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

Help this REXX Rookie-Bad arithmetic conversion-Date Func


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

New User


Joined: 08 Jul 2021
Posts: 3
Location: USA

PostPosted: Thu Jul 08, 2021 7:26 pm
Reply with quote

Trying to figure out how to fix this. Thanks!

REXX:
Code:
/* REXX CLIST */                                           
YESTERDAY = DATE('BASE') - 1                               
MESSAGE1 = 'YESTERDAY-BASE IS: '||YESTERDAY               
SAY MESSAGE1                                               
YESTERDAY-CONVERTED = DATE('USA',YESTERDAY,'BASE')         
MESSAGE2 = 'YESTERDAY-CONVERTED IS: '||YESTERDAY-CONVERTED
SAY MESSAGE2                                               

Output:
YESTERDAY-BASE IS: 737977
5 +++ YESTERDAY-CONVERTED = DATE('USA',YESTERDAY,'BASE')
IRX0041I Error running VIL02435, line 5: Bad arithmetic conversion
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1257
Location: Bamberg, Germany

PostPosted: Thu Jul 08, 2021 7:42 pm
Reply with quote

Code it like a Pro icon_cool.gif
Code:
YESTERDAY = DATE('B') - 1                                 
MESSAGE1 = 'YESTERDAY-BASE IS: '!!YESTERDAY               
SAY MESSAGE1                                             
YESTERDAY_CONVERTED = DATE('U',YESTERDAY,'B')             
MESSAGE2 = 'YESTERDAY_CONVERTED IS: '!!YESTERDAY_CONVERTED
SAY MESSAGE2
Back to top
View user's profile Send private message
REGGIE2028

New User


Joined: 08 Jul 2021
Posts: 3
Location: USA

PostPosted: Thu Jul 08, 2021 7:51 pm
Reply with quote

Thanks, I'm good. I'll use this solution below I just stumbled upon:

Code:
YESTERDAY1 = DATE('USA',DATE(B)-1,'B')   
SAY 'EX1 = '||YESTERDAY1                 


Output
EX1 = 07/07/21
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1257
Location: Bamberg, Germany

PostPosted: Thu Jul 08, 2021 7:55 pm
Reply with quote

You should chose whether you want to use full names or abbreviations for date specifics. Here you mix Usa and B(ase) together. Other than that, variables shall not have a 'minus' in the name.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

PostPosted: Thu Jul 08, 2021 9:07 pm
Reply with quote

When moving some code (or some ideas) from COBOL environment to REXX environment:

1) it is a very bad idea to use the ‘-‘ (minus sign) as part of any entity identification name; the result may be either syntax error, or unpredictable “bad arithmetic”, etc.

2) it is just a bad idea to use uppercase-only notation for either entity names, or REXX keywords themselves; it’s getting very, very hard for others (as well for yourself) to read and to understand the uppercase REXX code, especially when that one is longer than 3 lines of code. A reasonable mixed case notation is highly recommended (but ignored by many environmental migrants)

Surprisingly, in opposite to the minus sign, in REXX new characters like ‘!’, ‘?’, and others are allowed as part of entity names (variables, functions, labels…). Sometimes it looks very convenient:
Code:
balanceIsValid? = (client.balanceAmount > transaction.requestedValue)
. . . . . . . .
If balanceIsValid? Then Do
   . . . . . . . . . .
End
Else Do
   . . . . . . . . . .
End
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu Jul 08, 2021 10:43 pm
Reply with quote

I disagree with your comment:
Code:
/* REXX CLIST */


update: I originally posted this as humor, but it really annoys me for some reason. It is not a CLIST. CLISTs are a different language.
Back to top
View user's profile Send private message
REGGIE2028

New User


Joined: 08 Jul 2021
Posts: 3
Location: USA

PostPosted: Fri Jul 09, 2021 12:09 am
Reply with quote

All, I'm good. The solution I posted is working fine. The minus is not a part of my variable. It's a subtraction operation to go back one day. Get Yesterdays date. Ok yes my comments are not perfect yet. Whereas this is only a testbed to get things right prior to the big dive into code. I needed a solution that would account for month end/First of month situations. This code does exactly that and is simple to understand and use. I keep my vars within standards. The right-side of = I have nothing but built-in functions and math operations.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

PostPosted: Fri Jul 09, 2021 1:02 am
Reply with quote

REGGIE2028 wrote:
The minus is not a part of my variable. It's a subtraction operation to go back one day. Get Yesterdays date.
Please, take a closer look at your own original post:
Code:
/* REXX CLIST */                                           
YESTERDAY = DATE('BASE') - 1                               
MESSAGE1 = 'YESTERDAY-BASE IS: '||YESTERDAY               
SAY MESSAGE1                                               
YESTERDAY-CONVERTED = DATE('USA',YESTERDAY,'BASE')         
MESSAGE2 = 'YESTERDAY-CONVERTED IS: '||YESTERDAY-CONVERTED
SAY MESSAGE2                                               
It is definitely the subtraction operation between variables YESTERDAY, and CONVERTED. This is condemned to fail immediately…
REGGIE2028 wrote:
This code does exactly that and is simple to understand and use. I keep my vars within standards.

1) The standards blindly copied from COBOL do not work well in REXX. BTW, did you know that posting any message in uppercase is strictly prohibited at this forum? Try to guess, why? Because it is very difficult to read any text in caps-only!

2) Such code is “simple to understand and use” as long as its size remains within one page. Later this style of coding shall inevitably lead to the problems much worse than current problems with the getting obsolete COBOL code.
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
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 Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
Search our Forums:

Back to Top