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
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.