Page 1 of 1

NEED HELP IN SORT

Posted: Wed Apr 09, 2014 12:08 pm
by amolpawar
Hi,

I have a file having length 80.

The file contains records with several record types i.e. 1,2,---8( One byte field only)

Sample Layout

1000 1 abcd -----
1000 2 hjaskdjk ----
2000 3 dfjkdjf dfgfg
2000 5 abcd -----
1000 5 hjaskdjk ----
2000 6 dfjkdjf dfgfg
1000 6 dfjkdjf dfgfg


I want above file to be sorted only for record type 5 for first 4 bytes , rest of the data should be same as input.

Sample output :

1000 1 abcd -----
1000 2 hjaskdjk ----
2000 3 dfjkdjf dfgfg
1000 5 abcd -----
2000 5 hjaskdjk ----
2000 6 dfjkdjf dfgfg
1000 6 dfjkdjf dfgfg

Regards,
Amol

Posted: Wed Apr 09, 2014 2:04 pm
by NicC
Is the data already in the order of the second field? Can you have multiple records for other record types? Going by the data supplied a simple sort on major key of record type and minor key of the first four bytes should be sufficient. If not, why not?

Posted: Wed Apr 09, 2014 11:15 pm
by DikDude
Suggest you repost your examples or clarify how the output came to be . . .

It would help if you defined the fields and used beter values than alphabet soup . . .

Posted: Thu Apr 10, 2014 2:32 am
by William Collins
Use OPTION EQUALS
In INREC, use IFTHEN=(WHEN=(logical expression to identify your type 5s, and OVERLAY=(81:1,4).

SORT on your record-type, followed by the extended field.

Use OUTREC BUILD=(1,80) to return to your original size.

Posted: Thu Apr 10, 2014 2:15 pm
by amolpawar
Hi,

I have a file having length 80.

The file contains records with several record types i.e. 1,2,---8( One byte field only)

input

1000 1 Amol
1000 2 Amit
2000 3 Sumit
2000 5 Supriya
1000 5 Rakesh
2000 6 Sarita
1000 6 satish


I want above file to be sorted only for record type 5 for first 4 bytes , rest of the data should be same as input.

Sample output :

1000 1 Amol
1000 2 Amit
2000 3 Sumit
1000 5 Rakesh -- order changed
2000 5 Supriya -- Order changed
2000 6 Sarita
1000 6 satish


There are multiple records for each record type but is it not neccessary to have amount field should be sorted in input file ( Position 1 to 4) , i want to sort on this amount field only for record type 5, rest of the record should be same as sorted on record type.

Regards,
Amol

Posted: Thu Apr 10, 2014 3:08 pm
by William Collins
Did you try what I suggested?

Posted: Thu Apr 10, 2014 7:04 pm
by NicC
no need to repost your original query - it just 'hides' the additional text.
but is it not neccessary to ...
does this mean that the others must not sorted on bytes 1-4 or does it mean that they can be and no harm is done?

Posted: Fri Apr 11, 2014 10:09 am
by amolpawar
Yes Nicc, i dont want to sort other record ( other than record type 5) on bytes 1-4.

Regards,
Amol

Posted: Fri Apr 11, 2014 10:37 am
by amolpawar
Hi William,

I am trying same, by increasing the record lenth for record type 5 and sorting on extended data and as per requirement , it should work. Thank you !