The logic should be to read the second column (e.g. 310) from A, search for 310 in B, take the contents of B and write in C. Could you please let me know if this can be done using only JCL utilities?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
I'll take "the output records can be in the same order as in file A" to mean they must be in the same order as in file A (we could use a simpler job if the output records could be in key order).
With that assumption, here's a DFSORT/ICETOOL job that will do what you asked for:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
1234567 310
5345545 001
3456567 010
//IN2 DD *
310 ZZZZ
010 ABCD
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
* IN2->T1: Reformat records to:
* |key|data..|blanks|
COPY FROM(IN2) TO(T1) USING(CTL1)
* IN1->T1: Reformat records to:
* |key|blanks|seqnum|
COPY FROM(IN1) TO(T1) USING(CTL2)
* Use SPLICE to get only matching records as:
* |key|data..|seqnum|
SPLICE FROM(T1) TO(T2) ON(1,3,CH) WITH(81,8)
* Sort on seqnum to get spliced records back in their original
* IN1 order. Remove seqnum.
SORT FROM(T2) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
OUTREC FIELDS=(1,80,8X)
/*
//CTL2CNTL DD *
OUTREC FIELDS=(10,3,81:SEQNUM,8,ZD)
/*
//CTL3CNTL DD *
SORT FIELDS=(81,8,ZD,A)
OUTREC FIELDS=(1,80)
/*
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from: