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: 

Get Ascii Value A to 65

Former Member

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

3 REPLIES 3

matt
Active Contributor
0 Kudos

Why do you need this? What is the business functionality you're trying to achieve?

raymond_giuseppi
Active Contributor
0 Kudos

Look for UCS-2 in Abap documentation to understand.


raghug
Active Contributor

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.