IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To get the the current time


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 141
Location: India

PostPosted: Tue Nov 21, 2023 11:02 pm
Reply with quote

I have a requirement where i have to get the current time in a ps file if current time is less then 5 pm CT(central time)i need to execute the 2nd step in jcl or if the current time is more than 5 pm i need to execute the 3rd step in jcl.

Is it possible through sort card to get the time and do this..? I wanted to achieve this using sort only if possible any hint is fine.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Wed Nov 22, 2023 2:18 am
Reply with quote

Digvijay Singh wrote:

Is it possible through sort card to get the time and do this..?

Yes, it is possible. Though not only single "SORT card" must be involved.
Digvijay Singh wrote:
I wanted to achieve this using sort only if possible any hint is fine.

The major hint is: RTFM.

Pay attention to various &DATExxx parameters, and also Y4*,DTNS=(abc) and Y2*,DTNS=(abc) date conversion operations.

In order to skip or to execute next JCL step the best way is to conditionally place a dummy record into a temporary output via

OUTFIL INCLUDE=(compare dates),NULLOFL=RC4

In the next JCL step you can check the result of this comparison:

// EXEC PGM=...,COND=(4,EQ,SORTSTEP)

or you can use JCL IF statement:

// IF (SORTSTEP.RC EQ 4)
// ... do one thing
// ELSE
// ... do another thing
// ENDIF
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Wed Nov 22, 2023 9:37 am
Reply with quote

That’s why we have a job schedulers ..
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 141
Location: India

PostPosted: Wed Nov 22, 2023 10:29 am
Reply with quote

Hi I have used below sort card to get the timestamp:

Code:
//SYSIN    DD    *                   
   SORT FIELDS=COPY                   
   OUTFIL REMOVECC,NODETAIL,         
   HEADER1=(C'TIMESTAMP=',TIME=(12.))
 /*     



My output file looks like:

Code:
 ************************
 TIMESTAMP=11.37.26 pm   



Now i want to compare it with 5:00:00 Pm if it is greater than or less then 5 pm ...do i need to convert this file in character format, ned bit help here how i can compare here. Actually looking for belwo point you mentioned.

OUTFIL INCLUDE=(compare dates),NULLOFL=RC4


how this step works..? how i can put compare condition here ,,? can i simply compare fields against 5:00:00 pm ..?
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Wed Nov 22, 2023 12:34 pm
Reply with quote

I understand that your requirements are for a 5 pm boundary: regardless, in this situation, I would still worry about date boundaries.

Is 00:00:01 am greater than 12:59:59 pm?

For that reason, I think you should consider using the date also. And using military time instead of am/pm might be an easier comparison.
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 141
Location: India

PostPosted: Wed Nov 22, 2023 12:53 pm
Reply with quote

Quote:
Is 00:00:01 am greater than 12:59:59 pm?

I am not sure about this how it works..?

I am not worried about the date part i only want to compare the time if it is greater than 5:00:00 pm or less than it.

Quote:
And using military time instead of am/pm might be an easier comparison
.

about this you are saying using 24 hours format..? How will the comparison sort card look like then..? any help or suggestion appreciated [/quote]

i have used 24 hours format i got below output without am pm

*
Code:
*******************
 TIMESTAMP=02.37.59 
 ********************
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Nov 22, 2023 3:21 pm
Reply with quote

Quote:
Quote:
And using military time instead of am/pm might be an easier comparison
.

about this you are saying using 24 hours format..? How will the comparison sort card look like then..? any help or suggestion appreciated


i have used 24 hours format i got below output without am pm

*
Code:
*******************
TIMESTAMP=02.37.59
********************[/quote]

If you were to run that sort step at exactly 5 pm, you would get:

Code:
*******************
TIMESTAMP=17.00.00


Working out the comparison sort card should be simple.


Garry.
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 141
Location: India

PostPosted: Wed Nov 22, 2023 5:13 pm
Reply with quote

Yes, now i am using below sort card to compare:

my input file have now date in 24 hrs format.

input file:

Code:

********************
TIMESTAMP=02.57.29 


sort card i am using to compare:

Code:
 //SYSIN    DD *                                         
   SORT FIELDS=COPY                                       
   OUTFIL FNAMES=SORTOUT,INCLUDE=(11,8,CH,GT,C'17:00:00')
 /*   



depending upon the sortout file has data or not i can take further descision in my job.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Nov 22, 2023 5:44 pm
Reply with quote

Your input file has periods between the hours, minutes and seconds. Your sort card has colons in those locations.

Garry.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Wed Nov 22, 2023 8:01 pm
Reply with quote

Digvijay Singh wrote:
Yes, now i am using below sort card to compare:
my input file have now date in 24 hrs format.
input file:
Code:

********************
TIMESTAMP=02.57.29 

sort card i am using to compare:
Code:
 //SYSIN    DD *                                         
   SORT FIELDS=COPY                                       
   OUTFIL FNAMES=SORTOUT,INCLUDE=(11,8,CH,GT,C'17:00:00')
 /*   

depending upon the sortout file has data or not i can take further descision in my job.

Under no circumstances the value C'02.57.29' can be correctly compared to C'17:00:00'

PS: You've lost the critical parameter NULLOFL=, required for your initial task!

PPS: As mentioned in previous posts, the correct tool for your task is - any scheduler software, not SORT utility.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu Nov 23, 2023 12:16 am
Reply with quote

Is it possible that you only need to compare the first two characters of the time?
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 141
Location: India

PostPosted: Thu Nov 23, 2023 8:20 am
Reply with quote

Yes , I am thinking of that option it is in 24 hr format I could take only 17 in consideration. i am avoiding scheduling because number of jobs will be increased to maintain so thought of doing it using sorting itself.

Please suggest me a good option here since we are close to this if I can compare the only first two character of time..?
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu Nov 23, 2023 9:36 am
Reply with quote

re: only first two characters

only guessing at the syntax. Please verify.
Code:
 //SYSIN    DD *                                         
   SORT FIELDS=COPY                                       
   OUTFIL FNAMES=SORTOUT,INCLUDE=(11,2,CH,GT,C'17')
 /*   
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Thu Nov 23, 2023 9:49 pm
Reply with quote

Same result after
Code:
//SYSIN    DD *                                         
   SORT FIELDS=COPY                                       
   OUTFIL FNAMES=SORTOUT,INCLUDE=(11,10,CH,GT,C'17.00.00')
//*   


P.S.
The major issue with this topic was: how to use the parameter NULLOFL?
All the rest is too trivial to discuss further.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts C Compile time time stamps Java & MQSeries 10
No new posts Changeman - how can we know the curr... Compuware & Other Tools 2
No new posts Parallelization in CICS to reduce res... CICS 4
No new posts Fetch data from programs execute (dat... DB2 3
Search our Forums:

Back to Top