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

Answers were Sorted based on User's Feedback



File1 has 100 records and file2 has 200 records i want to copy 50 records which r in both file int..

Answer / harsha

Give both input files in concatenation to SORTIN.
SORT FIELDS=NONE,XSUM

This will copy all duplicate records from both files to
SORTXSUM dataset.

Is This Answer Correct ?    5 Yes 1 No

File1 has 100 records and file2 has 200 records i want to copy 50 records which r in both file int..

Answer / madhavi chava

This can be coded as given below

//SORT1 EXEC PGM=SORT
//SORTJNF1 DD *
00000111111 000001234567 LOCAL =====
00000333333 000003456789 LOCAL =====
00000555555 000005678901 EXTRN =====
00000666666 000006789012 EXTRN =====
00000777777 000007890123 LOCAL =====
//SORTJNF2 DD *
00000222222 000002345678 ===== BCDEF
00000444444 000004567890 =====
DEFGH
00000666666 000006789012 ===== FGHIJ
00000888888 000008901234 ===== HIJKL
00000999999 000009012345 ===== JKLMN
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(1,11,A,13,12,A)
JOINKEYS FILES=F2,FIELDS=(1,11,A,13,12,A)
REFORMAT FIELDS=(F1:1,31,F2:32,5)
SORT FIELDS=COPY

output of the file3
00000666666 000006789012 EXTRN FGHIJ

Is This Answer Correct ?    2 Yes 0 No

File1 has 100 records and file2 has 200 records i want to copy 50 records which r in both file int..

Answer / harsha

correction to the above.
it is SUM FIELDS=NONE instead of SORT FIELDS

Is This Answer Correct ?    3 Yes 2 No

File1 has 100 records and file2 has 200 records i want to copy 50 records which r in both file int..

Answer / mani

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

Is This Answer Correct ?    0 Yes 0 No

File1 has 100 records and file2 has 200 records i want to copy 50 records which r in both file int..

Answer / kamaldeep

We can't use SUM FIELDS=NONE,XSUM as mentioned by Harsha.
if we merge 2 files then it may be the case that input file already has duplicate records, so it will not give required output.

Is This Answer Correct ?    0 Yes 0 No

File1 has 100 records and file2 has 200 records i want to copy 50 records which r in both file int..

Answer / ayusman

First you have to join the two files with help of JOJNKEYS
in jcl sort . after that copy first 50 records by using
sort utility

Is This Answer Correct ?    0 Yes 1 No

File1 has 100 records and file2 has 200 records i want to copy 50 records which r in both file int..

Answer / muttaiah

Hi Ayusman,
I hope u didn't get the question properly.
Question.
file1: (3 records assumption)
100 ayusman
200 muttaiah
300 allinterview

File 2: (3 records
400 google
500 yahoo
100 ayusman

File3:
100 ayusman

This is what the question is, they want all the duplicates
in both file1 & file2 in file3(first 50 records).

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More JCL Interview Questions

How do you run a COBOL batch program from a JCL? How do you run a COBOL/DB2 program?

0 Answers  


A STEP has more than 1 file as INPUT. And we have to put all these records int 1 output file. How to do ? //InputF  DD DSN=ID.File1              DSN=ID.File2              DSN=ID.File3

1 Answers   FIS,


1) max no of steps with jcl job can execute 2) how many extentions r possible in sequencial files with job 3) what is set parameter will do 4)how to get syntax errors without sub 5) what is differ between error and abend 6) hw mvs knows who submitted the job and whoom it has to forward 7) what are the positinal parameters of data descripter

1 Answers   L&T,


Please explain with syntax and an example, the Inrec fields and Outrec build in sort.

4 Answers   CTS, TCS,


I have a jcl which is using 2 data sets i want to override those data sets. how can i override the files within the JCL. Give me the syntax. Make sure that it is not calling any Proc.

1 Answers  






Explain about RECORDING MODE Clause

1 Answers  


Suppose i have 2 steps in my pgm. Step1- creates a file, Step2 - generates report from file in step1, What changes have to be made in Step2, so that if the file in Step1 is empty Step2 should not be executed? No changes to be made to Step1.

4 Answers   TCS,


What is a GDG? Why do we go for a GDG ? utility used to create GDG?

3 Answers   Xansa,


What is Cataloged Procedures?

0 Answers  


WORKING-STORAGE SECTION. 1 GROUP-ITEM. 05 AMOUNT-1 PIC 99V9 USAGE COMP VALUE 50. 05 AMOUNT-2 PIC 9(4)V99 USAGE COMP. PROCEDURE DIVISION. MOVE ZERO TO GROUP-ITEM. ADD 50 TO AMOUNT-1. DISPLAY AMOUNT-1. STOP RUN.

1 Answers  


Why do you want to specify the REGION parameter in a JCL step?

4 Answers   Kekran Mekran, TCS,


The maximum number of steps in a job?

4 Answers  


Categories