Posted: Thu Nov 11, 2021 6:45 am Post subject: Sort subset of records within a file
Hi All,
We have a requirement where we have to sort the I621* and I618* record types. These records can occur between BH(batch header) and (BT)Batch Trailer records.
Currently, the records are being written in the order they are being received. From the below Input file, the order in one of the batch is I6211, I6212, I6181, I6182, I6183 and I6184. We need them to be in order of I6181, I6182, I6183, I6184, I6211, I6212. Only the record types I618* and I621* need to be ordered. For the other record types, there are no changes to the order.
We are planning either modify the program that creates the file or write a new program to arrange the records in the desired order.
Please let me know if there is any way the below can be achieved using DFSORT/ICETOOL.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Nov 11, 2021 7:27 am Post subject:
erasani,
Use the following untested which will give you the desired results. I assumed that your input file has LRECL=80 and RECFM=FB.
Basically you just tag the records with an ID number at position 81 whever there is a header or trailer.now within the group you put a constant of 0 at position 90 for all the records and when there is a I618* record you update that value to 1 and when there is I621* record you update the constant to 2.
Now sort on the ID number and the constant, so that the 0 records stay in the same place and 1 and 2 records will be sorted. Once we are done sorting just remove the id and the constant.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum