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

Match File 1 with File 2 and if found, write from File 2


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
teevijay

New User


Joined: 20 Mar 2006
Posts: 22

PostPosted: Thu Aug 14, 2008 11:43 am
Reply with quote

Sorry Guys,
Really running out of time...but need a quick help. i tried to use splice to match two files. File 1 is a driver( Key) file, and File 2 is key + data.
Requirement is, if there is a match, then write all the Matched records from File 2 into File 3.

File 1 --> Lrecl =2, Key @ 1 & 2 position
------
11
12
13
14
15

File 2 --> Lrecl = 10, Key @ 9 & 10 positions
------
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14
EEEEEEEE16
FFFFFFFF17
GGGGGGGG18
HHHHHHHH18

Code :
----------
//TOOLIN DD *
COPY FROM(IN1) TO(CMPP1) USING(CTL1)
COPY FROM(IN2) TO(CMPP2) USING(CTL2)
SPLICE FROM(CONCAT) TO(COMBINE) ON(9,2,CH) WITHALL WITH(1,10)

Output
------
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14
HHHHHHHH18 Key 18 is not there in File 1 but still its appearing in the output.

Kindly Help. Many thanks.
Vijay
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Aug 14, 2008 2:10 pm
Reply with quote

Vijay,

Can you try the below sort jcl.

Code:
//STEP00   EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*     
//IN1      DD *             
11                         
12                         
13                         
14                         
15                         
/*                         
//IN2      DD *                                                       
AAAAAAAA11                                                           
BBBBBBBB11                                                           
CCCCCCCC13                                                           
DDDDDDDD14                                                           
EEEEEEEE16                                                           
FFFFFFFF17                                                           
GGGGGGGG18                                                           
HHHHHHHH18                                                           
/*                                                                   
//TMP1     DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//OUT      DD SYSOUT=*                                               
//*                                                                   
//TOOLIN   DD *                                                       
 COPY FROM(IN1) TO(TMP1) USING(CTL1)                                 
 COPY FROM(IN2) TO(TMP1) USING(CTL2)                                 
 SPLICE FROM(TMP1) TO(OUT) ON(9,2,CH) WITH(1,10) WITHALL USING(CTL3) 
//*                                                   
//CTL1CNTL DD *                                       
 OPTION COPY                                           
 INREC FIELDS=(9:1,2,11:C'0 ')                         
//*                                                   
//CTL2CNTL DD *                                       
 OPTION COPY                                           
 INREC FIELDS=(1,10,11:C' 1')                         
//*                                                   
//CTL3CNTL DD *                                       
 OUTFIL FNAMES=OUT,OMIT=(11,1,CH,EQ,C' '),OUTREC=(1,10)
//*                                                   


OUT
Code:
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14


Thanks,
Arun
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Aug 14, 2008 10:50 pm
Reply with quote

Arun,

You don't need two id characters for this - one id character will do it.

Vijay,

You can use a DFSORT/ICETOOL job like this to do what you asked for:

Code:

//S1  EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN1 DD *
11
12
13
14
15
/*
//IN2 DD *
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14
EEEEEEEE16
FFFFFFFF17
GGGGGGGG18
HHHHHHHH18
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN   DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(9,2,CH) WITH(1,10) WITHALL USING(CTL3)
/*
//CTL1CNTL DD *
  OPTION COPY
  INREC BUILD=(9:1,2,11:C'1')
/*
//CTL2CNTL DD *
 OPTION COPY
  INREC OVERLAY=(11:C'2')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,OMIT=(11,1,CH,EQ,C'2'),BUILD=(1,10)
/*
Back to top
View user's profile Send private message
teevijay

New User


Joined: 20 Mar 2006
Posts: 22

PostPosted: Mon Aug 18, 2008 2:18 pm
Reply with quote

Thanks guys.
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Fri Oct 10, 2008 1:37 am
Reply with quote

All the records from file 2, which are present in file 1, are written to the output file.
Ok
But what if you want the records from file 2, which are NOT present in file 1, to be written to the output file. How becomes the code then?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Oct 10, 2008 3:56 am
Reply with quote

Show an example of your input records and what you want for output.
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Fri Oct 10, 2008 12:51 pm
Reply with quote

File 1 --> Lrecl =2, Key @ 1 & 2 position
------
11
12
13
14
15

File 2 --> Lrecl = 10, Key @ 9 & 10 positions
------
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14
EEEEEEEE16
FFFFFFFF17
GGGGGGGG18
HHHHHHHH18


Output
------
EEEEEEEE16
FFFFFFFF17
GGGGGGGG18
HHHHHHHH18

because 16, 17 and 18 aren't available in file 1.
See file 1 for instance as accounts. And file 2 as transactions on an account. If you can not find an account for a transaction in the account-file (file 1) it has to be written to the output file.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Oct 10, 2008 10:05 pm
Reply with quote

Here's a DFSORT/ICETOOL job for that requirement:

Code:

//S2  EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/2)
//IN2 DD DSN=...  input file1 (FB/10)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/10)
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(9,2,CH) KEEPNODUPS KEEPBASE -
  WITHALL WITH(1,11) USING(CTL3)
/*
//CTL1CNTL DD *
  OPTION COPY
  INREC BUILD=(9:1,2,11:C'BB')
/*
//CTL2CNTL DD *
 OPTION COPY
  INREC OVERLAY=(11:C'VV')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(11,2,CH,EQ,C'VV'),BUILD=(1,10)
/*
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top