Tony,

It is quite easy to get the matching records from both files. Here is a 
DFSORT JCL which will give you the desired results. I assumed that your 
inputs are already pre-sorted on the key to be matched. If they are not 
then you just need to remove SORTED,NOSEQCK parms from the control cards.

//STEP0100 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=* 
//INPUT1   DD * 
KEY1 DATA-X 
KEY1 DATA-Y 
KEY1 DATA-Z 
KEY2 DATA-M 
KEY2 DATA-N 
KEY2 DATA-O 
//INPUT2   DD * 
KEY1 BLAH 
KEY2 BLAH 
//SORTOUT  DD SYSOUT=* 
//SYSIN    DD * 
  OPTION COPY 
  JOINKEYS F1=INPUT1,FIELDS=(1,4,A),SORTED,NOSEQCK 
  JOINKEYS F2=INPUT2,FIELDS=(1,4,A),SORTED,NOSEQCK 
  REFORMAT FIELDS=(F2:1,12,F1:6,10) 
//*                                                

Check this link which explains in detail about Joinkeys

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA60/4.0?

Further if you have any questions please let me know

Thanks,
Kolusu
DFSORT Development
IBM Corporation

IBM Mainframe Discussion List <IBM-MAIN@listserv.ua.edu> wrote on 
02/11/2014 06:28:26 AM:

> From: TonyICLOUD <tonybabo...@icloud.com>
> To: IBM-MAIN@listserv.ua.edu, 
> Date: 02/11/2014 06:29 AM
> Subject: DF/SORT, joinkeys or splice ?
> Sent by: IBM Mainframe Discussion List <IBM-MAIN@listserv.ua.edu>
> 
> I'm trying to match-merge 2 input files based on a key.  I want to 
> create an output file with a record for every key from input1 plus all 
> records with a match key from input2.  I haven't found a specific 
> example in the books so I'm asking for help.
> 
> What I have:
> 
> //input1 dd *
> key1 blah
> key2 blah
> //input2 dd*
> key1 data-x
> key1 data-y
> key1 data-z
> key2 data-m
> key2 data-n
> key2 data-o
> 
> What I wish to have, an output record per key from input1 times each key 

> value found from input2 :
> 
> key1 blah data-x
> key1 blah data-y
> key1 blah data-z
> key2 blah data-m
> key2 blah data-n
> key2 blah data-o
> 
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
> 

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to