Page 1 of 1

DFSORT - JOINKEYS

Posted: Thu Mar 22, 2012 6:16 pm
by ragsara
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

Posted: Thu Mar 22, 2012 10:44 pm
by Frank Yaeger
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)
/*

Posted: Fri Mar 23, 2012 2:38 pm
by ragsara
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 :)

Posted: Fri Mar 23, 2012 10:00 pm
by Frank Yaeger
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.

Posted: Mon Mar 26, 2012 6:36 pm
by ragsara
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.

Posted: Mon Mar 26, 2012 11:35 pm
by Frank Yaeger
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.

Topic deleted by Admin

Posted: Mon Jan 25, 2016 10:29 pm
by academyindia4
<< Content deleted By Admin >>

Topic deleted by Admin

Posted: Mon Feb 01, 2016 10:06 pm
by academyindia4
<< Content deleted By Admin >>