Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Match on two fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
ayushT

New User


Joined: 01 Oct 2007
Posts: 23
Location: india

PostPosted: Thu Feb 05, 2009 7:21 am    Post subject: Match on two fields
Reply with quote

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
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Feb 06, 2009 1:47 am    Post subject: Reply to: Match on two fields
Reply with quote

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
View user's profile Send private message
ayushT

New User


Joined: 01 Oct 2007
Posts: 23
Location: india

PostPosted: Sun Feb 08, 2009 6:36 am    Post subject:
Reply with quote

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
View user's profile Send private message
ayushT

New User


Joined: 01 Oct 2007
Posts: 23
Location: india

PostPosted: Wed Feb 11, 2009 6:00 am    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us