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: 

Is it possible to move non-Unicode typex string into fields in US SAP?

Former Member
0 Kudos

The following test example code was created to resolve an issue where we are sending Unicode(US) data to an external (non-unicode)NUS. The below logic works great in converting the character fields from US to NUS, by placing them into the l_buffer field. The new converted hex values on l_buffer are just what the receiving system needs.

However, Because the sending APAB code in production sends the data out in already defined character text fields.....

Is it possible to move these non-Unicode(NUS) hex values created in the type x (l_buffer) string back into the character fields they were converted from? Or, does an SAP Unicode System(US) always need/display/convert 4 byte, unicode friendly hex, it its fields?

Simply, the field l_CRLF (carriage return line feed) after converting from US to NUS below has the value of '0d0a' in l_buffer.

In the US it was, and still is, '0d000a00' .....Can I put '0d0a' back into the char field of l_crlf from l_buffer?

Thank-You.

*--------------------------------------------------------------*
*& Report  YTMM_CRLF_UPGRADE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  YTMM_CRLF_UPGRADE.

DATA:
  text(100) TYPE C VALUE 'ABC',
  int TYPE I VALUE 258,
  CRLF(2) type c.

DATA:
  conv TYPE REF TO cl_abap_conv_out_ce,
  buffer TYPE XSTRING.
break matyst.

conv = cl_abap_conv_out_ce=>create(
         encoding = 'UTF-8'
         endian = 'L'
       ).

class CL_ABAP_CHAR_UTILITIES definition load.
crlf = CL_ABAP_CHAR_UTILITIES=>CR_LF.

CALL METHOD conv->write( data = crlf ).
CALL METHOD conv->write( data = text n = 4 ).
CALL METHOD conv->write( data = int ).

buffer = conv->get_buffer( ).

write:/ buffer.

2 REPLIES 2

Former Member
0 Kudos

After some experimenting, try the following: - the key is the 'NON-UNICODE' encoding in the create method.


report zchris.

data l_string(12) type c.
data l_xstring    type xstring.

data lc_conv TYPE REF TO cl_abap_conv_out_ce.
data l_crlf type abap_cr_lf value cl_abap_char_utilities=>cr_lf.

concatenate 'CHRISCHRIS' l_crlf into l_string.

lc_conv = cl_abap_conv_out_ce=>create(
         encoding = 'NON-UNICODE' ).

lc_conv->write( data = l_string ).

l_xstring = lc_conv->get_buffer( ).

Former Member
0 Kudos

I think you can use FM 'HR_RU_CONVERT_HEX_TO_STRING ' to convert hex data to string.