Page 1 of 1

Split into 3 files with sum fields on header

PostPosted: Tue Jan 06, 2015 3:06 pm
by nmr4u
Need to split a file into 3 files as follows.

Input file:
                205099                                            <
                                        42964205//          443ABC
              000000000                   964205830000000000   4201
               ........                   9642054452907309110024201             13
               ........                   9642054452797319210004201             13
                205099                                            <
                                        42907205//          445ABC
              000000000                   907205830000000000   4201
               ........                   9072053652907795010084201             13
               ........                   9072053652797805110044201             13

Controls:
1. Position 67 = "<" indicates Header level 1.
2. Position 64 to 66 = "ABC" indicates Header level 2.
3. Position 51 to 60 filled with zeroes indicate Header level 3.
4. Other records are detail records.
5. The input file needs to be split into 3 files based on the value in the detail records' position 49-54 as per the following data member.
000000 147000 532 F1
147001 314000 843 F2
314001 423000 334 F3
423001 547578 897 F1
547579 747000 234 F3
747001 748000 885 F1
748001 999999 174 F2

Layout for the above data:
Position 1 to 6 = Range start value
Position 8 to 13 = Range end value
Position 15 to 17 = Control number
Position 19 to 20 = Output file number

As per the match for detail records' position 49-54 in the above said ranges, the "Control number" & output split file number are identified.
6. In the output file, all three headers are required in all the split files.
7. On the appropriate split file, replace position 61 to 63 on Header level 2 with "Control number".
8. On the appropriate split file, for Header level 3 position 15 to 23 (comp-3), populate the sum of detail records' position 16 to 23 (comp-3).
9. If there is no detail record for a specific header record bunch, the header record bunch should not be written to the output file.

Please assist.