I have a requirement to modify the group header record depending on the contents of the detail records in the group.
The input file contains the following kinds of records:
File Header (pos 1 = FLEHD)
File Trailer (pos 1 = FLETR)
Group Header (pos 1 = GRPHD)
Group Detail (pos 1 = GRPDT) edited for typo
Group Trailer (pos 1 = GRPTR)
The file header and trailer occur only once: at the beinning and end of the file respectively.
There can be any number of group header, details and trailer records. The group header and trailer occur before and after the detail records in a group respectively.
The header needs to be modified as follows:
If byte 37 of the group header is set to 'N', then check byte 26 of all the detail records in the group. If byte 26 in any one of the detail records is set to '0', then set the byte 37 in the group header to 'Y'.
Here the first group is not checked as the byte 37 is Y.
In the second group byte 37 should be changed to Y as byte 26 is set to 0 in at least one of the details records (i.e. detail records 2,4,5 and 6)
The third group header is not altered as none of the detail records have byte 26 set to 0.
Really not sure if this can be done using ICETOOL
Any help on this highly appreciated.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
shettjs,
Is it ok to sort the detail records within each group? The idea is to get the 0 detail record next to the grphd record. If it is ok then use the following 1 pass DFSORT solution which will give you the desired results
Unfortunately we need to have the GRPDT records in the same sequence. Does that mean that we need to include a new sequence number field and then sort it based on that field in a second sort run?