Пример ABAP парсера XML файла следующего вида:
<?xml version="1.0" encoding="windows-1251"?> <MSG FORMAT="SAP_FORMAT" SENDER="SYSTEM1" RECIPIENT="SAP"> <INS CODE="TESTXXXXXX" FROMDATE="25.07.12" LONGNAME="TESTER 25" CUST_NAME="TESTER 25" CITY="ROME" TYPECODE="0" </MSG>
убил на него целый день, на будущее пригодится:
CALL FUNCTION 'F4_FILENAME' EXPORTING field_name = 'P_FILE' IMPORTING file_name = p_file. end of xml_line. xml_tablesize type i, istream type ref to if_ixml_istream. s_file = p_file. CALL FUNCTION 'GUI_UPLOAD' exporting filename = s_file filetype = 'BIN' importing filelength = xml_tablesize data_tab = xml_table exceptions others = 11. g_ixml = cl_ixml=>create( ). streamFactory = g_ixml->create_stream_factory( ). * wrap the table containing the file into a stream istream = streamFactory->create_istream_itable( table = xml_table size = xml_tablesize ). document = g_ixml->create_document( ). parser = g_ixml->create_parser( stream_factory = streamFactory istream = iStream document = document ). str type string, i type i, count type i, index type i. count = parser->num_errors( ). index = 0. parseError = parser->get_error( index = index ). i = parseError->get_line( ). i = parseError->get_column( ). str = parseError->get_reason( ). index = index + 1. attribute type ref to if_ixml_attribute, achild type ref to if_ixml_node. element = document->get_root_element( ). child = element->get_first_child( ). t_str = child->get_name( ). lr_attributenode TYPE REF TO if_ixml_node. lc_value type string. attributes = child->get_attributes( ). lr_nodeiterator = attributes->create_iterator( ). lr_attributenode = lr_nodeiterator->get_next( ). lc_name = lr_attributenode->get_name( ). lc_value = lr_attributenode->get_value( ). lr_attributenode = lr_nodeiterator->get_next( ). child = child->get_next( ).