10-23-2017 7:44 AM
I am generating xml file from 'CALL TRANSFORMATION' and it is generating with 'UTF-16' encoding method but to transfer this file to FTP server , When i Convert String to XString using 'SCMS_STRING _TO_XSTRING' then this function module converting data in 'UTF-8'and adding a special character in start of string .
I required data in 'UTF-16', So Please help
10-23-2017 8:00 AM
No, SCMS_STRING _TO_XSTRING does not add "a special character in start of string" (I would call it a "BOM" as it's about UTF but here it seems to be a different thing), or is there a bug in a given ABAP release. Which one are you using?
Which transformation are you using? ID or a custom one?
Could you tell again if you want UTF-8 or UTF-16 in your ABAP program? Which encoding or mime type are you using while calling SCMS_STRING_TO_XSTRING?
Moreover, if you generate the file in your abap program with the right target code page, make sure you transfer in BIN mode.
10-23-2017 8:39 AM
(1) I am using below mention code to generate XML.
APPEND WA_XML TO IT_XMLF.
CLEAR WA_XML.
DATA:L_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT.
CALL TRANSFORMATION ('ID')
SOURCE TAB = IT_XMLF[]
RESULT XML XML_OUT.
(2) When i am using below mention code when calling 'SCMS_STRING_TO_XSTRING'
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = xml_out2
* MIMETYPE = ' '
* ENCODING =
IMPORTING
BUFFER = xstring1
* EXCEPTIONS
* FAILED = 1
* OTHERS = 2
.
Here i am not passing mime type and encoding because i required data in UTF-16 and after 'CALL TRANSFORMATION' xml data in UTF-16 also.
For target Page is below mention screen shot.
This issue is coming after GST implementation and before GST this code was working fine.
10-23-2017 3:29 PM
As you use a string variable after RESULT XML, it's automatically encoded in UTF-16 in the string.
SCMS_STRING_TO_XSTRING without mimetype/encoding converts the string variable into an xstring variable in UTF-8 without leading bytes.
You can be sure of that by debugging and displaying the xstring with the Embedded code page converter (enter the code page 4110 for UTF-8).
So, the problem is after SCMS_STRING_TO_XSTRING.
10-24-2017 5:48 AM
I checkd Codepage through Debugging SCMS_STRING_TO_XSTRING which is processing is 4110.
After SCMS_STRING_TO_XSTRING i am using below mention code to transfer file to ftp server.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = xstring1
IMPORTING
output_length = len
TABLES
binary_tab = it_str[].
And after converting XSTRING to Binary i am transferring file to FTP Server.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
HANDLE = W_HDL
FNAME = FILE_NAME1 "file path of destination system
BLOB_LENGTH = len
* CHARACTER_MODE = MODE
TABLES
blob = IT_STR[]
* TEXT = IT_STR[]
** TEXT = lt_xml_table[]
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4.
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
10-24-2017 6:49 AM
I mean, just check the XSTRING1 value after SCMS_STRING_TO_XSTRING, that the "Translation" is equal to your original text:
10-24-2017 7:08 AM
10-24-2017 7:52 AM
Or the issue is about people telling you that the file is wrong. How did they check? Did they copy the file in text mode?
10-24-2017 8:17 AM
10-24-2017 8:52 AM
When i am place the file on ftp server without converting SCMS_STRING_TO_XSTRING and SCMS_XSTRING_TO_BINARY is working fine and data in UTF-16 .Use code is mention below.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILETYPE = 'BIN'
FILENAME = FILENAME"'C:\Users\VINOD\Desktop\ASN'
TABLES
DATA_TAB = IT_STR.
10-24-2017 10:47 AM
I any possibility to change encoding this below mention step.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = xstring1
IMPORTING
output_length = len
TABLES
binary_tab = it_str[].
10-24-2017 12:01 PM
?<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><EDIFACT><UNB><UNB01><UNB0101>UNOB</UNB0101><UNB0102>2</UNB0102></UNB01><UNB02><UNB0201>0000100188</UNB0201></UNB02><UNB03><UNB0301>HMCL</UNB0301></UNB03><UNB04><UNB0401>171014</UNB0401><UNB0402>1141</UNB0402></UNB04><UNB05>1101001772</UNB05><UNB07>INVOIC</UNB07></UNB></EDIFACT>
In this ? is adding in start of file due to which file is not opening
10-24-2017 1:17 PM
Yes, of course it's invalid. Wasn't it the initial question? What did produce that please?
10-24-2017 1:31 PM
I am generating XML file with whole process and below is the output.
?<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><EDIFACT><UNB><UNB01><UNB0101>UNOB</UNB0101><UNB0102>2</UNB0102></UNB01><UNB02><UNB0201>0000100188</UNB0201></UNB02><UNB03><UNB0301>HMCL</UNB0301></UNB03><UNB04><UNB0401>171014</UNB0401><UNB0402>1141</UNB0402></UNB04><UNB05>1101001772</UNB05><UNB07>INVOIC</UNB07></UNB></EDIFACT>
10-24-2017 7:08 PM
Sorry, I can't help anymore as I still don't understand where/when your problem is exactly.
10-23-2017 9:11 AM
Why do you transform to string and not to xstring? Why are you using the undocumented function module SCMS_STRING_TO_XSTRING which is part of a special framework and not the general system method CL_ABAP_CODEPAGE=>CONVERT_TO?
10-24-2017 2:57 PM
Why don't you transform into an object of CL_SXML_STRING_WRITER, created with encoding UTF-16, and get from there an XSTRING?
10-25-2017 8:22 AM
This issue is coming with only one customer but same FMs and program are working properly for different customer.