MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Current Date in a PS thru JCL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
karavi2000
Beginner


Joined: 17 Aug 2003
Posts: 51
Topics: 26
Location: Chennai

PostPosted: Wed Oct 18, 2006 11:13 am    Post subject: Current Date in a PS thru JCL Reply with quote

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.

Regards,
Ravishankar
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Oct 18, 2006 11:32 am    Post subject: Reply with quote

karavi2000,

Please search before posting. Check this link

http://www.mvsforums.com/helpboards/viewtopic.php?t=2101&highlight=ezacfsm1

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Oct 18, 2006 11:51 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
karavi2000
Beginner


Joined: 17 Aug 2003
Posts: 51
Topics: 26
Location: Chennai

PostPosted: Thu Oct 19, 2006 11:25 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
karavi2000
Beginner


Joined: 17 Aug 2003
Posts: 51
Topics: 26
Location: Chennai

PostPosted: Mon Nov 13, 2006 11:42 am    Post subject: Reply with quote

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.

Regards,
Ravishankar
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Mon Nov 13, 2006 12:02 pm    Post subject: Reply with quote

Why the aversion to writing a program? This is 2 lines in Rexx.
Back to top
View user's profile Send private message Visit poster's website
karavi2000
Beginner


Joined: 17 Aug 2003
Posts: 51
Topics: 26
Location: Chennai

PostPosted: Mon Nov 13, 2006 12:25 pm    Post subject: Reply with quote

Seemigeezer,
I believe our job stream doesn't allow REXX codes and yes, we can write programs. But SORT is easy to maintain and faster. Thanks.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Nov 13, 2006 2:09 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Nov 14, 2006 8:58 am    Post subject: Reply with quote

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

Code:

//STEP0100 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD *           
DUMMY RECORD               
//SORTOUT  DD SYSOUT=*     
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                             
  INREC IFTHEN=(WHEN=INIT,                                     
        BUILD=(01:DATE=(4MD/),                                 
               12:TIME,                                         
               22:C'312831303130313130313031',                 
               50:C'N',                                         
               80:X)),                                         
                                                               
        IFTHEN=(WHEN=(12,2,ZD,LT,12),                           
        OVERLAY=(50:C'Y',                                       
                 52:01,04,ZD,MOD,+4,EDIT=(T),                   
                 54:01,04,ZD,MOD,+100,EDIT=(TTT),               
                 58:01,04,ZD,MOD,+400,EDIT=(TTT)),HIT=NEXT),   
                                                               
        IFTHEN=(WHEN=(58,3,ZD,EQ,0,OR,                         
                     (52,1,ZD,EQ,0,AND,54,3,ZD,GT,0)),         
        OVERLAY=(24:C'29'))                                     
                                                               
 OUTREC IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,                     
                      09,02,CH,NE,C'01'),                       
       OVERLAY=(09:09,02,ZD,SUB,+1,EDIT=(TT))),
                 
       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,       
                     06,02,CH,EQ,C'02',AND,     
                     09,02,CH,EQ,C'01'),         
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),     
               09:22,02)),
                       
       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,       
                     06,02,CH,EQ,C'03',AND,     
                     09,02,CH,EQ,C'01'),         
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),     
               09:24,02)),                       

       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,       
                     06,02,CH,EQ,C'04',AND,     
                     09,02,CH,EQ,C'01'),         
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),     
               09:26,02)),                       

       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,       
                     06,02,CH,EQ,C'05',AND,     
                     09,02,CH,EQ,C'01'),         
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),     
               09:28,02)),                       

       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,       
                     06,02,CH,EQ,C'06',AND,     
                     09,02,CH,EQ,C'01'),         
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),     
               09:30,02)),                       

       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,       
                     06,02,CH,EQ,C'07',AND,     
                     09,02,CH,EQ,C'01'),         
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),     
               09:32,02)),                       

       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,       
                     06,02,CH,EQ,C'08',AND,     
                     09,02,CH,EQ,C'01'),         
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),     
               09:34,02)),                       

       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,     
                     06,02,CH,EQ,C'09',AND,   
                     09,02,CH,EQ,C'01'),       
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),   
               09:36,02)),                     

       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,     
                     06,02,CH,EQ,C'10',AND,   
                     09,02,CH,EQ,C'01'),       
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),   
               09:38,02)),                     

       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,     
                     06,02,CH,EQ,C'11',AND,   
                     09,02,CH,EQ,C'01'),       
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),   
               09:40,02)),                     

       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,     
                     06,02,CH,EQ,C'12',AND,   
                     09,02,CH,EQ,C'01'),       
      OVERLAY=(06:06,02,ZD,SUB,+1,EDIT=(TT),   
               09:42,02)),                     

       IFTHEN=(WHEN=(50,01,CH,EQ,C'Y',AND,     
                     06,02,CH,EQ,C'01',AND,   
                     09,02,CH,EQ,C'01'),       
      OVERLAY=(01:01,04,ZD,SUB,+1,EDIT=(TTTT),
               06:C'12',                       
               09:44,02))                     

  OUTFIL OUTREC=(01,10,80:X)                   
/*




or you can simply use the unload utility of DB2 to get the desired results.
Code:

//STEP0100 EXEC PGM=IKJEFT01               
//SYSTSPRT DD  SYSOUT=*,DCB=BLKSIZE=121   
//SYSPRINT DD  SYSOUT=*                   
//SYSTSIN  DD  *                           
 DSN SYSTEM(XXXX)                         
 RUN  PROGRAM(DSNTIAUL) -                 
      PLAN(DSNTIAUL)    -                 
      PARMS('SQL')      -                 
      LIB('DB2P.RUNLIB.LOAD')             
//SYSREC00 DD SYSOUT=*                     
//SYSPUNCH DD DUMMY
//SYSIN    DD *                           
  SELECT DATE(CURRENT TIMESTAMP - 12 HOURS)
    FROM SYSIBM.SYSDUMMY1                 
    ;

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group