comparing 2 files and writing out unmatched data



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

comparing 2 files and writing out unmatched data

Postby mrsmparkin » Tue Nov 01, 2016 6:19 pm

hi,

i have 2 files both the same format and length (1000 bytes)

File A was created yesterday
File B is created today. I want to compare the entire file content (all 1000 bytes) and if there is any change in the values to write the record lines to an output file. This file may also contain new record lines that don't exist in File A - these lines must also be written to the output file. The output file will contain all 1000 bytes from File B if a difference is found.
so basically i only want to identify a change in data between days and identify new entrants - and then create a file with this data only in the same format (1000 bytes)

I have researched on this forum and can see examples where i should use the following syntax:
//SYSIN DD *
JOIN KEYS = 01,FIELDS=(1,1000,CH)
JOIN KEYS = 02,FIELDS=(1,1000,CH)
REFORMAT FIELDS = (F1:1,1000,F2:1,1000)
SORT FIELDS = COPY
JOIN UNPAIRED,F1,F2


but i don't understand how JOIN UNPAIRED works or what the syntax is to create the output file.
Can you also confirm if the above syntax is correct as there was some disagreement in the forum.

Thanks
Michelle

Code'd
mrsmparkin
 
Posts: 2
Joined: Tue Nov 01, 2016 6:09 pm
Has thanked: 0 time
Been thanked: 0 time

Re: comparing 2 files and writing out unmatched data

 

Re: comparing 2 files and writing out unmatched data

Postby BillyBoyo » Tue Nov 01, 2016 9:07 pm

Starting with the output file, if you have a SORTOUT DD in your JCL that will be written to. You can specify additional output files with one or more OUTFIL statements.

UNPAIRED,F1,F2 gets you three possible states of the: it gets you matched records, because you get those unless you are explicit; it gets unmatched records from F1, and unmatched records from F2.

You can include, in the REFORMAT statement, an indicator which reveals the state: B (on both); 1 (of F1, not on F2); 2, (on F2 not on F1). This is the match-marker, which is represented in the REFORMAT statement by a question-mark (?) and which position contains the indicator when the REFORMAT record is built for you.

You need some work on the JOINKEYS statement itself.

You need to consider whether you want your data sorted before the matching. If you don't, tell the JOINKEYS not to, because by default it sorts. But. You then need something to be in order to do the match on.

Have a look at the DFSORT Getting Started Guide and the DFSORT Application Programming Guide. Decide whether you need to SORT the data in the JOINKEYS (if you do, you may miss things in the wrong place) and if you don't want it sorted, you want to match in situ, then there's some more that is needed.

If you have questions from your research, or need to get it beyond almost working, of course post again.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: comparing 2 files and writing out unmatched data

Postby mrsmparkin » Wed Nov 02, 2016 12:41 pm

thank you.
i would be joining the keys on a common key in the file, position 1 for 16 bytes, so i'll change that. I'll look for the guides you have suggested.
mrsmparkin
 
Posts: 2
Joined: Tue Nov 01, 2016 6:09 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post