DFSORT - JOINKEYS
Moderators: Frank Yaeger, Moderator Group
DFSORT - JOINKEYS
Hi
I am trying to join File F1 and File 2 with keys in position 1 to 75 in both the files.
A key in in F1 contains two matching records in F2. Normally when we perform join two records gets written into the output file.
But according to my requirement, I need only one record in the output. However, I should write the matching columns one after the other in the same record.
For instance, if keys match, I should write position 1 to 75 (key), followed by pos 76 to 200 (the first match), followed by the second match from position 201 to 325.
Is this possible in Joinkeys? if so please help me
Please find the below example
File 1
----+----1----+----2----+----3
00001
00002
File2
----+----1----+----2----+----3
00001 M12345
00001 P12345
00002 M12345
00002 P12345
OUTPUT FILE
----+----1----+----2----+----3
00001 M12345P12345
00002 M12345P12345
I am trying to join File F1 and File 2 with keys in position 1 to 75 in both the files.
A key in in F1 contains two matching records in F2. Normally when we perform join two records gets written into the output file.
But according to my requirement, I need only one record in the output. However, I should write the matching columns one after the other in the same record.
For instance, if keys match, I should write position 1 to 75 (key), followed by pos 76 to 200 (the first match), followed by the second match from position 201 to 325.
Is this possible in Joinkeys? if so please help me
Please find the below example
File 1
----+----1----+----2----+----3
00001
00002
File2
----+----1----+----2----+----3
00001 M12345
00001 P12345
00002 M12345
00002 P12345
OUTPUT FILE
----+----1----+----2----+----3
00001 M12345P12345
00002 M12345P12345
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
I'd suggest using the a DFSORT/ICETOOL SPLICE job like the following rather than JOINKEYS:
Code: Select all
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/75)
//IN2 DD DSN=.... input file2 (FB/200)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=... output file (FB/325)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,75,CH) WITHANY -
WITH(76,125) WITH(201,125) WITH(326,1) USING(CTL3)
//CTL1CNTL DD *
INREC OVERLAY=(326:C'BB',X)
//CTL2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(326:C'VV')),
IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,75),PUSH=(328:SEQ=1)),
IFTHEN=(WHEN=(328,1,ZD,EQ,2),BUILD=(1,75,201:76,125,326,3))
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(326,2,CH,EQ,C'VB'),
BUILD=(1,325)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Thanks Frank,
Why i have decided to go for for Join keys is for the following reason,
File1 - 520 (first 75 key)
File2 - 250 (First 75 key)
I need to evaluate 76th position in File 2, to see if its P or M .
Based on this i need to evaluate File1 and File2, here are the scenarios which i need to handle :
1) Nomatch - Keep File1 record alone in the output file. Output file - (520(F1) + 175X(space) + 175X(space))
2) Match with P of File 2 alone - Keep File1 record + P record of File2 . Output file - (520(F1) + 175(P of F2) + 175X(space))
3) Match with M of File2 alone - Keep File 1 record + M record of file2. Output file - (520(F1) + 175X(space) + 175(M of F2) )
4) If matched with both P and M of F2 - Keep File 1 record + P record of File2 + Mrecord of File2. Output file - (520(F1) + 175(P of F2) + 175(M of F2) )
It will be great if we can handle this too in ICETOOL
Why i have decided to go for for Join keys is for the following reason,
File1 - 520 (first 75 key)
File2 - 250 (First 75 key)
I need to evaluate 76th position in File 2, to see if its P or M .
Based on this i need to evaluate File1 and File2, here are the scenarios which i need to handle :
1) Nomatch - Keep File1 record alone in the output file. Output file - (520(F1) + 175X(space) + 175X(space))
2) Match with P of File 2 alone - Keep File1 record + P record of File2 . Output file - (520(F1) + 175(P of F2) + 175X(space))
3) Match with M of File2 alone - Keep File 1 record + M record of file2. Output file - (520(F1) + 175X(space) + 175(M of F2) )
4) If matched with both P and M of F2 - Keep File 1 record + P record of File2 + Mrecord of File2. Output file - (520(F1) + 175(P of F2) + 175(M of F2) )
It will be great if we can handle this too in ICETOOL
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
I don't understand how you expect somebody to help you if you only give a small part of your requirement the first time. If you knew you needed all of that you described in your second post, why didn't you say so?
Your full requirement is certainly not clear at this point. In your original example, every record in file1 had a match in file2. Now you're talking about unmatched records as well. You need to start over and show a much better example of input and expected output for your full requirement covering all possible variations including duplicates within file1 and duplicates within file 2 (matching/non-matching) where possible.
Your full requirement is certainly not clear at this point. In your original example, every record in file1 had a match in file2. Now you're talking about unmatched records as well. You need to start over and show a much better example of input and expected output for your full requirement covering all possible variations including duplicates within file1 and duplicates within file 2 (matching/non-matching) where possible.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Hi Yaeger,
Apologise for not providing you the complete requirement at the first look.
Here is an example of my requiremnet.
File1 :
Record 1: 1-75 (KEY) 76-521 (DATA)
File2 :
Record 1: 1-75 (KEY) 76 (P) 77-277(DATA)
Record 2: 1-75 (KEY) 76 (M) 77-277(DATA)
Output file
Record 1 : 1-75 (KEY File1) 76-521 (DATA File1) 522 ('P' Record1 & File2) 523-708 (Data Record 1 & File2) 709 ('M' Record2 & File2) 710-894 (Data Record 2 & File2)
Scenarios :
1)File 1 wont contain any duplicates.
2)In Normal case , For each Key in File1 , File 2 has two corresponding records (P and M).
3)In abnormal case , If File 1 doesnt have any match then output data corresponding to File 2 has to be populated with spaces.
Output file
Record 1 : 1-75 (KEY File1) 76-521 (DATA File1) 522 ('SPACE' Record1 & File2) 523-708 (SPACE Record 1 & File2) 709 ('SPACE' Record2 & File2) 710-894 ('Space' Record 2 & File2)
4) In certain case where File 2 conatins only 'P' or 'M' record for a match with File1, then 'P' or 'M' data should be populated rest should be populated with spaces. Lets assume only 'M' record is present for a match in File1, then the output file will look like :
Output file
Record 1 : 1-75 (KEY File1) 76-521 (DATA File1) 522 ('Space' Record1 & File2) 523-708 (Space Record 1 & File2) 709 ('M' Record2 & File2) 710-894 (Data Record 2 & File2)
Please let me know if am clear or you need more explanation.
Apologise for not providing you the complete requirement at the first look.
Here is an example of my requiremnet.
File1 :
Record 1: 1-75 (KEY) 76-521 (DATA)
File2 :
Record 1: 1-75 (KEY) 76 (P) 77-277(DATA)
Record 2: 1-75 (KEY) 76 (M) 77-277(DATA)
Output file
Record 1 : 1-75 (KEY File1) 76-521 (DATA File1) 522 ('P' Record1 & File2) 523-708 (Data Record 1 & File2) 709 ('M' Record2 & File2) 710-894 (Data Record 2 & File2)
Scenarios :
1)File 1 wont contain any duplicates.
2)In Normal case , For each Key in File1 , File 2 has two corresponding records (P and M).
3)In abnormal case , If File 1 doesnt have any match then output data corresponding to File 2 has to be populated with spaces.
Output file
Record 1 : 1-75 (KEY File1) 76-521 (DATA File1) 522 ('SPACE' Record1 & File2) 523-708 (SPACE Record 1 & File2) 709 ('SPACE' Record2 & File2) 710-894 ('Space' Record 2 & File2)
4) In certain case where File 2 conatins only 'P' or 'M' record for a match with File1, then 'P' or 'M' data should be populated rest should be populated with spaces. Lets assume only 'M' record is present for a match in File1, then the output file will look like :
Output file
Record 1 : 1-75 (KEY File1) 76-521 (DATA File1) 522 ('Space' Record1 & File2) 523-708 (Space Record 1 & File2) 709 ('M' Record2 & File2) 710-894 (Data Record 2 & File2)
Please let me know if am clear or you need more explanation.
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
As previously requested, show an example of the records in your input files and the expected output for all possible cases. Your descriptions of the rules are difficult to follow, so examples would certainly help.Please let me know if am clear or you need more explanation.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page