Each BLOCK OF RECORD starts with AAP and then followed by 10 records. That is, each BLOCK OF RECORD consists of 11 records.
Also, if you notice the 2nd and 3rd BLOCK OF RECORD, you would see numerous ')'. I am referring to these as BLOCKS OF RECORDS WITH INVALID DATA, whereas, the 1st BLOCK OF RECORD could be referred to as a BLOCK OF RECORD WITH VALID DATA.
My requirement is to: -
(1) Write out a BLOCK OF RECORD WITH VALID DATA to an Output File, say A.
NOTE: - The entire BLOCK OF RECORD WITH VALID DATA (starting with AAP and then followed by 10 records, that is, a total of 11 records constituting the entire block) needs to be written to the Output File A.
(2) Write out a BLOCK OF RECORD WITH INVALID DATA to another Output File, say B.
NOTE: - The entire BLOCK OF RECORD WITH INVALID DATA (starting with AAP and then followed by 10 records, that is, a total of 11 records constituting the entire block) needs to be written to the Output File B.
(3) In short, the Output File A should only have BLOCKS OF RECORDS WITH VALID DATA, whereas the Output File B should only have BLOCKS OF RECORDS WITH INVALID DATA.
POINTS TO REMEMBER ABOUT a BLOCK OF RECORD WITH INVALID DATA: -
1. A BLOCK OF RECORD WITH INVALID DATA contains numerous ')'.
2. The ')' need not always be continuous, as in the 3rd Block.
3. The ')' might also be continuous, as in the 2nd Block.
SOME OTHER POINTS TO REMEMBER: -
1. Input File has LRECL=80 and RECFM=FB.
2. There is no SPACE in between the BLOCKS OF RECORDS in the Input File. For the above-mentioned 3 BLOCKS OF RECORDS, I have deliberately inserted a SPACE in between each BLOCK OF RECORD for clarity of understanding.
3. I would need to use DFSORT.
Yes, the ")" is valid anywhere in any BLOCK OF RECORD. But, if the count of ")" is more than 5 in number in a paqrticular BLOCK OF RECORD, then that particular BLOCK OF RECORD is treated as a BLOCK OF RECORD WITH INVALID DATA and needs to be written to the Output File B.
On the other hand, if the count of ")" is less than 5 in number in a paqrticular BLOCK OF RECORD, then that particular BLOCK OF RECORD is treated as a BLOCK OF RECORD WITH VALID DATA and needs to be written to the Output File A.
I am sure there probably is a better solution but I can't think of a way to do it in a single pass. Trick here is to use JOINKEYs to SORT the same file twice in the same step. Keep in mind, INB needs to have 1 records with SPACES. For testing, I kept INB as 80 byte but that doesn't have to be 80 byte long.