View previous topic :: View next topic
Author
Message
ayushT New User Joined: 01 Oct 2007Posts: 23 Location: india
Hi,
I have two files one that contains a lookup value and the other the actual data. I have to replace the two fields (KEY1 & KEY2)in the actual file with the lookup values. The catch here is that my new value for the second field is actually dependent on the old values of KEY1 and KEY2
File A (length 40)contains ---> lookup file
oldvalue11newvalue11oldvalue21newvalue21
oldvalue12newvalue11oldvalue21newvalue22
oldvalue13newvalue13oldvalue21newvalue23
Old value of KEY1 starts at pos 1 and ends at pos 10
new value of KEY1 starts at pos 11 and ends at pos 20
Old value of KEY2 starts at pos 21 and ends at pos 30
new value of KEY2 starts at pos 31 and ends at pos 40
file B (lenth 30)contains ---> actual file
xoldvalue11xxxxoldvalue21xxxxx
xoldvalue13xxxxoldvalue21xxxxx
xoldvalue12xxxxoldvalue21xxxxx
Old value of KEY1 starts at pos 2 and ends at pos 11
Old value of KEY2 starts at pos 16 and ends at pos 25
Output(length 30) would be
xnewvalue11xxxxnewvalue21xxxxx
xnewvalue13xxxxnewvalue23xxxxx
xnewvalue12xxxxnewvalue22xxxxx
How will I be able to accomplish this thru icetool? Any suggestions !!!!!!!!!
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
ayusht,
The following DFSORT/ICETOOL JCL will give you the desired results. I assumed that both files do not have duplicates on the key and you only the matching keys in output.
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=your 40 byte file,
// DISP=SHR
//IN2 DD DSN=your 30 byte file,
// DISP=SHR
//T1 DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(X,Y),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) USING(CTL1)
COPY FROM(IN2) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(2,10,CH) ON(16,10,CH) -
WITH(01,30) USING(CTL3)
//CTL1CNTL DD *
OUTFIL FNAMES=T1,BUILD=(2:1,10,16:21,10,31:11,10,31,10)
//CTL2CNTL DD *
OUTFIL FNAMES=T1,OVERLAY=(31:20X)
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,IFOUTLEN=30,
IFTHEN=(WHEN=(31,20,CH,GT,C' '),OVERLAY=(2:31,10,16:41,10))
/*
Back to top
ayushT New User Joined: 01 Oct 2007Posts: 23 Location: india
What if my actual file has duplicates for the keys i.e.
30 byte file
xoldvalue11xxxxoldvalue21xxxxx
xoldvalue13xxxxoldvalue21xxxxx
xoldvalue11xxxxoldvalue21xxxxx
xoldvalue12xxxxoldvalue21xxxxx
I also want the icetool to
a) write out a file of unmatched records of actual file
b) The matched records should also maintain the same order as the actual file
Back to top
ayushT New User Joined: 01 Oct 2007Posts: 23 Location: india
Thank you Skol!!!!!!!
I built further and came up with this. It works fine
Code:
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(2,10,CH) ON(16,10,CH) -
WITHALL WITH(01,30) WITH(59,01) USING(CTL3) KEEPNODUPS
//CTL1CNTL DD *
OUTREC BUILD=(2:1,10,16:21,10,31:11,10,31,10,8X,59:C'11')
//CTL2CNTL DD *
OUTREC OVERLAY=(31:28X,59:C'22')
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,IFOUTLEN=30,
IFTHEN=(WHEN=(31,28,CH,GT,C' '),
OVERLAY=(2:31,10,12:41,10)),INCLUDE=(59,2,CH,NE,C'11')
OUTFIL FNAMES=UMATCH,INCLUDE=(59,2,CH,EQ,C'22'),BUILD=(1,30)
/*
Back to top
Please enable JavaScript!