Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Match File 1 with File 2 and if found, write from File 2
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: 2276
Location: @my desk

PostPosted: Thu Aug 14, 2008 2:10 pm    Post subject:
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 Moderator


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

PostPosted: Thu Aug 14, 2008 10:50 pm    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Fri Oct 10, 2008 3:56 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Fri Oct 10, 2008 10:05 pm    Post subject:
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    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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am
No new posts Occurrence of various strings within ... TS70363 JCL & VSAM 1 Thu Apr 27, 2017 8:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us