Hi
I have a requirement to send Chinese data from SAP tables including Strange characts(%$#@* etc.,) from Non-unicode system ecc5.0(with English log on) to External system.It works well if no strange characters but getting conversion error if there is strange character in data. I am using below code in my function module before sending data out from system in XML format.
Call function to get code page for language
CALL FUNCTION 'SCP_CODEPAGE_FOR_LANGUAGE'
EXPORTING
LANGUAGE = if_langu "Chinese
IMPORTING
CODEPAGE = lf_codepage. "Codepage for Chinese
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = request "my data
mimetype = ''
IMPORTING
buffer = lf_xstring. "Hexdecimal format
*.Call Method cl_abap_conv_x2x_ce=>create to convert Hexa decimal string
*.From Source code page to Unicode
lcn_conv_x2x = cl_abap_conv_x2x_ce=>create(
in_encoding = lf_codepage "tried pass UTF-8 as well, but did not work
in_endian = 'L'
out_encoding = '4110'
out_endian = 'B'
input = lf_xstring ).
*.Reset Xstring
lcn_conv_x2x->reset( input = lf_xstring ).
*.Now Convert to Unicode
TRY.
CALL METHOD lcn_conv_x2x->convert_c.
CATCH cx_sy_conversion_codepage cx_sy_codepage_converter_init.
WRITE : / 'Conversion Error'.
EXIT.
ENDTRY.
*.Buffer out Finally
lf_xstring = lcn_conv_x2x->get_out_buffer( ).
ENDIF. "Check in encoding
CALL METHOD lf_client->request->set_data
EXPORTING
data = lf_xstring.
*--- Send
*********************----> I am getting communicatin failure error if there is #%^& characters here
CALL METHOD lf_client->send
EXCEPTIONS
http_communication_failure = 1
OTHERS = 999.
*************************
I tried to add below code at beginning but it works onlly for English data with strange characters but not for other languages.
CALL METHOD cl_http_utility=>escape_url
EXPORTING
unescaped = request
OPTIONS = 1
RECEIVING
escaped = request.
Does anyone has some thoughts to solve this issue,
<< Moderator message - Please do not promise points >>
<< Moderator message - Everyone's problem is important. But the answers in the forum are provided by volunteers. Please do not ask for help quickly. >>
Thanks,
Anil
Edited by: Anil Yedlapalli on Jun 13, 2011 1:42 AM
Edited by: Rob Burbank on Jun 13, 2011 10:05 AM