‎2011 Apr 02 3:22 PM
Hello
I create with a transfomation a xstring
and with the fm SCMS_XSTRING_TO_BINARY I create a table.
This table I can download by fm gui_download and I can open the file
with a xml-editor - it works.
But if I do the same, but download to the application server, there is an error,
I cant open the xml-file.
I'm looping throught the table what fm SCMS_XSTRING_TO_BINARY give me back
For each loop I call TRANSFER TO dataset
I can see, the last record is filled out with 0 (Hex 00)
I think this is the problem - by dowload with fm GUI_DOWNLOAD, I can set the file lenght,
but by download to the application server I can't
Thanks for any help
Daniel
‎2011 Apr 03 11:54 AM
‎2014 Jun 16 8:55 PM
Hi Daniel,
please share your solution, I have the same problem.
Thanks
‎2014 Jun 17 4:50 AM
Hello Daniele
Here my solution:
*** open file ***
open dataset le_filename for output in binary mode.
*** create binary table from xstring
call function 'SCMS_XSTRING_TO_BINARY'
exporting
buffer = ie_data
importing
output_length = le_filesize
tables
binary_tab = lt_content.
*** write data ***
loop at lt_content assigning <ls_data>.
*--- first remove all null bytes
le_xml = <ls_data>.
le_null_string = cl_abap_conv_in_ce=>uccp( '0000' ).
replace all occurrences of le_null_string in le_xml
with le_empty_string
in byte mode.
*--- transfer data
transfer le_xml to le_filename.
endloop.
*** close file ***
close dataset le_filename.
‎2014 Jun 17 8:11 AM
Hi Daniel and thank you in advance for availability.
The code is good for me ... to do something like this:
lv_null_string = cl_abap_conv_in_ce => UCCP ('0000 ').
LOOP AT lt_stream ASSIGNING <fs>.
IF sy-tabix = lines (lt_stream). "only the last row must not be absolutely length
FIND FIRST OCCURRENCE OF lv_null_string IN <fs>
IN BYTE MODE MATCH OFFSET lv_null_length.
TRANSFER <fs> TO e_filename LENGTH lv_null_length.
ELSE.
TRANSFER <fs> TO e_filename.
ENDIF.
ENDLOOP.
CLOSE DATASET e_filename.
What do you think?
Then I need your opinion, yesterday I turned the file, which was initially in BINARY MODE, in TEXT MODE, using:
* Before the function
CALL FUNCTION 'SCMS_BINARY_TO_STRING'
EXPORTING
input_length = lv_length
IMPORTING
text_buffer = lv_xml_string
TABLES
binary_tab = lt_stream
* And then writing
OPEN DATASET FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
TRANSFER lv_xml_string TO e_filename.
CLOSE DATASET e_filename.
Do you think this workaround will produce an equally correct file of XML or is it more correct (formally) write a binary file?
I ask this because I don't understand why we are the only ones to have this kind of problem around ... there is no other case in SCN.
‎2014 Jun 17 11:40 AM
Hi Daniele
When the result is ok, and you can open the file as xml in the correct way, all is good.
Just my opinon, I am prefer a binary file.
You are not alone, I was before you
I have the experience, that I'm looking around for a half year and nothing be found, and the next month you can find 10 entries.......
Have a nice day
Daniel
‎2014 Jun 17 12:09 PM