Posted: Wed May 28, 2008 3:49 am Post subject: Insert new record in a detail record based on a condition
I have a file with header and detail records. The header records always starts with 1 in postion 1 and detail records with 2 in position 2.
The file is FB with LRECL=68.
Example of a file with header and trailer records.
1HEADER1 xxxxxxxxxxxxxxxxxxx
2AAAAA bbbbbb s
2WS-TITLE ABC CLEANUP IBNR - ACYEAR=2001 S
2BBBBB 20030401 S
2........ .... .
1HEADER2 xxxxxxxxxxxxxxxxxxx
2AAAAA bbbbbb S
2WS-TITLE ABC CLEANUP IBNR - ACYEAR=2001 S
2BBBBB 20030401 S
2GGGGGGG 0 S
2........ .... .
and so on.
I want to check for all detail records with 2WS-TITLE, get the value which is in position 53-64, which is ACYEAR=2001 in the first case and insert a new details record 2ACYEAR start position 1,2001 in position 34 and S in position 66 just after detail record 2WS-TITLE. This should be done every time a detail record with 2WS-TITLE is found.
1HEADER1 xxxxxxxxxxxxxxxxxxx
2AAAAA bbbbbb s
2WS-TITLE ABC CLEANUP IBNR - ACYEAR=2001 S
2ACYEAR 2001 S
2BBBBB 20030401 S
2........ .... .
1HEADER2 xxxxxxxxxxxxxxxxxxx
2AAAAA bbbbbb S
2WS-TITLE ABC CLEANUP IBNR - ACYEAR=2003 S
2ACYEAR 2003 S
2BBBBB 20030401 S
2GGGGGGG 0 S
2........ .... .
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