Skip to Content
0
Jun 16, 2009 at 07:19 AM

how to pass the line feed character in the string to have its hex value?

249 Views

Hi,

I have a code below. Its converting character to its hex value. Now I want to passa line feed to the string. What character I should provide in the string variable so that it will convert to the line fees hex value?

data: hexstring type xstring,
     input     type string ,
     input_x type x length 49.
data: buffer type xstring,
     int    type i value 258,
     text(64) type c ,
     n     type sy-index,
     conv   type ref to cl_abap_conv_out_ce,
     loc_conv type ref to cl_abap_conv_in_ce.

*---convert into hexa decimals.
input = 'ABC123        ACHDA0000        C000000000'.
text = input.
n = strlen( text ).
conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' endian = 'L' ).
call method conv->write( data = text n = n ).
call method conv->write( data = int ).
buffer = conv->get_buffer( ).
*write : / buffer.
input_x = buffer.
break-point.
*---convert xstring to string.
call method cl_abap_conv_in_ce=>create
 exporting
   input       = input_x "buffer
   encoding    = 'UTF-8'
   replacement = '?'
   ignore_cerr = abap_true
 receiving
   conv        = loc_conv.
try.
   call method loc_conv->read
     importing
       data = input.
 catch cx_sy_conversion_codepage.
*-- Should ignore errors in code conversions
 catch cx_sy_codepage_converter_init.
*-- Should ignore errors in code conversions
 catch cx_parameter_invalid_type.
 catch cx_parameter_invalid_range.
endtry.


write:/ input_x.
write:/ input.