shuko Beginner
Joined: 08 Nov 2005 Posts: 73 Topics: 20
|
Posted: Tue May 27, 2008 7:22 am Post subject: Insert a 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 detail records.
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+-
start pos 1 start pos 34 start pos 66
1HEADER1 xxxxxxxxxxxxxxxxxxx
2AAAAA bbbbbb s
2WS-TITLE IGR CLEANUP IBNR - ACYEAR=2001 S
2BBBBB 20030401 S
2........ .... .
1HEADER2 xxxxxxxxxxxxxxxxxxx
2AAAAA bbbbbb S
2WS-TITLE IGR 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 position 34 and S in position 66 for every 2WS-TITLE found in detail record.
Expected output file
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+-
start pos 1 start pos 34 start pos 66
1HEADER1 xxxxxxxxxxxxxxxxxxx
2AAAAA bbbbbb s
2WS-TITLE IGR CLEANUP IBNR - ACYEAR=2001 S
2ACYEAR 2001 S
2BBBBB 20030401 S
2........ .... .
1HEADER2 xxxxxxxxxxxxxxxxxxx
2AAAAA bbbbbb S
2WS-TITLE IGR CLEANUP IBNR - ACYEAR=2003 S
2ACYEAR 2003 S
2BBBBB 20030401 S
2GGGGGGG 0 S
2........ .... .
|
Thank you
Shuko |
|