Skip to Content
avatar image
-1
Former Member

Get Ascii Value A to 65

Data : LV_S type c.

DATA : LV_AN TYPE i.

FIELD-SYMBOLS: <fc> TYPE x.

LV_S = 'A'.

ASSIGN LV_S to <fc> CASTING.

MOVE <fc> to LV_AN.

Now get data in dubugging as ,

<fc> = 4100

LV_AN = 16640

Now i want lv_an = 65 ... but it is display lv_an = 16640.

kindly , give proper solution

Regards,

Pratiksha

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 07, 2017 at 03:31 PM

    You are dealing with double byte. If you read your <fc> as hex 41 00 - that is the ASCII equivalent of 65 00. You will have to convert the first 2 numbers from hex to ascii and then ignore the rest. Try this instead

    DATA(ascii) = cl_abap_conv_in_ce=>uccp( 'A' ).

    Also, see all the wiki on code page conversions Character encoding conversion - ABAP Development - SCN Wiki. If for some reason, you change your mind and want to work with the hex... you can try this snippet. When you create the conversion object, you optionally can change the code-page too.

    DATA(o_conv) = cl_abap_conv_out_ce=>create( ).
    
    o_conv->convert(
      EXPORTING
        data        = 'ABC'    " Field to Be Converted
      IMPORTING
        buffer      = DATA(buffer)    " Converted Data
    ).
    
    WRITE buffer.
    
    Add comment
    10|10000 characters needed characters exceeded