Re: How to hande SAP BCD numrics in RPGLE



Hi Ben -

On Sun, 20 May 2007 21:08:40 +0200, reader <ben@xxxxxxxx> wrote:

I am programming on an I5 V5R3M0 in Ile-RPG. I have written an RFC
program that connects to a remote Unix SAP server to retrieve cost
values. SAP returns numeric data in BCD format. That should be something
very likewise to packed values we know in RPG but I can not handle them
because they are invalid, causing decimal data errors.

IIRC, BCD data is just like packed except that there is no sign. What
would be the sign nybble is actually the last digit; what would be the
last digit is the next to last digit, etc.

Probably the best way to handle this is a data structure where you
have a packed numeric field initialized to zero. Overlay all but the
last byte (which is going to be a zero digit and a positive sign) with
the BCD data. If you divide the numeric field by ten (to get rid of
the zero digit), you will then have the actual number.

--
Ken
http://www.kensims.net/
Opinions expressed are my own and do not necessarily represent the views
of my employer or anyone in their right mind.
.



Relevant Pages

  • Re: how do I get more numbers past the decimal?
    ... Other common formats are 64 ... So for the multi precision arithmetic, ... BCD is no more and no less accurate on generic numbers than anything else., its virtue is its exact reproduction of decimal numbers like 12.3456. ... With BCD you generally use one byte per significant digit, so its as precise on the mantissa as the number of bytes allocated. ...
    (comp.lang.php)
  • Re: how do I get more numbers past the decimal?
    ... Other common formats are 64 ... So for the multi precision arithmetic, ... BCD is no more and no less accurate on generic numbers than anything else., its virtue is its exact reproduction of decimal numbers like 12.3456. ... With BCD you generally use one byte per significant digit, so its as precise on the mantissa as the number of bytes allocated. ...
    (comp.lang.php)
  • Re: how do I get more numbers past the decimal?
    ... Other common formats are 64 ... So for the multi precision arithmetic, ... BCD is no more and no less accurate on generic numbers than anything else., its virtue is its exact reproduction of decimal numbers like 12.3456. ... With BCD you generally use one byte per significant digit, so its as precise on the mantissa as the number of bytes allocated. ...
    (comp.lang.php)