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
 

 

compare two files and write output file with unmatched recor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: compare two files and write output file with unmatched recor
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 Moderator


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

PostPosted: Tue May 06, 2008 9:51 pm    Post subject:
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    Post subject: Reply to: compare two files and write output file with unmat
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 Moderator


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

PostPosted: Wed May 07, 2008 9:16 pm    Post subject:
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    Post subject: Reply to: compare two files and write output file with unmat
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    Post subject:
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    Post subject: Reply to: compare two files and write output file with unmat
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    Post subject:
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 Moderator


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

PostPosted: Fri May 20, 2011 11:11 pm    Post subject:
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:

http://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    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 SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 4 Tue Jan 17, 2017 4:26 pm
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts Incorrect output when trying to add n... monica1 PL/I & Assembler 10 Fri Jan 13, 2017 5:02 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm


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