Records are in group with position (1,12) being the key field for each group. Group starts with' 10' and ends with '60' in position (13,2).
Group can have multiple '60' type records and the last 60 type records will be the end of group.
So, below BLUEJAY is a group.
However , BLUEJAY at 13th record does not have any record type 10, but only 60 type record.
My requirement is to identify all such records which does not have a 10 type record , but they have only 60 type record.
You can have multiple conditions on on BEGIN. You can have multiple IFTHEN=(WHEN=GROUP. You can have IFTHEN=(WHEN=INIT to do something unconditionally.
If you use your existing GROUP but include a SEQ, you can establish a second group where the SEQ-field is equal to one, and the record-type is not equal to ten. Push a flag to indicate those. Since you can't PUSH a constant, add the flag to the temporarily extended record first, then PUSH that to a new position. You should then be able to identify individual, or groups of, disconnected 60s. Except in one situation.
This is where a 60 is actually disconnected (however that happened) but is coincidentally adjactend to a 10 or another 60 for the same referenece. See if you can create those, then see if you can identify them.
Your first GROUP will always end after one record, it is marking the first of a group. So use RECORDS=1, not END= (where did you get LE,C'61' from?).
The GROUPs we are interested in are those that start with 60, so the second GROUP can be limited to that. This will simplify the OUTFIL. The "end" of the GROUP can, however, go beyond the key, but not a problem, so we need to deal with that.
Using OMIT= makes the OUTFIL easier to follow. Now excludes all records not marked by the second GROUP, and those marked by the second GROUP which are not 60.
The ID=1 is fine for the first GROUP, and the second, because all we need to know is ID or not ID, it does not matter if it overflows (more than nine groups).
To see how this is working, comment out the entire OUTFIL.
Once you are happy that you understand it, you can change the first PUSH to an ID=1 and change the location of the second PUSH to immediately after that ID, and change the position of the OMIT= to that position (16 in the example).
Assuming you are trying to find data errors, remember that it might be possible for a 60 to coincidentally appear in the "right" place, and it will not be possible to code for that from what we know. If there is something somewhere which tells how many 60s there should be for a 10, that should be included in this.