Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
cvasu03

New User

Joined: 23 Mar 2007
Posts: 9
Location: USA

 Posted: Tue May 19, 2009 12:14 am    Post subject: Leading zeroes problem in REXX I have coded the rexx program for date in the following way. CURRDATE = SUBSTR(DATE(S),3,2) || SUBSTR(DATE(S),5,2) || SUBSTR(DATE(S),,7,2) CURRYY = SUBSTR(DATE(S),3,2) CURRYYYY = SUBSTR(DATE(S),1,4) CURRMM = SUBSTR(DATE(S),5,2) CURRDD = SUBSTR(DATE(S),7,2) I want to check for the quarter end date. If the current month is > 3 and less than 6 then set the month to 03 and similarly for other quarters. QTRENDDT = CURRYYYY || CURRMM Do While (CURRMM \= 03 & CURRMM \= 06 & CURRMM \= 09 & CURRMM \= 12) If (CURRMM = 03 | CURRMM = 06 | CURRMM = 09 | CURRMM = 12) Then QTRENDDT = CURRYYYY || CURRMM Else If (CURRMM = 01) Then Do QTRENDDT = CURRYYYY - 1 || 12 CURRMM = 12 End Else If (CURRMM \= 01) Then Do CURRMM = CURRMM - 1 QTRENDDT = CURRYYYY || CURRMM End End The logic is working fine. Only problem is with leading zeroes in month. The month it is giving is 3 instead of 03 after concatenation. Result is QTRENDDT = 20093 I want the result to be 200903. I have tried the RIGHT function but it is ABENDING. May be i have not used it correct way. Please help! Thanks

enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10439
Location: italy

Posted: Tue May 19, 2009 12:18 am    Post subject: Reply to: Leading zeroes problem in REXX

odd, never happened to me
post the culprit statement exactly as You have written it

also
 Quote: I want to check for the quarter end date. If the current month is > 3 and less than 6 then set the month to 03 and similarly for other quarters.

usually
 Code: 1-3   quarter end date = 3  start 1 4-6   quarter end date = 6  start 4 6-9   quarter end date = 9  start 7 10-12 quarter end date = 12 start 10
superk

Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

 Posted: Tue May 19, 2009 12:19 am    Post subject: Reply to: Leading zeroes problem in REXX RIGHT is the correct function, i.e.: QTRENDDT = CURRYYYY || RIGHT(CURRMM,2,'0')
enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10439
Location: italy

Posted: Tue May 19, 2009 12:34 am    Post subject: Reply to: Leading zeroes problem in REXX

and here is the algorithimic solution ...

 Code: do i = 1 to 12    say right(i,2,"0") "qstart = " right(((i-1)%3)*3+1,2,"0") "qend   = " right(((i-1)%3)*3+3,2,"0") end
cvasu03

New User

Joined: 23 Mar 2007
Posts: 9
Location: USA

 Posted: Tue May 19, 2009 12:39 am    Post subject: Reply to: Leading zeroes problem in REXX Thank you I have coded the right statement in the following way. CURRMM = RIGHT(CURRMM,2,'0'). I believe this statement was not liking. I changed it to QTRENDDT = CURRYYYY || RIGHT(CURRMM,2,'0') as per superk. and it is working fine. Code: 1-3 quarter end date = 12 start 1 4-6 quarter end date = 3 start 4 6-9 quarter end date = 6 start 7 10-12 quarter end date = 9 start 10 Thanks to all for your quick reply.
enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10439
Location: italy

Posted: Tue May 19, 2009 1:22 am    Post subject: Reply to: Leading zeroes problem in REXX

 Quote: 1-3 quarter end date = 12 start 1 4-6 quarter end date = 3 start 4 6-9 quarter end date = 6 start 7 10-12 quarter end date = 9 start 10

still illogic/very peculiar , but if You like it that way
if You want people to understand what You mean it would be wiser to use a different terminology or a better description...
quarter start and quarter end are pretty standard terms and You are using them in an odd way
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics How to control Panel Attributes throu... rsshanmugam CLIST & REXX 3 Mon Feb 26, 2018 9:51 pm Find a string in PS file opened in br... mukkas CLIST & REXX 3 Sat Feb 24, 2018 2:15 pm how to get Job information from IOF u... rsshanmugam CLIST & REXX 13 Mon Feb 05, 2018 4:22 pm attchmvs from rexx subroutine that re... harisukumaran CLIST & REXX 1 Fri Jan 19, 2018 5:29 am Can we create REXX ouput in an Excel ... upendrasri CLIST & REXX 3 Wed Jan 17, 2018 8:19 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us