Page 1 of 1

JCL to compare date within a file to yesterdays date

PostPosted: Fri Aug 08, 2014 12:33 am
by MANISH_124
I require a JCL that will compare date in a file which is in 1st record ie. 1st row of the file to the yesterdays date ie.current date-1 day and if it matches then it should perform a step in which it executes some othe jcl while if it doesn't match then it will execute the other jcl.

Re: JCL to compare date within a file to yesterdays date

PostPosted: Fri Aug 08, 2014 2:13 pm
by NicC
You are out of luck - JCL does not compare dates or anything else. It simply tells the operating system what program(s) to run and what resources are required.
Having said that, and the fact that you posted in the DFSort part of the forum, perhaps you after some Sort Control Cards to compare the dates and set a return code appropriately so that subsequent steps of your job either execute or do not execute. The first part I cannot help you with but the second part is simply coding conditions (COND=) on the steps after the sort. r using the JCL IF/THEN/ELSE construct for conditional execution which can be looked up in the JCL Language Reference manual - links via IBM Manuals at the top and bottom of each page in the forum.

Re: JCL to compare date within a file to yesterdays date

PostPosted: Fri Aug 08, 2014 6:28 pm
by Magesh23586
What is the date format... Here is the sample code for you, It will return RC4 when it is mismatch, accordingly you need to use COND= in your JCL Step.
assuming your date format is YYYY-MM-DD and its starts from position 2.

//S1 EXEC PGM=ICETOOL                     
//TOOLMSG DD SYSOUT=*                     
//DFSMSG DD SYSOUT=*                     
//IN DD *                                 
H2014-08-07                               
D RECORD 01                               
D RECORD 02                               
D RECORD 03                               
//TOOLIN DD *                             
 COUNT FROM(IN) RC4 EMPTY USING(CTL1)     
//CTL1CNTL DD *                           
 OPTION STOPAFT=1                         
 INCLUDE COND=(2,10,CH,EQ,DATE1(-)-1)     
/*                                       


Hope this helps..

Regards
Magesh

Re: JCL to compare date within a file to yesterdays date

PostPosted: Fri Aug 08, 2014 7:23 pm
by BillyBoyo
Plain SORT, STOPAFT=1 OUTFIL INCLUDE=, with OPTION NULLOUT or with NULLOFL on the OUTFIL.

Problem with the STOPAFT=1 and the INCLUDE COND is that in the case of a mismatched date, the entire input will be read, and there is a possibility of a false hit. Should also confirm with TS/OP whether there is anything to uniquely identify the first record (other than it being first).

You don't need *TOOL to get a non-zero RC.