|
View previous topic :: View next topic
|
| Author |
Message |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1753 Location: Tirupur, India
|
|
|
|
Hi,
Could you please let me know how to use WEEKDAY along with SUBDAYS(or ADDDAYS).
This link publib.boulder.ibm.com/infocenter/zos/v1r12/index.jsp?topic=%2Fcom.ibm.zos.r12.iceg200%2Fcvtdf.htm
| Quote: |
TOGREG=Yaa(s) - converts to a gregorian date with separators (for |example, C'2009.09.21').
|
WEEKDAY=CHAR3 - converts to a 3 character day of the week (for |example, C'WED' for Wednesday). |
says how to use TOGREG and WEEKDAY similar keywords,
When I try SUBDAYS with TOGREG like this
| Code: |
| 11:81,8,Y4T,SUBDAYS,+3,TOGREG=Y4T,2X, |
it works fine.
However
SUBDAYS with WEEKDAY
| Code: |
| 21:81,8,Y4T,SUBDAYS,+3,WEEKDAY=CHAR3 |
gives a syntax error.
One more doubt, in the solution you posted here
ibmmainframes.com/viewtopic.php?t=60965
you used,
| Code: |
| IFTHEN=(WHEN=NONE,OVERLAY=(84,4,C'-',88,2,C'-',90,2)) |
instead of
| Code: |
| IFTHEN=(WHEN=NONE,OVERLAY=(84,8,Y4T,2X)) |
Is it just a personal choice or it is less CPU consuming?
Thanks & Regards, |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| No Tailgating. New question, new topic :-) |
|
| Back to top |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1753 Location: Tirupur, India
|
|
|
|
Bill, Thanks :-)
The question was partially related to the techniques and terms used on
ibmmainframes.com/viewtopic.php?t=60965
hence I had to followup.
I am glad it was made new topic,
Happy weekend! time for drinks and
Thanks & Regards, |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
You might also be intrested in this solution then
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
TODAY,S'&WDAY'
//SORTIN DD *
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:TODAY,DATE1)),
IFTHEN=(WHEN=(81,3,CH,EQ,C'FRI'),OVERLAY=(84:DATE1(-)-3)),
IFTHEN=(WHEN=NONE,OVERLAY=(84:DATE1(-)-1)) |
 |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| vasanthz wrote: |
However SUBDAYS with WEEKDAY
| Code: |
| 21:81,8,Y4T,SUBDAYS,+3,WEEKDAY=CHAR3 |
gives a syntax error. |
Well WEEKDAY and SUBDAYS are two different functions and syntax wise they are on the same level. Essentially when you are adding/subtracting days from a given date, the result should also be a date and not day of the week.
if you want the weekday function after arithmetic, then you can use the following
| Code: |
OUTREC OVERLAY=(81:81,8,Y4T,SUBDAYS,+3,TOGREG=Y4T,
21:81,8,Y4T,WEEKDAY=CHAR3)
|
if you look at it , we essentially picked the updated date value at pos 81 and calculated the day of the week.
| vasanthz wrote: |
One more doubt, in the solution you posted here
ibmmainframes.com/viewtopic.php?t=60965
you used,
| Code: |
| IFTHEN=(WHEN=NONE,OVERLAY=(84,4,C'-',88,2,C'-',90,2)) |
instead of
| Code: |
| IFTHEN=(WHEN=NONE,OVERLAY=(84,8,Y4T,2X)) |
Is it just a personal choice or it is less CPU consuming?
Thanks & Regards, |
well you are comparing apples to oranges. OVERLAY=(84,4,C'-',88,2,C'-',90,2)) is creating the date with separators where as OVERLAY=(84,8,Y4T,2X)) will create the date as CCYYMMDD and padding 2 spaces at the end.
If you need the formatting done automatically you need to specify it differently ex:
| Code: |
| OVERLAY=(84,8,Y4T(-)) |
I just showed the date formatting manually. Just one of "n" ways to get the results. There will be no difference in CPU for this formatting. |
|
| Back to top |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1753 Location: Tirupur, India
|
|
|
|
Thank you Pandora and Kolusu, learnt something new today.
The similar syntaxes got me confused. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Pandora-Box wrote: |
You might also be intrested in this solution then
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
TODAY,S'&WDAY'
//SORTIN DD *
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:TODAY,DATE1)),
IFTHEN=(WHEN=(81,3,CH,EQ,C'FRI'),OVERLAY=(84:DATE1(-)-3)),
IFTHEN=(WHEN=NONE,OVERLAY=(84:DATE1(-)-1)) |
 |
Pandora-Box,
1. Were you intentionally creating the dates at position 84 instead of position 1 or within the first 80 bytes?
2. Why do you need DATE1 in your WHEN=INIT when you don't have any plans to use it? |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Hi Kolusu,
81 was intentional for a different problem as you pointed overlay can happen at position 1 and INIT doesn't need DATE1 |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
As Kolusu points a better solution now ;)
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
TODAY,S'&WDAY'
//SORTIN DD *
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1:TODAY,DATE1(-)-1)),
IFTHEN=(WHEN=(1,3,CH,EQ,C'TUE'),OVERLAY=(4:DATE1(-)-3)) |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|