Application Development and Automation 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: 
Read only

ASCII code convert problem

Former Member
0 Likes
643

Hi all,

ı wanna convert char to ascii code. But it returns 41 not 65 for 'A' . Please help !!

CALL FUNCTION 'URL_ASCII_CODE_GET'

     EXPORTING

       trans_char       = 'A'

    IMPORTING

      CHAR_CODE        = ascii

             .

2 REPLIES 2
Read only

former_member201285
Active Participant
0 Likes
564

Hi,

the parameter ascii is the hex-code as string:

It returns "41" which means 4 * 16^1 + 1 * 16^0 = 65

If you want an OO-approach für converting to other codepages, you can use class CL_ABAP_CONV_OUT_CE or CL_ABAP_CONV_IN_CE (there are some examples in the documentation).

Regards,

Ulrich

Read only

Former Member
0 Likes
564

Hi Gulsah,

The hexadecimal for 'A' is 41.

65 is the hexa for 'e'.

Try debuging the code and you can check it out yourself.

DATA: char_code(2) TYPE c.

FIELD-SYMBOLS: <test>  TYPE x.

   ASSIGN 'A' TO <test> CASTING.
   WRITE <test> TO char_code.

   WRITE char_code.



Cheers!