2004 Oct 20 9:28 PM
Hi,
I am generating an XML file from a custom smartform and saving into a folder in the application server. When the file is written into the application server, the Danish characters are not coming properly. Probaly this is a issue related to the codepage that the XML file is using. I am using the following technique to write the XSF data returned by the Smartform auto generated funciton module into the application server. The generated xml file starts with something like <?xml version="1.0"?> and it seems that the encoding header attribute is missing somehow and I dont know how to put it.
data wa type bin1024.
data length type i.
DATA dsn(50) VALUE '/tmp/test.xml' .
length = P_OUTPUT-XSFLENGTH.
OPEN DATASET dsn FOR OUTPUT IN BINARY MODE.
loop at P_OUTPUT-XSFDATA into wa.
if length > 1024.
transfer wa to dsn.
length = length - 1024.
else.
transfer wa to dsn length length.
endif.
endloop.
close dataset dsn.</i>
I am desperately trying to find out a solution to this. It would be nice of you if I can get a quick solution.
Thanks in advance
Nilay Ghosh
2004 Oct 20 9:39 PM
Hi Nilay,
You logic seems does not downloading the data completely.You get the length of P_OUTPUT outside the loop, then loop at P_OUTPUT-XSFDATA to download to the application server. Within the loop if length is > than 1024, you reduce length by 1024. But you are not downloading the rest of the text in each line of P_OUTPUT-ZSFDATA.
This could be resulted to some of your xml text got chopped off.
2004 Oct 20 10:09 PM
Hi Nablan,
Thanks for your quick reply. The raw XSF data is stored in the P_OUTPUT-XSFDATA as multiple lines of 1024 bytes. Actually I have slighly changed the logic for transfering the XML data into the file and following is the latest one.
**************************
DATA: l_last TYPE i,
l_len TYPE i,
l_sytabix TYPE int4.
l_len = 1024.
l_sytabix = l_xmlsize DIV l_len.
l_sytabix = l_sytabix + 1.
l_last = l_xmlsize MOD l_len.
**************************
Open the file in the appl server
OPEN DATASET l_xml_filename FOR OUTPUT IN BINARY MODE.
IF sy-subrc = 0.
it_xsfdata[] = p_it_output_data_xmloutput-xsfdata[].
LOOP AT it_xsfdata INTO wa_xsfdata.
IF sy-tabix = l_sytabix .
TRANSFER wa_xsfdata TO l_xml_filename LENGTH l_last .
ELSE.
TRANSFER wa_xsfdata TO l_xml_filename .
ENDIF.
CLEAR: l_data,wa_xsfdata.
ENDLOOP.
REFRESH it_xsfdata .
CLEAR: it_output_data,p_it_output_data_xmloutput.
ELSE.
MESSAGE i000 WITH text-007.
LEAVE LIST-PROCESSING.
ENDIF.
CLOSE DATASET l_xml_filename.
But it has basically nothing to do with the code page because I am getting a complete XML file which I can successfully open in the browser after downloading it into my local machine. There are certain options with OPEN DATASET command for setting codepage etc. but I was unable to use them successfully.