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

Selecting common records from 2 files.


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

New User


Joined: 10 Nov 2006
Posts: 49
Location: Canada

PostPosted: Wed Apr 30, 2008 12:38 am
Reply with quote

Hi,

I have 2 files:
File 1:
P000001XXXX
P000002XXXX
P000001YYYY
P000002YYYY
P000003YYYY
P000001ZZZZ
P000002ZZZZ
P000001AAAA

File2:
XXXX
YYYY
AAAA

Output file should have:
P000001XXXX
P000002XXXX
P000001YYYY
P000002YYYY
P000003YYYY
P000001AAAA

i.e the output file should have those records from File1 for which last 4 bytes File1 are present in 1st 4 bytes of File2.

Please suggest how it can be using ICETOOL.

Thanks.
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: Wed Apr 30, 2008 1:58 am
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your input files have RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes. I also assumed that you wanted the output records in the same order as the input records as shown in your example - that requires an extra pass.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *       input file1 (FB/80)
P000001XXXX
P000002XXXX
P000001YYYY
P000002YYYY
P000003YYYY
P000001ZZZZ
P000002ZZZZ
P000001AAAA
/*
//IN2 DD *       input file2 (FB/80)
XXXX
YYYY
AAAA
QQQQ
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN DD *
COPY FROM(IN2) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(T2) ON(8,4,CH) -
  WITHALL WITH(1,81) WITH(89,8) USING(CTL3)
SORT FROM(T2) TO(OUT) USING(CTL4)
/*
//CTL1CNTL DD *
  INREC BUILD=(8:1,4,81:C'BB',89:8X)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'VV',89:SEQNUM,8,ZD)
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=T2,INCLUDE=(81,2,CH,EQ,C'VB')
/*
//CTL4CNTL DD *
  SORT FIELDS=(89,8,ZD,A)
  OUTREC BUILD=(1,80)
/*
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
Search our Forums:

Back to Top