2013 Jun 27 11:44 PM
Hello all
I have an XML file that was read from a ZIP file by cl_abap_zip class. When I try to use FM SCMS_XSTRING_TO_BINARY in order to use this XML I see that it is being cut, and XML becomes wrong formed. I´d appreciate if anyone knows how to find out an answer of this.
This is part of what I´m doing;
CALL METHOD l_o_zip->get
EXPORTING
name = le_arch-name
IMPORTING
content = l_output_x
EXCEPTIONS
zip_index_error = 1
zip_decompression_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = l_output_x
IMPORTING
output_length = size
TABLES
binary_tab = lt_content.
but the content of "lt_content" if the file is an XML, the file is being corrupted.
Any ideas??
Regards
2013 Jun 28 1:02 AM
Hi,
Have you tried with CALL TRANSFORMATION 'ID' which will help you transform your XML. Check the link:
http://help.sap.com/abapdocu_731/en/abenasxml_id_vs_st_abexa.htm
Cheers,
Arindam
2013 Jun 28 5:06 AM
Hi Gabriel,
I have your whole situation simulated in my system. I am using an .XML file in a .ZIP file.
Your variable IT_CONTENT has to be declared as XSTRING. if you double click and view it in Tabular form, you will see everything.
Then After that, you need to convert to binary then; binary to text.
Binary has to be 1024 characters long.
And the text will be 2048 character long.
I am able to see my own simulated program's result; whole string out from IT_CONTENT, and even the last outcome of .XML.
Actually, your problem can be easily solved, if you followed the link below:
http://scn.sap.com/thread/116815
Regards,
William
2013 Jun 28 9:41 PM
Hello William,
I fact that link is very usefull, i had it before, thanks. My issue is that I have to attach to a transaction via Generic Object Services by calling
CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
folder_id = ls_fol_id
object_type = l_cte_ext
object_hd_change = ls_obj_data
IMPORTING
object_id = ls_obj_id
TABLES
objhead = lt_objhead
objcont = it_content
EXCEPTIONS
active_user_not_exist = 35
folder_not_exist = 6
object_type_not_exist = 17
owner_not_exist = 22
parameter_error = 23
OTHERS = 1000.
and it_content is table type SOLI.
My problem is it_content has a different abap type. If I attach for example a PDF file with the method Im using it works ok, but with XML the file is being corrupted.
any remmarks will be appreciated.
What im trying to do is to move the file to this FM in order to attach.
2013 Jul 01 7:17 AM
Have you try retaining IT_CONTENT as type "Binary" then attach it to the function module?
2013 Jun 28 5:04 AM
2013 Jun 28 5:37 AM
see the following example:
DATA : data_line TYPE REF TO data,
ixml TYPE xstring, xml TYPE string,
izip TYPE REF TO cl_abap_zip,
zip_file TYPE xstring,
binary_tab TYPE STANDARD TABLE OF solisti1, "x255
lwa_data TYPE x_t_data,
lt_splice_entries TYPE TABLE OF x_splice_entry,
lwa_splice_entries TYPE x_splice_entry,
l_filename TYPE string,
input_length TYPE i,
lv_index TYPE sytabix,
lwa_file TYPE x_t_data.
DATA : filesize TYPE i.
FIELD-SYMBOLS :<gt_data> TYPE table,
<wa> TYPE ANY.
CREATE OBJECT izip.
DATA: lt_data TYPE TABLE OF solisti1," x255,
ls_data LIKE LINE OF lt_data.
break developer.
**Download to XML File(s)
LOOP AT i_data INTO lwa_data.
CLEAR : data_line,zip_file,binary_tab[],ixml,xml.
UNASSIGN : <gt_data>,<wa>.
ASSIGN lwa_data-data->* TO <gt_data>.
CREATE DATA data_line LIKE LINE OF <gt_data>.
ASSIGN data_line->* TO <wa>.
**Create the XML Transformation
CALL TRANSFORMATION id SOURCE <wa> = <gt_data>
RESULT XML ixml.
izip->add( name = lwa_data-xmlfile content = ixml ).
ENDLOOP.
*Create a new zip file
zip_file = izip->save( ).
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = zip_file
IMPORTING
output_length = filesize
TABLES
binary_tab = binary_tab.
*filesize = 7487295.
*
cl_gui_frontend_services=>gui_download(
EXPORTING
bin_filesize = filesize
filename = p_path
filetype = 'BIN'
APPEND = 'X'
CHANGING
data_tab = binary_tab
). "i_tab2 ).
IF sy-subrc NE 0.
RAISE file_not_created.
ENDIF.