View previous topic :: View next topic
|
Author |
Message |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 150 Location: India
|
|
|
|
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2159 Location: USA
|
|
|
|
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 |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3077 Location: NYC,USA
|
|
|
|
That’s why we have a job schedulers .. |
|
Back to top |
|
 |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 150 Location: India
|
|
|
|
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 |
|
 |
Pedro
Global Moderator

Joined: 01 Sep 2006 Posts: 2600 Location: Silicon Valley
|
|
|
|
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 |
|
 |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 150 Location: India
|
|
|
|
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 |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
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 |
|
 |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 150 Location: India
|
|
|
|
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 |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
Your input file has periods between the hours, minutes and seconds. Your sort card has colons in those locations.
Garry. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2159 Location: USA
|
|
|
|
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 |
|
 |
Pedro
Global Moderator

Joined: 01 Sep 2006 Posts: 2600 Location: Silicon Valley
|
|
|
|
Is it possible that you only need to compare the first two characters of the time? |
|
Back to top |
|
 |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 150 Location: India
|
|
|
|
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 |
|
 |
Pedro
Global Moderator

Joined: 01 Sep 2006 Posts: 2600 Location: Silicon Valley
|
|
|
|
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2159 Location: USA
|
|
|
|
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 |
|
 |
|