Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 10309
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: 4650
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: 10309
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: 10309
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
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Creating ISPF Screens with Scrname vi... Albireo20 TSO/ISPF 9 Tue Sep 05, 2017 4:24 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us