|
View previous topic :: View next topic
|
| Author |
Message |
pgopi92
New User
Joined: 29 Oct 2014 Posts: 3 Location: india
|
|
|
|
Hi Friends,
In want sort card which meets the below condition.
Input file:
| Code: |
3777345820160121123819HDR
3777345820160121123819SHP011
3777345820160121123819SHPA21
3777345820160121123819SHP031
3777345820160121123819SHP038
3777345820160121123819SHP0AA
3777348020160121124214HDR
3777348020160121124214SHP042
3777348020160121124214SHPA48
3777348020160121124214SHP011
3777348020160121124214SHP031 |
In input file many HDR records would be present followed by detail records (SHP) here my requirement would be
1) I Just want to sort detail records that to last field i.e 031 should come first rest detail records i don't care. As like below output file
output file would be like this:
| Code: |
3777345820160121123819HDR
3777345820160121123819SHP031
3777345820160121123819SHPA21
3777345820160121123819SHP0AA
3777345820160121123819SHP011
3777345820160121123819SHP038
3777348020160121124214HDR
3777348020160121124214SHP031
3777348020160121124214SHPA48
3777348020160121124214SHP011
3777348020160121124214SHP042 |
Appreciate you help.
Code'd and de-emphasised |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It's not tricky at all. You need a three-byte temporary extension to each record, which will contain your minor sort-key. Since you don't care about the order of the other records, you can just set this minor-sort key to the value with WHEN=INIT, and use WHEN=(logicalexpression) to test for 031 and set it to, for instance, X'000000'.
Sort on your key, followed by minor key. In OUTREC or OUTFIL return record to original size. |
|
| Back to top |
|
 |
pgopi92
New User
Joined: 29 Oct 2014 Posts: 3 Location: india
|
|
|
|
Hi Bill,
Thanks much for your advise,
It would be more grateful if you provide the sort card. |
|
| Back to top |
|
 |
pgopi92
New User
Joined: 29 Oct 2014 Posts: 3 Location: india
|
|
|
|
Thank much Bill,
I have done with the help of yours...
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(2679:C'C')),
IFTHEN=(WHEN=(631,3,CH,EQ,C'031'),
OVERLAY=(2679:C'B')),
IFTHEN=(WHEN=(023,3,CH,EQ,C'HDR'),
OVERLAY=(2679:C'A'))
SORT FIELDS=(26,5,A,1,8,A,9,14,D,2548,6,A,2585,7,A,2679,1,A),
FORMAT=CH,EQUALS
OUTREC BUILD=(1:1,2679)
Thank you soooo much for you advise..  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|