× 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.



Thank you, Barbara, for your explanations and yes, I do have a lot of subfields in the data structures, hence the need for eval-corr.
What Chris suggested is a good solution and I am going to give it a try; my work-around was this:
if DS_HRESD01.D1CHGAMT < 0;
DS_DETD01 *= (-1);
endif;

and it worked. So, the subfield DS_HRESD01.D1CHGAMT is recognized as a negative value; but probably Chris solution is better to avoid any (unpleasant) surprises down the road.



Thank you


Florin Todor


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Barbara Morris
Sent: Friday, May 10, 2013 8:36 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Eval-corr

On 5/10/2013 9:56 AM, Florin Todor wrote:

ds_hresD01 = f_in210txt;
// DS_HRESD01.D1CHGAMT = -793.49<---- from Debug session
eval-corr ds_detD01 = ds_hresD01;
// D1CHGAMT OF DS_DETD01 = 0000000793.49<---- from Debug session


That's interesting that the debugger shows the zoned value that way. If
that '-' character happened to be '/', the debugger would show the value
of DS_HRESD01.D1CHGAMT as /793.49.

And it's interesting that RPG doesn't mind the '-' as one of the zoned
decimal digits. I believe it is allowed because the hex value of '-' is
x'60', and for zoned arithmetic, only the digit part, x'0' in this case
is used. The zone part, x'6' in this case, is ignored for all except the
sign byte (the last byte, where only zones of x'A' to x'F' are allowed).

If you happened to have x'61', '/', where you have the '-' character, it
would be interpreted as a 1, and the result would be 1793.49.

And if you happened to have the '+' character, x'4e', you would get
decimal data error on the eval-corr.

I think you should just define DS_HRESD01.D1CHGAMT as character, so
EVAL-CORR will skip it, and then handle it separately as Chris
suggested. I am assuming you have other subfields in the data
structures, otherwise, there is no real need for eval-corr; eval will do.

I'm surprised that the data in f_in210txt has the numeric value as half
character, with the minus sign as part of the data, and half numeric,
not showing a decimal point. It would be somewhat easier to process in
RPG if it had both the sign and the decimal point because then you could
just use %dec directly, without having to divide by 100.


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.