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
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
Arun Raj

Moderator


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

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

tecnokrat,

Did you pay attention to the questions raised by Gerry? You have just stated what you need, but it does not look like you are doing the same in your posted code.
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