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

Comparison of two files


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Wed Jun 19, 2013 5:27 am
Reply with quote

I have a requirement where in two files have to be compared and if both the files are byte byte same then SET a RC code = 8.and if not then the third file is generated.

I have tried using the SORT and ICETOOL but when compared the the MAXCC is always set to ZERO.

Should there be a condition COND=(0,LT, SEt RC=8)
can you please help me on this to how can i be able to check the condition.
Is that the Third file be checked for the blanks and then set a MAXCC = 8. Please help me on this.
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: Wed Jun 19, 2013 6:03 am
Reply with quote

Hello,

Quote:
I have tried using the SORT and ICETOOL but when compared the the MAXCC is always set to ZERO.
Show what you have tried and what happened.

Quote:
Should there be a condition COND=(0,LT, SEt RC=8)
No - as there is no such syntax.

When is this "3rd" file created? The explanaton given is not clear.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jun 19, 2013 10:14 am
Reply with quote

Also let us know your sort product
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Fri Jun 21, 2013 3:41 am
Reply with quote

This is my step where the comparision is done

Code:

//STEP1   EXEC PGM=ICETOOL,COND=(4,LT)                       
//TOOLMSG DD SYSOUT=*                                       
//DFSMSG  DD SYSOUT=*                                       
//IN1     DD DISP=SHR,DSN=<File1>
//IN2     DD DISP=SHR,DSN=<File2>
//T1      DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5)),         
//           DISP=(MOD,PASS)                                 
//OUT12   DD DISP=SHR,DSN=<file3>
//OUT1    DD *                                               
//OUT2    DD *                                               
//TOOLIN  DD *                                               
  COPY FROM(IN1) TO(T1) USING(CTL1)                         
  COPY FROM(IN2) TO(T1) USING(CTL2)                         
  SPLICE FROM(T1) TO(OUT12) ON(1,250,CH) WITH(251,1) -       
  USING(CTL3) KEEPNODUPS                                     
/*                                                           
//CTL1CNTL DD *                                             
//CTL2CNTL DD *                                             
//CTL3CNTL DD *                                             
  OUTFIL FNAMES=OUT12,BUILD=(1,250)                         
/*


File 1 ---
Code:
Header06022013
11111
12222
23333
12224
Trailer

File2-------
Code:
Header06012013
11111
12222
23333
11112
Trailer
File 2 is the older file and file 1 is the new file so when im comparing both files i should get the o/p in file3 as only

File3----
Code:
12224
and for scenario 2:
File 1 ---
Code:
Header06022013
11111
12222
23333
12224
Trailer


File2-------
Code:
Header06022013
11111
12222
23333
12224
Trailer

when file 1 and file 2 are both same the job should abend with RC-8 i need to specify the cond explicity to abend when both files are same please help me with the syntax.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Jun 21, 2013 4:01 am
Reply with quote

run the following job and show us the complete sysout which will help us determine the level of DFSORT

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DUMMY
//SYSIN   DD   *
  OPTION COPY
/*
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Fri Jun 21, 2013 4:20 am
Reply with quote

Hi Kolusu,
I have run the Job and below are the parameters
Code:

SYSIN :                                                                       
  OPTION COPY                                                           0009130
WER276B  SYSDIAG= 285342, 1631991, 1631991, 3521025                           
WER164B  7,408K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,             
WER164B     0 BYTES RESERVE REQUESTED, 2,288K BYTES USED                       
WER146B  20K BYTES OF EMERGENCY SPACE ALLOCATED                               
WER108I  SORTIN   : RECFM=FB   ; LRECL=   250; BLKSIZE= 27750                 
WER073I  SORTIN   : DSNAME=<File1>
WER110I  SORTOUT  : RECFM=FB   ; LRECL=   250; BLKSIZE= 27750                 
WER074I  SORTOUT  : DSNAME=NULLFILE                                           
WER410B  5,868K BYTES OF VIRTUAL STORAGE AVAILABLE ABOVE THE 16MEG LINE,       
WER410B     0 BYTES RESERVE REQUESTED, 2,164K BYTES USED                       
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                                 
WER416B  SORTIN   : EXCP'S=1,UNIT=3390,DEV=D0DB,CHP=(01050D12161F22,1),VOL=FPM0
WER416B  BSAM WAS USED FOR SORTOUT                                             
WER054I  RCD IN         34, OUT         34                                     


I need when both same files are compared the job should abend else it should run fine. currently even if both the files are same the job is running with MAXCC=0 but i need to modulate to run with maxcc=8 when both files compared are same.
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: Fri Jun 21, 2013 4:59 am
Reply with quote

Well, you have SyncSort, not DFSORT.

Can you include the bit from the sysout which tells us which version of SyncSort you have?

You're going to be better with JOINKEYS instead of SPLICE.

If you use OUTFIL OMIT for the F1 part of the REFORMAT equal to the F2 then if the files are identical, you'll have no output records. There is an option to set a return-code for no output from OUTFIL. Set your SORTOUT to DD DUMMY, as all you are interested in is the RC.
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Fri Jun 21, 2013 5:48 am
Reply with quote

Hi Bill,
As you suggested i had the approach with the JOINKEYS

Here is what I have done
Code:

//STEP1    EXEC PGM=SORT,COND=(4,LT)   
//SYSPRINT DD  SYSOUT=*                                       
//SYSLIST  DD  SYSOUT=*                                       
//SYSOUT   DD  SYSOUT=*                                       
//SYSUDUMP DD  SYSOUT=*                                       
//SORTJNF1 DD DISP=SHR,DSN=File1
//SORTJNF2 DD DISP=SHR,DSN=File2
//SORTOUT  DD DSN=File3,
//            DISP=SHR                                       
//SYSIN    DD *
   SORT FIELDS=COPY                                           
     JOINKEYS FILE=F1,FIELDS=(1,250,CH,A)                     
     JOINKEYS FILE=F2,FIELDS=(1,250,CH,A)                     
     JOIN UNPAIRED F1 ONLY                                   
     REFORMAT FIELDS=(F1:1,250,F2:1,250)                     
   OMIT COND=((1,6,CH,EQ,C'HEADER'),OR,(1,7,CH,EQ,C'TRAILER'),OR, 
              (1,250,CH,EQ,C' '))                             
/*


When i Used thabove JOINKEYS the F3 File is always filled with values.

Say in scenario Where Files F1 is compared to F1 then still in the O/P I get the records of F1.

Instead my scenario here is :
1. When Two identical files F1 and F2 are compared then the MAXCC should be set = 8.
2. When F1 and F2 different then The records in F1 which are not in F2 are to be copied to F3.

But the above JOINKEYS are not serving my purpose.
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: Fri Jun 21, 2013 6:54 am
Reply with quote

Hello,

Is there some reason you have not run the jcl provided above? It will provide this answer:
Quote:
Can you include the bit from the sysout which tells us which version of SyncSort you have?


Or, you could post the top part of the info you did post from a run.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jun 21, 2013 9:37 am
Reply with quote

Also what are you trying to do with the header and trailer records in the JOIN OMIT COND shown above. Your explanation of the requirement seems to be incomplete.
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: Fri Jun 21, 2013 11:40 am
Reply with quote

Try this instead. Then work when you get no output on SORTOUT, work out the correct way to get a non-zero RC.

Code:
    JOINKEYS FILE=F1,FIELDS=(1,250,CH,A)                     
    JOINKEYS FILE=F2,FIELDS=(1,250,CH,A)                     
 
    JOIN UNPAIRED                               

    REFORMAT FIELDS=(F1:1,250,F2:1,250)                     

    SORT FIELDS=COPY                                           
    OMIT COND=(1,250,CH,EQ,251,250,CH)
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Jun 21, 2013 12:24 pm
Reply with quote

Hi,

I'm not sure you can get SYNCSORT to set a rc of 8,

you can try replacing
Code:
    OMIT COND=(1,250,CH,EQ,251,250,CH)

with
Code:
   OUTFIL FNAMES=OUT,OMIT=(1,250,CH,EQ,251,250,CH),NULLOFL=RC4 


This will result in a rc of 4.

You will need to replace SORTOUT with OUT DD


Gerry
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: Fri Jun 21, 2013 12:37 pm
Reply with quote

NULLOUT is for SORTOUT. NULLOFL is for OUTFIL files.

1.4.something apparently has RC setting for when there is data on a file.

Yes, you can't get 8 directly. But it's the requirement...
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jun 21, 2013 12:54 pm
Reply with quote

Hi Bill,

The TS needs the unpaired F1 records as well in the output, in addition to the RC .
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: Fri Jun 21, 2013 1:15 pm
Reply with quote

Hi Arun,

The "third file" is still a total mystery to me :-)

With the latest set of cards, if the files are the same byte-for-byte, there will be no data on SORTOUT. If not, all the unmatched F1 and F2 will be on SORTOUT.

There does seem to be a mention of a third file, but nothing clear as to what should be on it. If it is the unpaired F1s, then yes, the INCLUDE/OMIT has to go back to OUTFIL and another OUTFIL would be needed for the required data, which would be 251,250,CH,NE,C' '
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jun 21, 2013 3:54 pm
Reply with quote

Bill Woodger wrote:
Hi Arun,

The "third file" is still a total mystery to me :-)
Hi Bill,

The one person who can uncover the mystery does nt seem to be interested in the discussion. icon_smile.gif
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Sat Jun 22, 2013 12:08 am
Reply with quote

Hi Bill,
I have worked with the below condition and I got the desired result of the Records in F1 and not in F2 are copied to F3

Code:
JOINKEYS FILE=F1,FIELDS=(1,250,CH,A)                         
JOINKEYS FILE=F2,FIELDS=(1,250,CH,A)                         
                                                             
JOIN UNPAIRED                                               
REFORMAT FIELDS=(F1:1,250,F2:1,250)                         
SORT FIELDS=COPY                                             
OMIT COND=((1,250,CH,EQ,251,250,CH),OR,(251,250,CH,NE,C' '))


The other question is how to put a condition when both files are equal to get a RC set to MAXCC=8

I tried this but its falls on the SUPERC
Code:
//SUPERC  EXEC PGM=ISRSUPC,                   
//             PARM=(DELTAL,LINECMP,           
//             'LONGLN',                       
//             '')                             
//NEWDD  DD DSN=File1,
//          DISP=SHR                           
//OLDDD  DD DSN=File2,
//          DISP=SHR                           
//OUTDD  DD SYSOUT=(*)                         
//SYSIN  DD *                                 
  CMPCOLM 1:250                               
/*                                 
// IF SUPERC.RC = 0 THEN                                       
//*****************************   
//* SETTING RETURN CODE TO 8                                   
//*****************************   
//STEPIF  EXEC PGM=IDCAMS                                     
//SYSIN  DD *                                                 
  SET MAXCC=8                                                 
/*                                                             
//SYSPRINT DD SYSOUT=*                                         
//  ENDIF                                                     
//*                                         
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: Sat Jun 22, 2013 12:29 am
Reply with quote

SyncSort can give you 0, 4 or 16 for an "empty" file, either for SORTOUT (NULLOUT) or OUTFIL (NULLOFL).

If you have an up-to-date SyncSort, information which you still haven't supplied to us, you can set the same range for a file which contains data.

If you have the up-to-date SyncSort, you will be able to do it in one step - but your non-Zero RC can only be either 4 or 16. If you are "desperate" for an 8, you could do the IDCAMS on the 4 from the SORT, which then sets 8.

Without the up-to-date version, I think you'd have a problem where there are unmatched records on F2 and no records on F1. Your byte-for-byte match should obviously fail, but you'd get the NULLOFL for the unmatched F1 output, which would give the the "wrong" RC for the step.

Yes, if you're going to ignore questions and suggestions, you can make your topic wander off into other avenues: just bear in mind that people will be less likely to reply given the way things have gone so far on this one.
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Sat Jun 22, 2013 6:23 am
Reply with quote

bill my syncsort is
Code:
SYNCSORT FOR Z/OS  1.4.0.1R
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: Sat Jun 22, 2013 7:07 am
Reply with quote

OK, you may be in luck. Check your documentation for NOTMTOFL.

This will allow you to set the RC (not to 8) if the specified OUTFIL contains data.

You have your byte-for-byte match. To get a full match, you have no unpaired records.

If you have differences, you have:

Differences are "new" records, only on F1. These interest you.

Difference are "old" records, only on F2. These (apparently) don't interest you.

Changed records, where there will be an F1 and an F2. You are only interested in the F1s.

The INCLUDE/OMIT you have already been shown will get you an empty output if the two files match completely, byte-for-byte, record-for-record.

You have two remaining situations. Records solely unmatched from F2 (so F1 output is empty). And unmatched records from F1 which you want to process (whether or not there are F2 records).

The F1 records are where 251,250,CH,EQ,C' '

To do this all in one step, you have three "states" I think you need to cover, and you have three different RC values (0, 4 or 16) with the added "complication" that 16 is produced when there is a problem with the control cards.

Personally, I'd probably go for 0 telling me there are unmatched F1 records for processing and 04 telling me there is not an output file for processing, but which a further step would have to be used to distinguish between the "matched entirely" state, and the "unmatched, but only unmatched on F2" - if you need to differentiate.

If you really have to set 8, use the IDCAMS to set to 8 when spotting a 4.

You now have all the bits you need to put the thing together. We're not aware of exactly the combinations you need, but you are, and we've covered them what you may need, and more. There are variations in how to do it, what codes to set. You have the option to certainly identify an empty OUTFIL with non-zero RC, and probably a data-containing OUTFIL with non-zero RC.

You should be able to sit back, go through everything, and work out what it is that you exactly need.

If you can't get it to work, show what you've tried and include and exact description of what you want, covering all situations. Someone may then put together the bits from what you've already been shown.

If you do get it by yourself, post it here, as it may well help someone else in the future.

You've got everything you need. You can do everything in SORT. You can know from one step whether you have a file which needs processing. For convenience (due to the prior use of RC16) you can differentiate the two no-output-to-process situations (if you need to) in a separate step, and probably by reading/attempting to read only one record (STOPAFT).

We've spent time on it, now it's your turn. Don't come back in five minutes just wanting it off pat, please.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sun Jun 23, 2013 6:08 pm
Reply with quote

I read this thread several times, and I have been thinking why would we need a JOIN UNPAIRED when we are not at all interested in UNPAIRED records from F2 where a JOIN UNPAIRED,F1,ONLY would suffice the requirement. And the TS himself has posted the below "JOIN UNPAIRED F1 ONLY" solution in the Page1 of this thread and had complained saying he gets records in output even if both the input files are same.
Code:
//SYSIN    DD *
  SORT FIELDS=COPY                                           
  JOINKEYS FILE=F1,FIELDS=(1,250,CH,A)                     
  JOINKEYS FILE=F2,FIELDS=(1,250,CH,A)                     
  JOIN UNPAIRED F1 ONLY                                   
  REFORMAT FIELDS=(F1:1,250,F2:1,250)                     
  OMIT COND=((1,6,CH,EQ,C'HEADER'),OR,(1,7,CH,EQ,C'TRAILER'),OR, 
              (1,250,CH,EQ,C' '))                             
/*
In the above card, comma is missed after UNPAIRED and after F1, and hence the portion after UNPAIRED was treated as comments. JOIN UNPAIRED has a totally different meaning - it tells sort to extract all the records - matched records + unmatched records from file1 + unmatched records from file2.
Again an UNPAIRED,F1,ONLY does not need a REFORMAT statement since the output record is generated by fields from a single file.ie., F1.
I would have preferred something like this.
Code:
//SYSIN    DD *
  SORT FIELDS=COPY                                           
  JOINKEYS FILE=F1,FIELDS=(1,250,CH,A)                     
  JOINKEYS FILE=F2,FIELDS=(1,250,CH,A)                     
  JOIN UNPAIRED,F1,ONLY                                   
  OPTION COPY,NULLOUT=RC4                               
  OMIT COND=(1,6,CH,EQ,C'HEADER',OR,1,7,CH,EQ,C'TRAILER')
This will give
RC0 - unpaired data records from file1 alone in output
RC4 - empty output since both the files are matching byte-by-byte
RC4 - empty output since file1 is empty
RC4 - empty output since both file1 and file2 are empty
RC4 - empty output since all data records are matching, but header or trailer records do not match

If the TS is particular about RC4 only when file1 is not empty, he could have it checked beforehand and skip this comparison step itself.
However the header or trailer mismatch alone could lead to RC4. He could very well analyse on the possibility of occurrence of each scenario and take an appropriate decision.
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: Sun Jun 23, 2013 7:13 pm
Reply with quote

I see now that there is some reference to header/trailer in the SPLICE post. Which I ignored thinking "why use SPLICE"?

If there are dates which are not to be treated as equal, just splat them in JNFnCNTL...

Ah, SyncSort. Perhaps they've not gone to the bother of asking for the JNFnCNTL "patch".

A different date on the header/trailer is going to "throw out" the byte-for-byte if it can't be blatted before the JOIN.

That aside, here' my F1

Code:
A

Here's my F2

Code:
A
B


My byte-for-byte has to be "false", but I've got exactly the same "nothing" on my output that I have for when my byte-for-byte is "true".

TS hasn't been specific about whether that matters.

In short, to add to your list,

RC4, byte-for-byte-mismatch, but unpaired F1.
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Wed Jun 26, 2013 11:59 am
Reply with quote

Thanks Arun and Bill , the desired output is found with your sort CArd

1. The Sort card has included as per

Code:
//SYSIN    DD *
  SORT FIELDS=COPY                                           
  JOINKEYS FILE=F1,FIELDS=(1,250,CH,A)                     
  JOINKEYS FILE=F2,FIELDS=(1,250,CH,A)                     
  JOIN UNPAIRED,F1,ONLY                                   
  OPTION COPY,NULLOUT=RC4                               
  OMIT COND=(1,6,CH,EQ,C'HEADER',OR,1,7,CH,EQ,C'TRAILER')


For the STEP4 to run i'm checking for the SORT step to be COND=(4,LT,STEP3)

Code:

// IF STEP3.RC = 4 THEN                                         
//*****************************                                 
//* SETTING RETURN CODE TO 8                                   
//*****************************                                 
//STEPIF  EXEC PGM=IDCAMS                                       
//SYSIN  DD *                                                   
  SET MAXCC=8                                                   
/*                                                             
//SYSPRINT DD SYSOUT=*                                         
// ENDIF                                                       
//**************************************************************
//*STEP TO run STEP4 based on STEP3                         
//**************************************************************
//STEP4    EXEC PGM=IKJEFT01,DYNAMNBR=20,COND=(4,LT,STEP3)     
//SYSTSPRT DD   SYSOUT=*                                       
//SYSPRINT DD   SYSOUT=*                                       
//SYSOUT   DD   SYSOUT=*                                       
//SYSOUX   DD   SYSOUT=*                                       
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Jun 26, 2013 12:49 pm
Reply with quote

Hi,

STEP4 will run when STEP3 returns a 0 or 4 RC with COND=(4,LT,STEP3)

Why set a return code of 8 in a step if you are not going to reference it ?

Gerry
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Wed Jun 26, 2013 1:03 pm
Reply with quote

Gerry

I need the skip the step 4 if both the files compared are same in step3
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 -> JCL & VSAM Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top