Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

FM to convert hexadecimal to decimal

Former Member
0 Kudos

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

2 REPLIES 2

Former Member
0 Kudos

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.

matt
Active Contributor
0 Kudos

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.