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

Leading zeroes problem in REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cvasu03

New User


Joined: 23 Mar 2007
Posts: 9
Location: USA

PostPosted: Tue May 19, 2009 12:14 am
Reply with quote

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
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue May 19, 2009 12:18 am
Reply with quote

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.


please clarify ...
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
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Tue May 19, 2009 12:19 am
Reply with quote

RIGHT is the correct function, i.e.:

QTRENDDT = CURRYYYY || RIGHT(CURRMM,2,'0')
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue May 19, 2009 12:34 am
Reply with quote

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
Back to top
View user's profile Send private message
cvasu03

New User


Joined: 23 Mar 2007
Posts: 9
Location: USA

PostPosted: Tue May 19, 2009 12:39 am
Reply with quote

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.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue May 19, 2009 1:22 am
Reply with quote

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 icon_cool.gif
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
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top