Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Leading zeroes problem in REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Leading zeroes problem in REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue May 19, 2009 12:18 am    Post subject: Reply to: Leading zeroes problem in REXX
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

Moderator Team Head


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

PostPosted: Tue May 19, 2009 12:19 am    Post subject: Reply to: Leading zeroes problem in REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue May 19, 2009 12:34 am    Post subject: Reply to: Leading zeroes problem in REXX
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    Post subject: Reply to: Leading zeroes problem in REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue May 19, 2009 1:22 am    Post subject: Reply to: Leading zeroes problem in REXX
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Running an REXX EXEC implicitly sho7hills CLIST & REXX 3 Thu Apr 20, 2017 8:14 am
No new posts Need help in REXX CALL program Raje1002 CLIST & REXX 5 Wed Apr 19, 2017 11:18 pm
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us