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
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 |
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 |
Answer / harsha
correction to the above.
it is SUM FIELDS=NONE instead of SORT FIELDS
Is This Answer Correct ? | 3 Yes | 2 No |
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 |
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 |
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 |
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 |
I need exexution process for JCL programs
Can we use COND=EVEN on a job card, when jobs are scheduled through scheduler?
Can you delete the GDG base without deleting GDG generations ?
There is one QSAM is the VB file. i want to get the first characters in this file and change those characters from'abcd' to '1234' and creat a vasm file to put '1234' in it. how to do in only JCL. if it not QSAM, it's VASM and VB. how to do it.
What is the meaning of the following declaration : DCB=BLKSIZE=, What is the difference between above declaration & not specifying DCB at all for a output file?
can we have more than one job in a single job card that is we are specifying only one 'job' statement in the jcl.
in catalog procedure i have step1 dd dsn=filea dd dsn=fileb dd dsn=filec ur concatenaning all the files. but i need to override fileb with file 2 ? can anyone give the ans pls for ths
What is the significance of addrspc parameter in the exec statement?
Is there a way to check for an empty file in JCL other than using IEBCOMPR and the command PRINT COUNT(1)?
List the different jcl statements that are not permitted in the procedures?
IN-STREAM DATA NOT ALLOWED IN PROC how can come out from this problem
if we give TIME=0 how many sec that job/step