02-07-2017 8:54 AM
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
02-07-2017 9:30 AM
Why do you need this? What is the business functionality you're trying to achieve?
02-07-2017 10:08 AM
02-07-2017 3: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.