JCL to compare date within a file to yesterdays date



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

JCL to compare date within a file to yesterdays date

Postby MANISH_124 » Fri Aug 08, 2014 12:33 am

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.
MANISH_124
 
Posts: 1
Joined: Fri Aug 08, 2014 12:20 am
Has thanked: 0 time
Been thanked: 0 time

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

Postby NicC » Fri Aug 08, 2014 2:13 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

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

Postby Magesh23586 » Fri Aug 08, 2014 6:28 pm

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
Magesh23586
 
Posts: 36
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

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

Postby BillyBoyo » Fri Aug 08, 2014 7:23 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post