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

Comparing 2 headers on files


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

New User


Joined: 02 Aug 2007
Posts: 83
Location: Here

PostPosted: Tue Apr 24, 2012 12:11 pm
Reply with quote

My requirement is as follows. I have 2 files which has a header. the header of these 2 files contain the timestamp. I need to compare the timestamps on the header of these 2 files. if the timestamps match the job should not be processed. If the timestamps do not match the job should be processed.


File A
XXXXX DD-MM-YY-HH:MM:SS:USSSS
----
----


File B
XXXXX DD-MM-YY-HH:MM:SS:USSSS


Can we do this through a sort step? Can someone guide me on this.


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: Tue Apr 24, 2012 12:14 pm
Reply with quote

What are XXXXX, would they be the same on each file?
Back to top
View user's profile Send private message
CJT

New User


Joined: 02 Aug 2007
Posts: 83
Location: Here

PostPosted: Tue Apr 24, 2012 12:27 pm
Reply with quote

Yes its the same string but i would like to compare only the timestamps.
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: Tue Apr 24, 2012 1:14 pm
Reply with quote

This could get you started.

CHKOUT is a DD DUMMY which is used to give a RC of 4 if no data is written to the file (timestamps match). If timestamps do not match, two records are written, but you don't need to see them/use them, so the DUMMY.

If the timestamps do not match, they will also be written to SORTOUT so you can see them. This can be changed, or they can be shown in a more friendly way, and you can have them even when they do match, so you know what matched, if you want.

Code:
//STEP0100 EXEC PGM=SORT
//CHKOUT DD DUMMY
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  JOINKEYS F1=INA,FIELDS=(7,26,A),SORTED,NOSEQCK
  JOINKEYS F2=INB,FIELDS=(7,26,A),SORTED,NOSEQCK
  JOIN UNPAIRED,F1,F2,ONLY
  REFORMAT FIELDS=(F1:1,32,?,F2:1,32)
  OUTFIL FNAMES=CHKOUT,NULLOFL=RC4
//JNF1CNTL DD *
 OPTION COPY,STOPAFT=1
//JNF2CNTL DD *
 OPTION COPY,STOPAFT=1
//INA      DD *
XXXXX DD-MM-YY-HH:MM:SS:USSSS
2222
3333
4444
5555
6666
7777
//INB      DD *
XXXXX TD-MM-YY-HH:MM:SS:USSSS
2222
3333
4444
5555
6666
7777
Back to top
View user's profile Send private message
CJT

New User


Joined: 02 Aug 2007
Posts: 83
Location: Here

PostPosted: Wed May 09, 2012 1:50 pm
Reply with quote

Thanks Bill, your solution was a starting point.
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Thu May 10, 2012 11:16 pm
Reply with quote

CJT wrote:
My requirement is as follows. I have 2 files which has a header. the header of these 2 files contain the timestamp. I need to compare the timestamps on the header of these 2 files. if the timestamps match the job should not be processed. If the timestamps do not match the job should be processed.


I suggest to use SuperCompare instead of DFSORT. Below is sample jcl that will compare just the first line:
Code:
//* COMPARE FIRST RECORD OF TWO FILES         
//* RC=0 MEANS THEY ARE THE SAME               
//* RC=1 MEANS THEY ARE DIFFERENT             
//SUPERC  EXEC PGM=ISRSUPC,                   
//        PARM='DELTAL,LINECMP,DLREFM NOPRTCC'
//NEWDD  DD DSN=?,
//          DISP=SHR                           
//OLDDD  DD DSN=?,
//          DISP=SHR                           
//OUTDD  DD SYSOUT=(*)                         
//SYSIN  DD *                                 
 CMPCOLM 51:61
 CMPLINE BTM 1                                 
/*                                             

Then check the return code on the next step.
The CMPLINE restricts it to the first line only. The CMPCOLM is optional. It will compare specified columns only.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
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 Grouping by multiple headers DFSORT/ICETOOL 7
Search our Forums:

Back to Top