IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Match on two fields


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts Converting unpacked fields to pack us... SYNCSORT 4
No new posts Data for newly added fields not displ... IMS DB/DC 6
This topic is locked: you cannot edit posts or make replies. SUM FIELDS=NONE in reverse - Get dupl... DFSORT/ICETOOL 9
Search our Forums:

Back to Top