Page 1 of 1

Matched records alone need in o/p from both file !

PostPosted: Sun Dec 21, 2008 2:51 pm
by ranga_subham
Hi,

I have two files and want the matched records only in the output from both the files :!: A temporary identification can be applied to both the files to determine the origin from where there come in the output.

INPUT-1:
----+----1----+----2----+----3----
VX2                GGGVX2     2460
BC2                MMMBC2     2160
GF2                KKKGF2     2460


INPUT-2:
----+----1----+----2----+----3----
VX2                GGGVX2     2442
VX2                GGGVX2     2442
GF2                KKKGFM     2442
GF2                KKKGFM     2442
GF2                KKKGFM     2442
GF2                KKKGFM     2442
J42                KRTJ42     2442
JK2                KRTJK2     2442


OUTPUT WITH MATCHED RECORDS:
----+----1----+----2----+----3----+----4
VX2                GGGVX2     2460     1
VX2                GGGVX2     2442     2
VX2                GGGVX2     2442     2
GF2                KKKGF2     2460     1
GF2                KKKGFM     2442     2
GF2                KKKGFM     2442     2
GF2                KKKGFM     2442     2
GF2                KKKGFM     2442     2


Note: Both the files may contain duplicates and are NOT in sorted order.

Please suggest.

Thanks.

Re: Matched records alone need in o/p from both file !

PostPosted: Mon Dec 22, 2008 9:18 pm
by Alissa Margulies
Is the temporary file identification a requirement? Also, what fields are you matching (1-3,20-25,1-25)?

Re: Matched records alone need in o/p from both file !

PostPosted: Tue Dec 23, 2008 11:42 am
by ranga_subham
The field to be compared starts from 16th column (10 bytes). Applying an id is not part of requirement but to know from which file the records have come because matching records are to be pulled out from both the files including duplicates.
Thanks.

Re: Matched records alone need in o/p from both file !

PostPosted: Fri Jan 02, 2009 11:23 pm
by Alissa Margulies
If your records can be pre-processed with a sequence number in addition to the file id, then here is a sample application you can use:

//STEP1  EXEC PGM=SORT               
//SORTOUT  DD DISP=(NEW,PASS),DSN=TEMP.DATASET,...
//SORTJNF1 DD *                             
VX2                GGGVX2     2460 1       1
BC2                MMMBC2     2160 1       2
GF2                KKKGF2     2460 1       3
//SORTJNF2 DD *                             
VX2                GGGVX2     2442 2       1
VX2                GGGVX2     2442 2       2
GF2                KKKGFM     2442 2       3
GF2                KKKGFM     2442 2       4
GF2                KKKGFM     2442 2       5
GF2                KKKGFM     2442 2       6
J42                KRTJ42     2442 2       7
JK2                KRTJK2     2442 2       8
//SYSOUT   DD SYSOUT=*   
//SYSIN    DD *                               
  JOINKEYS FILE=F1,FIELDS=(1,3,A)             
  JOINKEYS FILE=F2,FIELDS=(1,3,A)             
  REFORMAT FIELDS=(F1:1,44,F2:1,44)           
  SORT FIELDS=COPY                             
  OUTFIL OUTREC=(1:1,44,/,1:45,44)             
//*********************************************
//STEP2  EXEC PGM=SORT                         
//SORTIN   DD DISP=SHR,DSN=TEMP.DATASET
//SORTOUT  DD DSN=FINAL.OUTPUT,...
//SYSOUT   DD SYSOUT=*                         
//SYSIN    DD *                               
   SORT FIELDS=(20,6,CH,A,36,1,CH,A,37,8,CH,A)
   DUPKEYS FIELDS=NONE                             
   OUTREC BUILD=(1,36)
/*   

NOTE:
Support for DUPKEYS was included in SyncSort for z/OS 1.3. If you are running an earlier release, you can replace DUPKEYS with SUM.

Re: Matched records alone need in o/p from both file !

PostPosted: Sat Jan 03, 2009 4:28 pm
by ranga_subham
Thank you. We are still at v1.2 only :(

Re: Matched records alone need in o/p from both file !

PostPosted: Mon Jan 05, 2009 9:23 am
by Alissa Margulies
Then as I previously mentioned, you can code SUM FIELDS instead of DUPKEYS FIELDS.