One file consists of header records and detail records.
Key of the file is Emp no, Dept no and Record type.
Here record-type=0 means header. 1,2 etc indicates detail records. EMP-NO and DEPT-NO fields are common to both header and detail records. Emp-status field is only present in header records. I want to extract all the employee records where emp-status=confirmed. But it should extract the corresponding detail records also.
EMP-NO DEPT-NO RECORD-TYPE EMP-STATUS REMAINING DATA
X(4) X(2) 9(2) X(9) X(33)
A111 B1 0 TEMPORARY
A111 B1 1 ………………………………………
A111 B1 2 ………………………………………
B111 B1 0 CONFIRMED
B111 B1 1 ………………………………………
B111 B1 2 ………………………………………
C111 B1 0 TEMPORARY
C111 B1 1 ………………………………………
C111 B1 2 ………………………………………
C111 B1 3 ………………………………………
D111 B1 0 CONFIRMED
D111 B1 1 ………………………………………
Output should be
B111 B1 0 CONFIRMED
B111 B1 1 ………………………………………
B111 B1 2 ………………………………………
D111 B1 0 CONFIRMED
D111 B1 1 ………………………………………
Could someone please help me out ?