Using cvtch (the hex must be 8 characters long


D data DS
D i                             10i 0
D a                              4    overlay(data: 1)
D h               s              8
Dcvtch            PR                  EXTPROC('cvtch')
D                                1
D                                1
D                               10i 0 VALUE

  h = '00BC614E';
  dsply 'hex:' '' h;
  cvtch(a: h: 8);
  dsply 'int:' '' i;

   *inlr = *on;


DSPLY  hex:    00BC614E
DSPLY  int:      12345678

On 9/11/19 1:33 AM, Roberto De Pedrini wrote:
But if you don't like API and love SQL ...take a look at this SQL statement

D usrf01 ds
D TypeCode 1 2s 0
D Category 3 4p 0
D Amount 5 8p 2

// get the amount and check the sign

select dec(
7,2) *
(case when substr(hex(substr(usrf01,5,4)),8,1) = 'D'
then -1 else 1 end),
7,2) as Price
from usrfldpf

Il giorno lun 9 set 2019 alle ore 14:47 David Gibbs via RPG400-L <
rpg400-l@xxxxxxxxxxxxxxxxxx> ha scritto:


Does anyone have a routine handy (or know of an API) that will convert
hex characters to decimal or integer?

For example: If I have the character value 'BC614E' I would get
12345678 returned.

I had hoped there would be something in SQL, since there is a HEX
function that will convert a numeric into character hex, but it
doesn't appear to exist.



IBM i on Power Systems: For when you can't afford to be out of business!

I'm riding in the American Diabetes Association's Tour de Cure to
raise money for diabetes research, education, advocacy, and awareness.
You can make a tax-deductible donation to my ride by visiting

You can see where my donations come from by visiting my interactive
donation map ... (it's a geeky

I may have diabetes, but diabetes doesn't have me!
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives

Please contact support@xxxxxxxxxxxx for any subscription related

Help support by shopping at with our affiliate

-- Este e-mail fue enviado desde el Mail Server del diario ABC Color -- -- Verificado por Anti-Virus Corporativo Symantec --

This thread ...


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

This mailing list archive is Copyright 1997-2020 by 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].