× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Mon, 2004-05-24 at 16:12, Robert Clay wrote:
> We are at V5R1 so I have to jump through hoops to get things to work.  

No hoops needed :-)
> We have MONTHID  (A  6) which represents YYYYMM, where YYYY is the year and 
> MM is the month number.  Sample data would be '200404'.
>  
> I need to do some manipulation where this value is the key and I need to know 
> the same month of the previous year.  So, I came up with this EVAL statement 
> (in free format):
>  
> PASTMONTH = %char(atoi(%subst(MONTHID:1:4))-1) + %subst(MONTHID:5:2)

YEAR = atoi( %subst( MONTHID : 1 : 4 ) ) - 1;
MONTH = %subst( MONTHID : 5 );
PASTMONTH = %editc( YEAR : 'X' ) + MONTH ;

Or you could move it into a DS:

<psuedo-code>
d MONTH_DS        ds
d   year                                     4  0
d   month                                   2  0

 /free
     MONTH_DS = MONTHID ;
     PASTMONTH = %editc( year - 1 : 'X' ) + %editc( month : 'X' );
 /end-free

</psuedo-code>

> PASTMONTH is also (A  6).

According to the below error, PASTMONTH cannot be modified.  I know you
said it is a field in the file, but could it also be a procedure
parameter defined with CONST by any chance?  

If not, then it seems the compiler may be getting confused by the nested 
statements, 
but I don't think I've seen this before.  It could be some kind of intermediate
operation problem.

Joel
http://www.rpgnext.com




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.