DFSORT - JOINKEYS

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
ragsara
Member
Posts: 3
Joined: Thu Mar 22, 2012 4:51 pm

DFSORT - JOINKEYS

Post by ragsara » Thu Mar 22, 2012 6:16 pm

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

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu Mar 22, 2012 10:44 pm

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

ragsara
Member
Posts: 3
Joined: Thu Mar 22, 2012 4:51 pm

Post by ragsara » Fri Mar 23, 2012 2:38 pm

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 :)

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Mar 23, 2012 10:00 pm

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.
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

ragsara
Member
Posts: 3
Joined: Thu Mar 22, 2012 4:51 pm

Post by ragsara » Mon Mar 26, 2012 6:36 pm

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.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Mon Mar 26, 2012 11:35 pm

Please let me know if am clear or you need more explanation.
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.
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

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 10:29 pm

<< Content deleted By Admin >>

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Feb 01, 2016 10:06 pm

<< Content deleted By Admin >>

Post Reply

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



Other References
Mainframe Tools and others