IBM MainFrame Question:
Download Questions PDF

File1 has 100 records and file2 has 200 records i want to copy 50 records which r in both file into file3?

Answer:

First need to sort both files
READ FILE1
READ FILE2
PERFORM UNTIL EOF = 'Y'
IF FILE1-ID > FILE2-ID THEN
READ FILE2 AT END MOVE 'Y' TO EOF
ELSE IF FILE1-ID < FILE2-ID
READ FILE1 AT END MOVE 'Y' TO EOF
ELSE IF FILE1-ID = FILE2-ID
WRITE FILE3
READ FILE1 AT END MOVE 'Y' TO EOF
READ FILE2 AT END MOVE 'Y' TO EOF
END-PERFORM

Download IBM MainFrame Interview Questions And Answers PDF

Previous QuestionNext Question
How to fetch even records from one file to another file by using ICETOOL in JCL?What is use of linkage section?