View previous topic :: View next topic
|
Author |
Message |
CJT
New User
Joined: 02 Aug 2007 Posts: 83 Location: Here
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
What are XXXXX, would they be the same on each file? |
|
Back to top |
|
|
CJT
New User
Joined: 02 Aug 2007 Posts: 83 Location: Here
|
|
|
|
Yes its the same string but i would like to compare only the timestamps. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
CJT
New User
Joined: 02 Aug 2007 Posts: 83 Location: Here
|
|
|
|
Thanks Bill, your solution was a starting point. |
|
Back to top |
|
|
jerryte
Active User
Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
|
|
|
|
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 |
|
|
|