‎2008 Sep 02 6:02 PM
Hello!
Until now I generated XML data with the FM 'SDIXML_DOM_TO_XML'.
After that I did a loop over the xml_as_table in which I was casting each line of that table to a string.
ASSIGN <line> TO <line_c> CASTING.After the inftroduction of unicode in our system I get a error:
--
In the current program an error occured when setting the field symbol <LINE_C> with ASSIGN or ASSIGNING (maybe in combination with the CASTING addition).
When converting the base entry of the field symbol <LINE_C> (number in base table: 32776), it was found that the target type requests a memory alignment of 2
--
What does it mean? Does somebody have a solution.
I need this function for sending this XML data as string over a simple old CPIC connection.
Best regards
Martin
‎2008 Sep 02 11:42 PM
Hello Martin
Perhaps my sample report ZUS_SDN_XML_XSTRING_TO_STRING provides a solution for your problem.
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_XML_XSTRING_TO_STRING
*&
*&---------------------------------------------------------------------*
*& Thread: Converting hexadecimal XML data to a string
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1029652"></a>
*&---------------------------------------------------------------------*
REPORT zus_sdn_xml_xstring_to_string.
*-- data
*-- read the XML document from the frontend machine
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA: xml_table TYPE TABLE OF xml_line.
DATA: go_xml_doc TYPE REF TO cl_xml_document,
gd_xml_string TYPE string,
gd_rc TYPE i.
PARAMETERS:
p_file TYPE localfile DEFAULT 'C:payload_idoc.xml'.
START-OF-SELECTION.
CREATE OBJECT go_xml_doc.
" Load XML file from PC and get XML itab
CALL METHOD go_xml_doc->import_from_file
EXPORTING
filename = p_file
RECEIVING
retcode = gd_rc.
CALL METHOD go_xml_doc->get_as_table
IMPORTING
table = xml_table
* size =
* retcode =
.
" NOTE: simulate creation of XML itab
go_xml_doc->display( ).
create object go_xml_doc.
CALL METHOD go_xml_doc->parse_table
EXPORTING
table = xml_table
* size = 0
receiving
retcode = gd_rc.
CALL METHOD go_xml_doc->render_2_string
* EXPORTING
* pretty_print = 'X'
IMPORTING
retcode = gd_rc
stream = gd_xml_string
* size =
.
write: / gd_xml_string.
END-OF-SELECTION.
Regards
Uwe
‎2008 Sep 03 8:58 AM
Hello Uwe,
I just used the last part of your example coding and it works. Thanks!
Here is my ready code snipplet:
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
document = m_document
pretty_print = 'X'
IMPORTING
xml_as_string = w_string
size = w_size
TABLES
xml_as_table = it_xml
EXCEPTIONS
no_document = 1
OTHERS = 2.
IF sy-subrc = 0.
* WRITE 'ok'.
ELSE.
WRITE: 'Err =', sy-subrc.
ENDIF.
create object go_xml_doc.
CALL METHOD go_xml_doc->parse_table
EXPORTING
table = it_xml
* size = 0
receiving
retcode = gd_rc.
CALL METHOD go_xml_doc->render_2_string
* EXPORTING
* pretty_print = 'X'
IMPORTING
retcode = gd_rc
stream = gd_xml_string
* size =
.Now the string variable gd_xml_string contains the XML stream which I'm able to split into a table.
SPLIT gd_xml_string AT CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO TABLE write_table IN CHARACTER MODE.Each line of the table is now send over CPIC and it works.
Best regards
Martin
‎2008 Sep 03 9:14 AM
Hello Martin
If you want to retrieve the XML stream as itab then you could use another method:
CALL METHOD go_xml_doc->render_2_table
* EXPORTING
* pretty_print = 'X'
IMPORTING
retcode = gd_rc
table = write_table
* size =
.
Regards
Uwe