Re: HOW TO GET REQUIRED FIELDS INTO O/P FILE
Posted: Wed Mar 09, 2011 3:25 pm
So, you have to tell us what you've done to process the spanned records... because we don't know where the data is or how it is arranged otherwise. Hopefully you've not done anything to make it more difficult.
Try this.
Try this.
01 RECORD-TO-BE-SEARCHED REDEFINES INPUT-RECORD.
05 FILLER OCCURS x TIMES DEPENDING ON BYTES-BEFORE-ITEM-IDENTIFIER.
10 FILLER PIC X.
05 ITEM-ITSELF.
10 ITEM-LENGTH COMP PIC S9(9) (maybe, doesn't specify).
10 FILLER OCCURS x TIMES DEPENDING ON LENGTH-OF-ITEM-LESS-ITS-LENGTH. (note, not ITEM-LENGTH)
15 FILLER PIC X.
05 DATA-TO-SEARCH-FOR PIC XX.
To start processing a new record,
Set BYTES-BEFORE-ITEM-IDENTIFIER to the fixed number of bytes before it could be item data
Set LENGHT-OF-ITEM to zero (yes, zero)
Then you can test ITEM-ITSELF against your table of requests. If it matches, put your key into your ouput record, calculate lenght-of-item-less... and move ITEM-ITSELF to output record. Write. Add ITEM-LENGTH to
BYTES-BEFORE-ITEM-IDENTIFIER and then you'll basically be there.
Of course, you'll need to be checking the length of your input record itself, or number of items on it, whatever you have and have not mentioned (or not obviously enough).
05 FILLER OCCURS x TIMES DEPENDING ON BYTES-BEFORE-ITEM-IDENTIFIER.
10 FILLER PIC X.
05 ITEM-ITSELF.
10 ITEM-LENGTH COMP PIC S9(9) (maybe, doesn't specify).
10 FILLER OCCURS x TIMES DEPENDING ON LENGTH-OF-ITEM-LESS-ITS-LENGTH. (note, not ITEM-LENGTH)
15 FILLER PIC X.
05 DATA-TO-SEARCH-FOR PIC XX.
To start processing a new record,
Set BYTES-BEFORE-ITEM-IDENTIFIER to the fixed number of bytes before it could be item data
Set LENGHT-OF-ITEM to zero (yes, zero)
Then you can test ITEM-ITSELF against your table of requests. If it matches, put your key into your ouput record, calculate lenght-of-item-less... and move ITEM-ITSELF to output record. Write. Add ITEM-LENGTH to
BYTES-BEFORE-ITEM-IDENTIFIER and then you'll basically be there.
Of course, you'll need to be checking the length of your input record itself, or number of items on it, whatever you have and have not mentioned (or not obviously enough).