I've a file with some hundreds of records which are sorted based on some key fields.
Now, I need to edit a key field in all these records say first 200 records should have the value 123. Next 100 records should have 124. next 300 records to have value 125 and so on for 5 times in overall. And all these modified records have to be in the same output file.
As of now, i'm trying OUTFIL & SKIPREC,STOPAFT combination and writing into 5 different files and finally merging into a single file.
Is it possible to avoid this OUTFIL option/multiple files and do a SORT Operation directly to move into a single output file ???
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Extend each record to include a sequence number (varaible-length or fixed-length records dictate where to do the extension).
Use IFTHEN=(WHEN=INIT to set the SEQNUM with a RESTART on itself for the number of records you want in a group of records.
Use IFTHEN=(WHEN=GROUP with BEGIN for sequence zero and RECORDS= for the number in your group and PUSH an ID into where you want the data to be the same for each group.
Use IFTHEN=(WHEN=INIT to add 122 to your entire field which needs to change.
Please post your code once you have it working.
To develop the solution, add one piece at a time to a basic COPY operation. Once you are clear about what that does and that it is working, move on to the next.