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

WEEKDAY with S*U*B*DAYS/ADDDAYS


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

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri May 10, 2013 5:38 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 10, 2013 6:34 pm
Reply with quote

No Tailgating. New question, new topic :-)
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri May 10, 2013 7:18 pm
Reply with quote

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 icon_oak.gif

Thanks & Regards,
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri May 10, 2013 7:40 pm
Reply with quote

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))
icon_biggrin.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri May 10, 2013 10:26 pm
Reply with quote

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
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Mon May 13, 2013 2:44 pm
Reply with quote

Thank you Pandora and Kolusu, learnt something new today.
The similar syntaxes got me confused.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue May 14, 2013 3:32 am
Reply with quote

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))
icon_biggrin.gif


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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue May 14, 2013 7:35 am
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue May 14, 2013 11:14 am
Reply with quote

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
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 Amount of days between two dates PL/I & Assembler 8
No new posts How to remove remote file older than ... All Other Mainframe Topics 4
This topic is locked: you cannot edit posts or make replies. Add 5 days to a date DB2 19
No new posts Process file after 7 days of hold All Other Mainframe Topics 4
No new posts How to find jobs that are in schedule... All Other Mainframe Topics 5
Search our Forums:

Back to Top