on 2024 Jul 28 11:34 PM
There is an error in the XML Writer framework. When used, the XML files are created without an XML declaration. Even if the XML declaration is optional, this leads to incorrect behavior. The XML cannot be viewed as a structure in the debugger because the SAP debugger does not recognize the XML as such. The debugger can´t display an XML that creates an SAP class because an optional parameter is missing. It is not a good solution to simply assign the parameter. We made an example to show the effects:
" make XML with XML declaration
DATA writer_with_declaration TYPE REF TO if_sxml_writer.
DATA xml_with_declaration TYPE string.
writer_with_declaration = CAST if_sxml_writer( cl_sxml_string_writer=>create( encoding = CONV #( 'UTF-8' ) ) ). " <= XML declaration
writer_with_declaration->write_node( writer_with_declaration->new_open_element( name = 'test_tag' ) ) .
writer_with_declaration->write_node( writer_with_declaration->new_close_element( ) ).
DATA(conv_w_decl) = cl_abap_conv_in_ce=>create( input = CAST cl_sxml_string_writer( writer_with_declaration )->get_output( ) encoding = zif_lib_print_serializer=>c_encoding ).
conv_w_decl->read( IMPORTING data = xml_with_declaration ).
" make XML without XML declaration
DATA writer_without_declaration TYPE REF TO if_sxml_writer.
DATA xml_without_declaration TYPE string.
writer_without_declaration = CAST if_sxml_writer( cl_sxml_string_writer=>create( ) ). " <= ** no ** XML declaration
writer_without_declaration->write_node( writer_without_declaration->new_open_element( name = 'test_tag' ) ) .
writer_without_declaration->write_node( writer_without_declaration->new_close_element( ) ).
DATA(conv_wo_decl) = cl_abap_conv_in_ce=>create( input = CAST cl_sxml_string_writer( writer_without_declaration )->get_output( ) encoding = zif_lib_print_serializer=>c_encoding ).
conv_wo_decl->read( IMPORTING data = xml_without_declaration ).
BREAK-POINT.
Request clarification before answering.
Workaround:
CALL TRANSFORMATION id SOURCE XML xml_without_declaration
RESULT XML xml_with_declaration.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Monika,
Development released a solution with SAP BTP ABAP Environment 2502. There are now header options for the sXML Library. These are the options:
You can find more in the documentation: https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABENABAP_SXML_LIB_RENDER.html (hint section).
Best regards,
Lena
Then:
cl_sxml_string_writer=>create( encoding = 'UTF-8' )
That will give you the XML header.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah jetzt ja.
In CL_DEMO_OUTPUT_STREAM=>WRITE_XML we format XML ourselves to achieve this. Maybe Debugger can do the same. I will ask the colleagues.
Using transformation ID adds the <xml>-Tag what would change the debugged content. This is not desirable.
Due to the discussion here, our development has introduced the following enhancements with releases 9.14/2502, 8.16/2025:
Header Options for sXML Library
Header options for the XML declaration are now available in the sXML Library:
But regarding the debugger problem, I don't have any further information yet. You might report it as a customer incident.
User | Count |
---|---|
79 | |
21 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.