Application Development and Automation 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: 
Read only

xml to application server

dmi
Participant
0 Likes
772

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

6 REPLIES 6
Read only

dmi
Participant
0 Likes
679

solved by my self

Read only

0 Likes
679

Hi Daniel,

please share your solution, I have the same problem.

Thanks

Read only

dmi
Participant
0 Likes
679

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.

Read only

0 Likes
679

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.

Read only

dmi
Participant
0 Likes
679

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

Read only

0 Likes
679

ok, thanks for the thread.