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

Compare and write non-matching records to output file


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

Active User


Joined: 23 Dec 2005
Posts: 176
Location: India

PostPosted: Thu May 02, 2013 7:48 pm
Reply with quote

Hi,

I want to compare 2 files and write the records those are in file 1 but not in file to a output file.

Could someone help with a code snippet please?

Thanks,
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu May 02, 2013 7:55 pm
Reply with quote

Google SUM FIELDS=NONE

Garry
Back to top
View user's profile Send private message
monasu1998

Active User


Joined: 23 Dec 2005
Posts: 176
Location: India

PostPosted: Thu May 02, 2013 7:59 pm
Reply with quote

Hi Garry,
SUM FIELDS=NONE will only remove the duplicates I mean the 2nd occurances.. I donot want the record in output if exists in both the files.

Thanks,
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu May 02, 2013 8:06 pm
Reply with quote

search the forum,
there are gazillions of examples doing it using JOINKEYS
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu May 02, 2013 8:08 pm
Reply with quote

Are the 2nd occurrences not duplicates???

You might want to use JOINKEYS which enables you to select records which are only in File1, only in File2 or are in both.


Garry.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 8:17 pm
Reply with quote

Largely butchered from an example today. You'll need to change your keys, and explain better if this is not what you want. If your input(s) are not sortted, you'll need to remove the SORTED,NOSEQCK.

Code:
  JOINKEYS FILE=F1,FIELDS=(1,3,A),SORTED,NOSEQCK
  JOINKEYS FILE=F2,FIELDS=(1,3,A),SORTED,NOSEQCK
  JOIN UNPAIRED,F1,ONLY
  OPTION   COPY


The output will be on SORTOUT.
Back to top
View user's profile Send private message
monasu1998

Active User


Joined: 23 Dec 2005
Posts: 176
Location: India

PostPosted: Thu May 02, 2013 8:21 pm
Reply with quote

Hi Garry,

I am glad that you are trying to help me with a solution. But I donot want any of those occurances. I just need that is in 1 and not in 2.

background: I am doing some testing where in in my test run there should be few records less from the requirements from business. Now Business wants me to send a file with just what has been removed.
I am comparing the prod vs test file.

Note: Both the files are sorted with same key.

Thanks,
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu May 02, 2013 8:24 pm
Reply with quote

Mishra,

Bill's job suitable changed for the FIELDS= values should do what you want. You will want FIELDS=(1,lrecl,A) where lrecl matches the LRECL of your records.

Garry.
Back to top
View user's profile Send private message
monasu1998

Active User


Joined: 23 Dec 2005
Posts: 176
Location: India

PostPosted: Thu May 02, 2013 8:38 pm
Reply with quote

Hi Garry,

I'm close to the result.

I used
JOINKEYS FILES=F1,FIELDS=(1,66,A)
JOINKEYS FILES=F2,FIELDS=(1,66,A)
JOIN UNPAIRED,ONLY,F1
OPTION COPY

what I see in the sortout is the records those are common in both the files. But not the ones which are removed in my test file.

Just need to reverse the sort card so that the diff comes in sortout..

Thanks,
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 8:45 pm
Reply with quote

Did you typo F1,ONLY to ONLY,F1?

The example show should give you all records which are on file 1, but not on file 2, based on the key you provided.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu May 02, 2013 8:54 pm
Reply with quote

Hi Mishra,

check this link for a better understanding.
Back to top
View user's profile Send private message
monasu1998

Active User


Joined: 23 Dec 2005
Posts: 176
Location: India

PostPosted: Thu May 02, 2013 8:57 pm
Reply with quote

Hi Bill,

yes, that was a typo. But changing that is not giving me correct result..

SORTJNF1 is the prod file with records 651911
SORTJNF2 is the test file with records 650933

I want the 978 records which are in prod and not in test in the sortout file.

With the current following sort card,

JOINKEYS FILES=F1,FIELDS=(1,66,A)
JOINKEYS FILES=F2,FIELDS=(1,66,A)
JOIN UNPAIRED,F1,ONLY
OPTION COPY

all the reocrds from the prod file is written to sortout. which is not I want..

Thanks,
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 9:12 pm
Reply with quote

Well, show some sample data (masked, if necessary) the key field should be enough. RECFM and LRECL of both input files.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu May 02, 2013 11:31 pm
Reply with quote

Hello,

Show some sample values from both files. If a file can have duplicates, show some duplicates in your sample data.

Show the output you want from the sample data you post.

Only the "match" keys need to be shown - not the rest of the data, unless it is needed for the selection.
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 3
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