Joined: 17 Aug 2003 Posts: 51 Topics: 26 Location: Chennai
Posted: Wed Oct 18, 2006 11:13 am Post subject: Current Date in a PS thru JCL
Hi,
I have to create a PS in a JOB with the Current date value in it. Is it possible using JCL funtions? I don't want a write a program to get this function. I believe there should be a simpler way. Even a way thru SORT card is fine with me. Please let me know. Thank you.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Wed Oct 18, 2006 11:51 am Post subject:
If you just want one record with the date in C'yyyymmdd' format, you can use this DFSORT job:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD DSN=... output record with date
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=(DATENS=(4MD))
/*
If you want something else, you need to describe exactly what it is you want. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 17 Aug 2003 Posts: 51 Topics: 26 Location: Chennai
Posted: Thu Oct 19, 2006 11:25 am Post subject:
Kolusu,
I searched the forum but I couldn't find one which writes "Current Date" into a dataset. So I created a one new. Sorry if I didn't get the search seeds right.
Frank Yaeger,
You hit it right. I was just expecting what you gave me. Saved me a good amount of time. Very much appreciated. Thank you.
Joined: 17 Aug 2003 Posts: 51 Topics: 26 Location: Chennai
Posted: Mon Nov 13, 2006 11:42 am Post subject:
Frank,
I have got another additional requirement for the same request. Will it be possible to add/subtract time value that is written into the dataset. The reason is that the SORT now gives the SYSTEM DATE which is (REAL DATE - 12 HOURS) and we would like to have REAL DATE in our dataset. Please let me know if this is possible. Thank you.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Nov 13, 2006 2:09 pm Post subject:
Quote:
Will it be possible to add/subtract time value that is written into the dataset.
DFSORT has built-in functions to generate constants for current date - n days and current date + n days, but does not have built-in functions to generate the current date - n hours or current date + n hours.
I suppose you could generate a timestamp (yyyymmddhhmmss) and then use DFSORT's arithmetic functions for hh-12 or hh+12, but you'd have to be careful to handle it as date/time arithmetic rather than as regular arithmetic since they are different. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue Nov 14, 2006 8:58 am Post subject:
karavi2000,
The following DFSORT JCL will give you the date as (current date - 12 hours). As frank mentioned earlier there are no built-in functions to do the subtraction. However with a series of IFTHEN stmts we can achieve the desired results.
A brief explanation of the job. Subtraction of 12 hours will be a problem only when the current time is between 00 and 12 i.e midnight to afternoon. This is the only period of time that subtracting 12 hours results in yesterdays date.
Another tricky part is if the date happens to be March 1st on a leap year.In case of leap year we need to pick feb 29th.
The first build operator builts the record in the following format.
Pos 01 - Date in YYYY/MM/DD format
Pos 12 - Time in MM:HH:SS format
Pos 22 - will have the last of everymonth from Jan to dec
Pos 50 - flag to check if the date change is necessary (default is set to 'N')
The first Ifthen is to check if the time is less than 12 , If so we overlay the check falg to 'Y'. Also we perform the division by 4,100,400 to perform the check for leap year.
The next Ifthen is to check if it was leap year. The leap year check is simple
Code:
IF DIVISIBLE-BY-400 OR
(DIVISIBLE-BY-4 AND NOT DIVISIBLE-BY-100)
Leap year = 'Y'
If Leap-year = 'Y'
overlay feb last day = '29'
Using a series of IFTHEN statements on OUTREC we check if we need to subtract 1 from the day portion of date or overlay the month and day if it is the first day of the month
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum