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

Compare 2 Files & Write Specific Mismatch to Output


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

New User


Joined: 04 Jun 2007
Posts: 34
Location: Chennai

PostPosted: Tue Feb 26, 2008 3:59 pm
Reply with quote

Hi,
I have a certain job in which I'm required to compare two files. I'm supposed to write records to the Output that are Present in the First File, but absent in the first.
For Example, if I have the Two Input Files as below:

File I:
10000 1234 ABC 9999
10001 1235 XYZ 9090
10002 1236 AXZ 9009

File II:
10000 1234 ABC 9999
10002 1236 AXZ 9009
10006 9999 MAD 1111

I need the Output file as below:

Output File:
10000 1234 ABC 9999
10002 1236 AXZ 9009

It's Possible using DFSORT. The Key Fields are 1:5,BI & 12:3,CH. Can someone help me with this please?
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Tue Feb 26, 2008 5:12 pm
Reply with quote

hi,

Quote:
Present in the First File, but absent in the first


what do you mean by the above statement?
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Tue Feb 26, 2008 6:00 pm
Reply with quote

hi,

As per your above example the output file contains the records which are matching in both the input files...is that what you need?
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: Tue Feb 26, 2008 9:46 pm
Reply with quote

Prasanya,

If you want the records from input file1 that have a match in input file2 on those two keys, you can use a DFSORT/ICETOOL job like this:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//CON DD *
10000 1234 ABC 9999
10001 1235 XYZ 9090
10002 1236 AXZ 9009
/*
//    DD *
10000 1234 ABC 9999
10002 1236 AXZ 9009
10006 9999 MAD 1111
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(1,5,BI) ON(12,3,CH) FIRSTDUP
/*


If that's not what you want, then you need to do a better job of explaining what you do want.
Back to top
View user's profile Send private message
Prasanya

New User


Joined: 04 Jun 2007
Posts: 34
Location: Chennai

PostPosted: Wed Feb 27, 2008 8:37 am
Reply with quote

Sorry,
My Requirement is that, in the given example, for the Files given, I need the Output to contain only the record
10006 9999 MAD 1111
This Record is present in the Second File, but a corresponding match is not found in the first.
I do not want the record
10001 1235 XYZ 9090
to be displayed in the output, as it is a record which is present in the first file with no match in the second file.
Sorry for any inconvenience. icon_redface.gif
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Wed Feb 27, 2008 8:09 pm
Reply with quote

Hi Prasanya,

Here is the DFSORT/ICETOOL code which meets your requrement:


Code:
//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1  DD *
10000 1234 ABC 9999
10001 1235 XYZ 9090
10002 1236 AXZ 9009
/*
//IN2 DD *
10000 1234 ABC 9999
10002 1236 AXZ 9009
10006 9999 MAD 1111
/* 
//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 SYSOUT=*
//TOOLIN DD *
  COPY FROM(IN1) TO(T1) USING(CTL1)
  COPY FROM(IN2) TO(T1) USING(CTL2)
  SPLICE FROM(T1) TO(T2) ON(1,5,BI) ON(12,3,CH) -
  KEEPBASE KEEPNODUPS WITHALL WITH(1,81) WITH(83,8) USING(CTL3)
  SORT FROM(T2) TO(OUT) USING(CTL4)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'AA',83:8X)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'BB',83:SEQNUM,8,ZD)
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=T2,INCLUDE=(81,2,CH,EQ,C'BB')
/*
//CTL4CNTL DD *
  SORT FIELDS=(83,8,ZD,A)
  OUTREC BUILD=(1,80)
/
*
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 Feb 27, 2008 10:34 pm
Reply with quote

Prasanya,

Here's a simpler way to do what you asked for with DFSORT/ICETOOL:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *
10000 1234 ABC 9999
10001 1235 XYZ 9090
10002 1236 AXZ 9009
/*
//IN2 DD *
10000 1234 ABC 9999
10002 1236 AXZ 9009
10006 9999 MAD 1111
/*
//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)
SELECT FROM(T1) TO(OUT) ON(1,5,BI) ON(12,3,CH) NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'1')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'2')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(81,1,CH,EQ,C'2'),
    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 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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top