Skip to Content
avatar image
Former Member

FM to convert hexadecimal to decimal

Hi ,

Is there any FM or any other way to convert hexadecimal ( type xstring) to packed decimal ( type P).

Thanks in advance.

Best Regards,

Gopi

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 16, 2008 at 03:11 PM

    1st convert the xstring to string using fm ECATT_CONV_XSTRING_TO_STRING and after that try to convert the string value to decimal by simple assignment.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 16, 2008 at 03:18 PM

    Here's one I prepared earlier today:

    DATA value1 TYPE x LENGTH 2 VALUE '0BDF'.
    DATA value2 TYPE i.
    MOVE value1 TO value2.
    WRITE / value2.  " Hex converted to integer
    
    DATA value3 TYPE p DECIMALS 2.
    value3 = value2. " Convert to type p
    
    WRITE / value3.

    Note, the LENGTH for value1 - the hex value - must be the correct number of bytes. And you must have leading 0 if the number of hex digits isn't even.

    Add comment
    10|10000 characters needed characters exceeded