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

compare two files and write output file with unmatched recor


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

New User


Joined: 21 May 2005
Posts: 13
Location: Bangalore

PostPosted: Tue May 06, 2008 6:40 pm
Reply with quote

i want a JCL that will compare two files with similar record length and similar fields and create one output file that contains only unmatched records
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 May 06, 2008 9:51 pm
Reply with quote

You need to give more details of what you want to do.

Please show an example of the records in each input file (relevant fields only) and what you expect for output. If input file1 can have duplicates within it, show that in your example. If input file2 can have duplicates within it, show that in your example. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of each input file.
Back to top
View user's profile Send private message
ajithgeorvar

New User


Joined: 01 Apr 2005
Posts: 1

PostPosted: Wed May 07, 2008 9:20 am
Reply with quote

I too was interested in knowing how to use DFSORT and write out unmatched records.
Say there are 2 files File A and File B of which first 10 chars is key data. We need to find the records in File A which arent in File B or vice versa (means unmatched).

Data in File A (80chars long):
1111111111 RECORD1XXXXXXXXXXXXXXXXXXXXXXX
2222222222 RECORD2YYYYYYYYYYYYYYYYYYYYYYYYYY

Data in File B (80chars long):
1111111111 RECORD1AAAAAAAAAAAAAAAAAAAAAAA
3333333333 RECORD2BBBBBBBBBBBBBBBBBBBBBBB


The output file if its Records in A, but not in B need to have:
2222222222 RECORD2YYYYYYYYYYYYYYYYYYYYYYYYYY


Can we do it with DFSORT?
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 May 07, 2008 9:16 pm
Reply with quote

Ajith,

For the example you show, where there are no duplicates within fileA and no duplicates within fileB, you can use a DFSORT/ICETOOL job like this:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1    DD DSN=...  input fileA (FB/80)
//IN2    DD DSN=...  input fileB (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT    DD DSN=...  output file (FB/80)
//TOOLIN  DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(OUT) ON(1,10,CH) NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'A')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'B')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(81,1,CH,EQ,C'A'),
    BUILD=(1,80)
/*


If you do have duplicates within either input file, show a better example of the records in each input file for that situation and what you expect for output.
Back to top
View user's profile Send private message
haohao

New User


Joined: 23 May 2008
Posts: 35
Location: beijing China

PostPosted: Sun May 25, 2008 8:33 am
Reply with quote

that requirement is very similar to mine. in my case the two files might have duplicate key records both. take for example:

file structure: the two input file have the same file structure as below:
01 FILE-RECORD
03 FILE-KEY PIC X(10).
03 FILE-DATE PIC X(50).

file A's content:

1111111111AAAAAAAAAAAAAAAAAA
1111111111BBBBBBBBBBBBBBBBBB
1111111111CCCCCCCCCCCCCCCCCC
2222222222AAAAAAAAAAAAAAAAAA
2222222222BBBBBBBBBBBBBBBBBB
3333333333AAAAAAAAAAAAAAAAAA
4444444444CCCCCCCCCCCCCCCCCC

file B's content:
1111111111DDDDDDDDDDDDDDDDDD
1111111111FFFFFFFFFFFFFFFFFF
4444444444AAAAAAAAAAAAAAAAAA

I want generate two files ,one file contains all records from file A which key are different from file B's key.
another file contains all recoreds from file A and file B which records have the same key in file B.

SO the first output file should as below:
2222222222AAAAAAAAAAAAAAAAAA
2222222222BBBBBBBBBBBBBBBBBB
3333333333AAAAAAAAAAAAAAAAAA

the second output file should as below:
1111111111AAAAAAAAAAAAAAAAAA
1111111111BBBBBBBBBBBBBBBBBB
1111111111CCCCCCCCCCCCCCCCCC
1111111111DDDDDDDDDDDDDDDDDD
1111111111FFFFFFFFFFFFFFFFFF
4444444444AAAAAAAAAAAAAAAAAA
4444444444CCCCCCCCCCCCCCCCCC

I hope I made my requirement clear. how can it be done by DFSORT? thanks a lot for your help!!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue May 27, 2008 10:28 pm
Reply with quote

haohao,

The following DFSORT/ICETOOL JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL                                     
//TOOLMSG  DD SYSOUT=*                                           
//DFSMSG   DD SYSOUT=*                                           
//IN1      DD *                                                 
1111111111DDDDDDDDDDDDDDDDDD                                     
1111111111FFFFFFFFFFFFFFFFFF                                     
4444444444AAAAAAAAAAAAAAAAAA                                     
//IN2      DD *                                                 
1111111111AAAAAAAAAAAAAAAAAA                                     
1111111111BBBBBBBBBBBBBBBBBB                                     
1111111111CCCCCCCCCCCCCCCCCC                                     
2222222222AAAAAAAAAAAAAAAAAA                                     
2222222222BBBBBBBBBBBBBBBBBB                                     
3333333333AAAAAAAAAAAAAAAAAA                                     
4444444444CCCCCCCCCCCCCCCCCC                                     
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)   
//OUT1     DD SYSOUT=*                                           
//OUT2     DD SYSOUT=*                                           
//TOOLIN   DD *                                                 
  COPY FROM(IN1) USING(CTL1)                                     
  COPY FROM(IN2) USING(CTL2)                                     
  SPLICE FROM(T1) TO(OUT1) ON(01,10,CH) -                       
  WITHALL WITH(01,60) USING(CTL3) KEEPNODUPS KEEPBASE           
//CTL1CNTL DD *                                                 
  OUTFIL FNAMES=T1,BUILD=(1,60,1,10)                             
//CTL2CNTL DD *                                                 
  OUTFIL FNAMES=T1,BUILD=(1,60,10X)                             
//CTL3CNTL DD *                                                 
  OUTFIL FNAMES=OUT1,BUILD=(01,60),INCLUDE=(61,10,CH,EQ,1,10,CH)
  OUTFIL FNAMES=OUT2,SAVE                                       
/*


Hope this helps..
Back to top
View user's profile Send private message
haohao

New User


Joined: 23 May 2008
Posts: 35
Location: beijing China

PostPosted: Wed May 28, 2008 12:43 pm
Reply with quote

hi,San Jose:
That's great! I have tested it, It's well done, thank you very much!
Back to top
View user's profile Send private message
Vishwamurthy

New User


Joined: 11 Mar 2008
Posts: 57
Location: India

PostPosted: Fri May 20, 2011 5:44 pm
Reply with quote

So how do we do it for getting only matched records out?
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 May 20, 2011 11:11 pm
Reply with quote

That thread was from 2008. Today, we would probably use DFSORT's JOINKEYS function for this. For details on how to do various matching operations with JOINKEYS, see the "Create files with matching and non-matching records" Smart DFSORT Trick at:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000094

If you need more specific, help show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example.

Also, run this job and show the //SYSOUT messages you receive, so we can see what level you're at:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
RECORD
//SORTOUT DD DUMMY
//SYSIN    DD    *
    OPTION COPY
/*
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 6
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
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top