Hi, I would need help in getting this logic done.
I am having an input file in below format:
AAAAA HsfAgr345S 001 pos gfdgojog
AAAAA HsfAgr346S 001 pos gfdgojog
AAAAA HsfAgr347S 001 pos gfdgojog
BBBBB POSgfgh571 002 ipo postalap
BBBBB POSgfgh572 002 ipo postalap
BBBBB POSgfgh573 002 ipo postalap
BBBBB POSgfgh574 002 ipo postalap
BBBBB POSgfgh575 002 ipo postalap
I have to split the input file to two output files based on 001 and 002. i.e, I am writing 001 to separate file, and 002 to another file. - I am Done with this
Not more than 50 records per file. If the input file exceeds more than 50 records, I am writing to another 001 or 002 file by appending 'n'(1...n) at the end of filename - I am done with this
All records for a member(either AAAAA or BBBBB) must be included on the same output file
(ie. If the 50th record would split up a member's records then split the file at the last record of the previous member) - I Need Help on this logic.
Let us consider, if BBBBB POSgfgh573 002 ipo postalap is the 50 th line of output file, I have to take all BBBBB records(last five line lines of input file) and write it to next output file.
Please help me on this logic.