Process XML attributes of all tables in a structured document

Hi all,
I try to process the XML attributes of all tables in a structured document.
When I use SelectedTbl everything works fine for the selected table and the attributes of the tabelle Element are written correctly to the Console.
doc = app.ActiveDoc;
table = doc.SelectedTbl;
if (table.TblElement)
    Console('Elementname: ' + table.TblElement.ElementDef.Name);
    tblEle = table.Element;
    attrs = tblEle.GetAttributes();
    for (i = 0; i < attrs.len; i++) {
        aName = attrs[i].name;
        aWert = attrs[i].values;
        Console( "     " + aName + "    " + aWert);     
However when I use GetText(Constants.FTI_TblAnchor) to walk through all tables of the documens neither ElementDef.Name nor Attributes are processed.
var flow = doc.FirstFlowInDoc;
var textItems = flow.GetText(Constants.FTI_TblAnchor);
while(iTab<textItems.length) {
table = textItems[iTab].obj;
if (table.TblElement)
    Console('Elementname: ' + table.TblElement.ElementDef.Name);
    tblEle = table.Element;
    attrs = tblEle.GetAttributes();
    for (i = 0; i < attrs.len; i++) {
        aName = attrs[i].name;
        aWert = attrs[i].values;
        Console( "     " + aName + "    " + aWert);     
Any Suggestions?
Yours
Wolfgang

You'll probably want all the tables from the main flow. Try
var flow = doc.MainFlowInDoc;
Kind regards
JoH

Similar Messages

  • Is it possible to update attributes in all tables in a multi entity view

    Hi I have a view based on 4 entities, all of which are a 3 of which are 1 to many relationship with the 4th. The 3 additional entities have 2 or 3 attributes, Id, name, and one entity has a foreign key relating to a different table which I do not care about. The IDs are all updatable in the entity, and none of them are generated from a sequence but are inserted manually, except for the 4th (Master?) which is generated from a sequence.
    I create the view and all the entities are updatable, but in the view when I go to attributes from the other tables, it says updatable never and is grayed out so I cannot change it, even though in the entities tab, it is updatable always.
    So I was wondering if this was possible to do???

    I do not understand really, if it is 2 different tables, it is 2 different primary keys. Why would this even happen? What does it matter if EmployeeID and DepartmentID is both 1??? It just seems that there has to be a simpler way to do this but ok.
    So I go to the AppModule, Java tab and go generate Java class. The original code was
    public ViewObjectImpl getObjektiCRUDView1()
    return (ViewObjectImpl)findViewObject("ObjektiCRUDView1");
    I then copy your code to the best of my limited knowledge and get this
    public ViewObjectImpl getObjektiCRUDView1()
    this.getObjektiCRUDView1().executeEmptyRowSet();
    {Row yourRow = this.getObjektiCRUDView1().createRow();
    this.getObjektiCRUDView1().insertRow(yourRow );
            return (ViewObjectImpl)findViewObject("ObjektiCRUDView1");
    On the first row the getObjektiCRUDView1() is underlined and it says missing method body or declare as abstract.
    I know I did something wrong here but I have no idea what as I am not very good with Java
    Also it is not a jsf page, I create a single jspx page and divided it using the panel splitter so on one side we have an adf table for updating the Objekti database table, and on the other side I have an adf form for updating the Positions table (and later on other tables, I hope to have many forms there)
    Edited by: Dino2dy on Jun 10, 2010 12:02 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to find all tables that are associated with a given domain name.

    I want to find all table, excluding the structures, of a given domain name, say, waers.
    Some of the tables are directly contains the domains while others are related with a data element which is connected to that domain.
    I want to find tables for all two case -either tables connected directly to the domain or connected via data element- and exclude the structures.
    thanks in advance.

    Hi,
    The following thing may help you.
    in se11-> search for tables having names like 'DD*'.
    From this list of tables you can find the required table to get domain, data element nad table name.
    one way of doing it:
    SELECT rollname domname
      FROM dd04l
      INTO CORRESPONDING FIELDS OF TABLE it_tab.
    SELECT rollname tabname
      FROM dd03l
      INTO CORRESPONDING FIELDS OF TABLE it_tab1
      FOR ALL ENTRIES IN it_tab
      WHERE rollname = it_tab-rollname.
    SORT it_tab1.
    DELETE ADJACENT DUPLICATES FROM it_tab1.
    LOOP AT it_tab1 INTO wa_tab.
      MODIFY it_tab FROM wa_tab
      TRANSPORTING tabname
      WHERE rollname = wa_tab-rollname.
    ENDLOOP.
    LOOP AT it_tab INTO wa_tab.
      WRITE:/ wa_tab-domname,
              wa_tab-tabname.
    ENDLOOP.
    Regards,
    Manoj Kumar P

  • Indesign library drag drop looses xml attributes of Table tag

    Hi all,
         I have created a Table with 1 row and 3 coloumns, I have text in all 3 cells. I have attaced xml tags to cell text and after that I have added attibutes to Story tag, Table tag and Text tag.  I have drag this table frame to Indesign library to save it for further use.
         When I tried to drag it back to document the Table tag attributes are missing. This is happening on Indesign CS4 Win and Mac.
    I have saved required information in the xml attributes of table tag and since its attributes are missing after drag from library I am not able to use library of Indesign.
    Is this an issue with Indesign CS4?
    -Rahul Dalvi.

    Hi All,
         I am still waitng for the reply. I have attached 2 files here, first one is the Indesign document 'TableXMLTags.indd' having a tagged table. second one is the Library file 'TableXMLtagLibrary.indl' in which I have draged table from 'TableXMLTags.indd'. When I tried to drag that table from library to any document it just loses attributes of Table tag. Here each tag has 3 attributes attached to it.
    I am using Indesign CS4 on Windows and Macintosh.
    Please let me know if there is any way to avoid tag attribute loss.
    Thanks,
    Rahul Dalvi.

  • How to write XML with attributes to a table in Oracle?

    I tried to find solutions over the internet. Some of the stuff I looked at:https://forums.oracle.com/thread/2182669 http://www.club-oracle.com/forums/how-to-insert-data-from-xml-to-table-t2845/
    In all these cases, the solution considers XML structure with only nodes and child nodes but not attributes. In fact, one of the solutions suggests transforming the XML into a canonical form with only nodes w/o attributes.
    This is a sample of xml structure I am working with:
    Sample XML
    <rep type="P" title="P List"> <as> <a id="3" /> <a id="4" /> </as> </rep>
    I am working with oracle client 11.2 and SQL developer
    My question is: how to write XML data into a table with attributes also as column values, beside the nodes?

    My question is: how to write XML data into a table with attributes also as column values, beside the nodes
    The question you should be asking is : "how do I access attributes in the XPath language?"
    and the answer to that is easily found in any XPath tutorial you may find over the Internet, it is not related to Oracle in particular.
    Short answer : you use an "attribute::" axis before the attribute name, or more commonly a "@", e.g. @type, @id etc.
    Using the method described in the first link, something like this will extract the root attributes :
    SELECT x.*
    FROM XMLTable(
           '/rep'
           passing <xmltype variable/column goes here>
           columns type  varchar2(1)  path '@type'
                 , title varchar2(30) path '@title'
    ) x ;
    For deeper levels, use additional XMLTable calls as described in the mentioned post.

  • Table Names of Processed  XML Messages

    Hi ALL,
    We are facing space problem  in PRD box with one of our client, due to increase in large number of Messages  .
    Our basis tryed to do archiving, but endup with no luck.
    Could any one tell us in which tables processed idoc xml messages will get stored.
    .Any help is highly appreciated.
    Kind Regards,
    Vijay

    Hi,
    you should not delete XI Message directely from database table. Please schedule archive or delete jobs. If you never define which interface should be archived, it could NOT be done afterwards. This is also documented clearly on the help.sap.com. What you could do is delete the old messages to free table space. You could configure now interface which should be archived, in this case the message processed in XI in future could be archvied.
    XI message is actually stored in different tables,
    SXMSPMAST, SXMSPMAST2      XML Message master Table,  contains runtime information on XML messages processed by XI; in this table you can find all the information that is visible in SXMB_MONI.
    SXMSCLUP     XI Message Payload Tabelle
    SXMSCLUR     XI Message Payload Tabelle
    SMPPREL3     this table contains information about interfaces; here you can find information on sender (party, service, interface and namespace) and receiver (party, service, interface and namespace) as well as information on maps (their GUID and name as well as namespace).
    SXMSPFRAWH     Performance Head Data, Audit Log,
    SXMSPFRAWD     Performance Data, Audit Log
    There are could be more tables used to store information about XI messages, as I mentioned don't modify database table by your own risk. You will not get support by SAP, it could cause fatal error.
    regards,
    Hai

  • Extract schema/metadata - names for all tables and attributes

    Hi, I am quite new to Oracle DB (only been doing dev mostly with sqlserver before). Is there a way to extract schema (names for all tables and attributes) for 10g and 11g in application code (either java or .net) or pl/sql?
    Thank you,
    -Tony

    There are built in views that start with DBA_, ALL_, and USER_. All means all the user can see, user means all the user has, and dba means everything, which generally means the same as the others plus an owner. So you can desc user_tables to see what-all that view has, then select columns from the view with ordinary sql. See the doc set for all the views available, interesting ones are ...views, ...objects, ...tab_cols and so forth.
    There are also built in procedures for getting metadata, google for details.
    Many tools have easy GUI's for this too. EM has ways on the administration screen to get to various objects, and then you can show the ddl. Maybe sqldeveloper has something too.

  • XML Processing (XML file data to ABAP internal table).

    Hi,
    I have a an XML file and i need to send the data to internal table. I suppose i have written the program correctly.
    But the transformation program may not be correct.
    So can one please tell me the transformation program c o d e or guide me to write the transformation code. Below are details of XML file and my program.
    XML File
    <?xml version="1.0" encoding="UTF-8" ?>
    - <aeRequestOutputType>
    + <trackingInfo>
    + <JMSHeaders>
    - <ns:__caret_reply_caret_ZBAPI xmlns:ae="http://www.tibco.com/" xsi:type="ns:__caret_reply_caret_ZBAPI_">
    + <RETURN>
    - <T__TRADE__DATA>
    - <item>
      <BUKRS>1111</BUKRS>
      <HKONT>22222</HKONT>
      </item>
    - <item>
      <BUKRS>3333</BUKRS>
      <HKONT>44444</HKONT>
      </item>
      </T__TRADE__DATA>
      </ns:__caret_reply_caret_ZBAPI__TRADE__ACC__DOC__POST_caret_ZBAPI__TRADE__ACC__DOC__POST>
      </aeRequestOutputType>
    My Program
    REPORT  ZTEST13.
    DATA : BEGIN OF itab OCCURS 0,
              f(255) TYPE c,
         END OF itab.
    DATA : t001 TYPE TABLE OF ZTEST_ST_UB. "(structure has few variables like hkont,bukrs)
    DATA: xmlupl TYPE string .
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                       =  'c:\sap_output_xml.txt'
       FILETYPE                        = 'ASC'
      tables
        data_tab                      = itab          .
    LOOP AT itab.
    CONCATENATE xmlupl itab-f INTO xmlupl.
    ENDLOOP.
    CALL TRANSFORMATION ZTEST_ST_UB2
    SOURCE XML xmlupl
    RESULT root = t001.

    Hi,
    use class cl_xml_document and method import_from_file inorder to read the xml file to internal table.
    go trough this [LINK|http://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table] for detial code.
    Regards,
    Shanmugavel chandrasekaran

  • PL/SQL procedure to process XML file

    I am just starting to work on xml, and we are using PL/SQL stored procedures to process xml file. I did find the sample code in the package (family.sql). This sample print out all element names and attributes. My questions are :
    (1) I tried to modify the code to print out the element values (or Node values). Here is the code:
    -- get all elements and values
    nl := xmlparser.getElementsByTagName(doc, '*');
    len := xmlparser.getLength(nl);
    -- loop through elements
    for i in 0..len-1 loop
    n := xmlparser.item(nl, i);
    dbms_output.put_line('NodeName: ' &#0124; &#0124; xmlparser.getNodeName(n) &#0124; &#0124; ' ');
    dbms_output.put_line('NodeValue: ' &#0124; &#0124; xmlparser.getNodeValue(n) &#0124; &#0124; ' ');
    end loop;
    However, it did not print out the values, although it did print out the name. what's wrong with it? how can I get the value?
    (2) I have the following xml file:
    <?xml version="1.0"?>
    <profile>
    <id>1</id>
    <name>Company</name>
    <des>master profile</desc>
    <subprofile>
    <subid>1</subid>
    <subname>group1</subname>
    <subdesc>group profile</subdesc>
    </subprofile>
    </profile>
    now, I'd like to print out all the children of the <subprofile> node, that is <subid>, <subname> and <subdesc>. Here is my code:
    -- get subprofile nodelist
    qnlist := xmlparser.getElementsByTagName(doc, 'subprofile');
    -- get length of the nodelist
    len := xmlparser.getLength(qnlist);
    -- loop through elements
    for i in 0..len-1 loop
    qnode := xmlparser.item(qnlist, i);
    qnnode := xmlparser.getFirstChild(qnode);
    qnchild := xmlparser.getFirstChild(qnnode);
    dbms_output.put_line(xmlparser.getNodeName(qnnode));
    dbms_output.put_line(xmlparser.getNodeValue(qnchild));
    LOOP
    if (xmlparser.isNULL(xmlparser.getNextSibling(qnnode))) then exit;
    END IF;
    qnnode := xmlparser.getNextSibling(qnnode);
    qnchild := xmlparser.getFirstChild(qnnode);
    dbms_output.put_line(xmlparser.getNodeName(qnnode));
    dbms_output.put_line(xmlparser.getNodeValue(qnchild));
    END LOOP;
    end loop;
    when I execute the procedure, I get the following output:
    #text
    I am not sure what's wrong with it. Basically, I didn't know the procedure to traverse the tree since here it's a little different from OO programming. Could someone give a sample code which demonstrate the procedure which can get a specific element's name and values? (for my exapmle, the name and value of the <subname>, or <subid>, <subdesc>).
    Also, is there a way to insert a part of xml file into a DB table? in my case, insert the subprofile into a table. I know the xmlgen package has a procedure to insert a xml file into a table, but not a part of xml. And can I insert a xml file into several tables instead of one table, using xmlgen package?
    looking forward to hearing from you. any suggestion and sample code would be helpful. thank you very much.
    null

    I sloved my first question: to get the Nodevalue, I need to use getFirstChild(n);
    But, I still didn't figure out the second
    problem. Actually, It works when I modified my xml file as following:
    <?xml version="1.0"?>
    <profile>
    <id>1</id>
    <name>Company</name>
    <des>master profile</desc>
    <subprofile><subid>1</subid><subname>group1</subname><subdesc>groupprofile</subdesc></subprofile>
    </profile>
    All the <subprofile>....</subprofile> must be in one line without any return. This is unbelievable! It suppose that xml does not matter new lines. I tested my code, it seems space is fine, but new line. Something must be wrong in my code.
    please give any suggestion. Thanks,
    Yudong
    null

  • Xml data into internal table

    Hi Friends,
    See the followong code which converts xml data into itab.
    *& Report  ZTEST_XML1                                                  *
    REPORT  ZTEST_XML1                              .
    *PURPOSE: This program transfers XML data into SAP internal table format
    *The nodes in DOM can be stored as fields in SAP Internal table
    type pool definitions
    TYPE-POOLS: ixml. "iXML Library Types
    type definitions
    TYPES: BEGIN OF t_xml_line, "Structure for holding XML data
    data(256) TYPE x,
    END OF t_xml_line.
    DATA: l_ixml TYPE REF TO if_ixml,
    l_streamfactory TYPE REF TO if_ixml_stream_factory,
    l_parser TYPE REF TO if_ixml_parser,
    l_istream TYPE REF TO if_ixml_istream,
    l_document TYPE REF TO if_ixml_document,
    l_node TYPE REF TO if_ixml_node,
    l_xmldata TYPE string.
    DATA: l_elem TYPE REF TO if_ixml_element,
    l_root_node TYPE REF TO if_ixml_node,
    l_next_node TYPE REF TO if_ixml_node,
    l_name TYPE string,
    l_iterator TYPE REF TO if_ixml_node_iterator.
    DATA: l_xml_table TYPE TABLE OF t_xml_line, " XML Table of the structure
    *t_xml_line
    l_xml_line TYPE t_xml_line, " Record of structure t_xml_line
    l_xml_table_size TYPE i. " XML table size
    DATA: l_filename TYPE string. " String to hold filename
    data: begin of i_final occurs 0,
          pnumber(20),
          pname(50),
          pdes(70),
          end of i_final.
    PARAMETERS: pa_file TYPE char1024 DEFAULT 'C:\product.xml'.
    Validation of XML file: Only DTD included in XML document is supported
    PARAMETERS: pa_val TYPE char1 AS CHECKBOX.
    start of selection
    START-OF-SELECTION.
    Creating the main iXML factory
    l_ixml = cl_ixml=>create( ).
    Creating a stream factory
    l_streamfactory = l_ixml->create_stream_factory( ).
    PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
    Wrap the table containing the file into a stream.
    l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
    size = l_xml_table_size ).
    Creating a document
    l_document = l_ixml->create_document( ).
    Creating a Parser
    l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
    istream = l_istream
    document = l_document ).
    Validate a document
    IF pa_val = 'X'.
    l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
    ENDIF.
    Parse the stream
    IF l_parser->parse( ) <> 0.
    IF l_parser->num_errors( ) <> 0.
    DATA: parseerror TYPE REF TO if_ixml_parse_error,
    str TYPE string,
    i TYPE i,
    count TYPE i,
    index TYPE i.
    count = l_parser->num_errors( ).
    WRITE: count, ' parse errors have occured:'.
    index = 0.
    WHILE index < count.
    parseerror = l_parser->get_error( index = index ).
    i = parseerror->get_line( ).
    WRITE: 'line: ', i.
    i = parseerror->get_column( ).
    WRITE: 'column: ', i.
    str = parseerror->get_reason( ).
    WRITE: str.
    index = index + 1.
    ENDWHILE.
    ENDIF.
    ENDIF.
    Process the document
    IF l_parser->is_dom_generating( ) EQ 'X'.
    PERFORM process_dom USING l_document.
    ENDIF.
    *& Form get_xml_table
    text
    <--P_L_XML_TABLE_SIZE text
    <--P_L_XML_TABLE text
    FORM get_xml_table CHANGING p_l_xml_table_size
    p_l_xml_table.
    Local variable declarations
    DATA: l_len TYPE i,
    l_len2 TYPE i,
    l_tab TYPE tsfixml,
    l_content TYPE string,
    l_str1 TYPE string,
    c_conv TYPE REF TO cl_abap_conv_in_ce,
    l_itab TYPE TABLE OF string.
    l_filename = pa_file.
    Upload file from the client's workstation
    CALL METHOD cl_gui_frontend_services=>gui_upload
    EXPORTING
    filename = l_filename
    filetype = 'BIN'
    IMPORTING
    filelength = l_xml_table_size
    CHANGING
    data_tab = l_xml_table
    EXCEPTIONS
    OTHERS = 19.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Writing the XML document to the screen
    CLEAR l_str1.
    LOOP AT l_xml_table INTO l_xml_line.
    c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data replacement
    = space ).
    c_conv->read( IMPORTING data = l_content len = l_len ).
    CONCATENATE l_str1 l_content INTO l_str1.
    ENDLOOP.
    l_str1 = l_str1+0(l_xml_table_size).
    SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
    WRITE: /.
    WRITE: /' XML File'.
    WRITE: /.
    LOOP AT l_itab INTO l_str1.
    REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
    l_str1 WITH space.
    WRITE: / l_str1.
    ENDLOOP.
    WRITE: /.
    ENDFORM. " get_xml_table
    *& Form process_dom
    text
    -->P_L_DOCUMENT text
    FORM process_dom USING document TYPE REF TO if_ixml_document.
    DATA: node TYPE REF TO if_ixml_node,
    iterator TYPE REF TO if_ixml_node_iterator,
    nodemap TYPE REF TO if_ixml_named_node_map,
    attr TYPE REF TO if_ixml_node,
    name TYPE string,
    prefix TYPE string,
    value TYPE string,
    indent TYPE i,
    count TYPE i,
    index TYPE i.
    node ?= document.
    CHECK NOT node IS INITIAL.
    ULINE.
    WRITE:/.
    WRITE: /' DOM-TREE'.
    WRITE: /.
    IF node IS INITIAL.
    EXIT.
    ENDIF.
    Create a node iterator
    iterator = node->create_iterator( ).
    Get current node
    node = iterator->get_next( ).
    Loop over all nodes
    WHILE NOT node IS INITIAL.
    indent = node->get_height( ) * 2.
    indent = indent + 20.
    CASE node->get_type( ).
    WHEN if_ixml_node=>co_node_element.
    element node
    name = node->get_name( ).
    nodemap = node->get_attributes( ).
    WRITE: / 'ELEMENT :'.
    WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
    IF NOT nodemap IS INITIAL.
    attributes
    count = nodemap->get_length( ).
    DO count TIMES.
    index = sy-index - 1.
    attr = nodemap->get_item( index ).
    name = attr->get_name( ).
    prefix = attr->get_namespace_prefix( ).
    value = attr->get_value( ).
    WRITE: / 'ATTRIBUTE:'.
    WRITE: AT indent name COLOR COL_HEADING INVERSE, '=',
    value COLOR COL_TOTAL INVERSE.
    ENDDO.
    ENDIF.
    WHEN if_ixml_node=>co_node_text OR
    if_ixml_node=>co_node_cdata_section.
    text node
    value = node->get_value( ).
    WRITE: / 'VALUE :'.
    WRITE: AT indent value COLOR COL_GROUP INVERSE.
    ENDCASE.
    Advance to next node
    node = iterator->get_next( ).
    ENDWHILE.
    *delete adjacent duplicates from  i_final.
    *loop at i_final.
    *write:/ i_final-pnumber,i_final-pname,i_final-pdes.
    *endloop.
    *if not i_final[] is initial.
    *modify ztestproduct from table i_final.
    *endif.
    ENDFORM. " process_dom
    in the above code at line no: 268 there is a method:
    value = node->get_value( ).in which actual data from XML file is coming.
    So the varibale "Value" contains the data.
    see line no: 270:
    WRITE: AT indent value COLOR COL_GROUP INVERSE.
    what ever values i am getting here i want to append to a Internal table ...
    Can any body tell me how to do that?
    i am sure of reward points.

    Hai Ravi
    REPORT abc.
    DATA
    DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
    DATA : BEGIN OF itab OCCURS 0,
    a(100) TYPE c,
    END OF itab.
    DATA: xml_out TYPE string .
    DATA : BEGIN OF upl OCCURS 0,
    f(255) TYPE c,
    END OF upl.
    DATA: xmlupl TYPE string .
    FIRST PHASE
    FIRST PHASE
    FIRST PHASE
    Fetch Data
    SELECT * FROM t001 INTO TABLE t001.
    XML
    CALL TRANSFORMATION ('ID')
    SOURCE tab = t001[]
    RESULT XML xml_out.
    Convert to TABLE
    CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
    EXPORTING
    i_string = xml_out
    i_tabline_length = 100
    TABLES
    et_table = itab.
    Download
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filetype = 'BIN'
    filename = 'd:\xx.xml'
    TABLES
    data_tab = itab.
    SECOND PHASE
    SECOND PHASE
    SECOND PHASE
    BREAK-POINT.
    REFRESH t001.
    CLEAR t001.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'D:\XX.XML'
    filetype = 'BIN'
    TABLES
    data_tab = upl.
    LOOP AT upl.
    CONCATENATE xmlupl upl-f INTO xmlupl.
    ENDLOOP.
    XML
    CALL TRANSFORMATION ('ID')
    SOURCE XML xmlupl
    RESULT tab = t001[].
    Regards
    Sreeni

  • Problem converting data in XML file to internal table data

    Hi all,
    I have a requirement. I need to convert an XML file to internal table data and based on that data do Goods Receipt in SAP.
    With the help of this blog /people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
    I am able to convert the XML file to data in SAP. But this blog will display the output on screen as ELELEMNT = nodename VALUE= value of that node.
    But I donu2019t want in that way, I want to store all the data in XML file in an internal table so that I can make use of those values and do Goods Recipt in SAP.
    Can some one suggest how should I read the data in an internal table.
    Here is my code..what changes should I make?
    *& Report  z_xit_xml_check
      REPORT  z_xit_xml_check.
      TYPE-POOLS: ixml.
      TYPES: BEGIN OF t_xml_line,
              data(256) TYPE x,
            END OF t_xml_line.
      DATA: l_ixml            TYPE REF TO if_ixml,
            l_streamfactory   TYPE REF TO if_ixml_stream_factory,
            l_parser          TYPE REF TO if_ixml_parser,
            l_istream         TYPE REF TO if_ixml_istream,
            l_document        TYPE REF TO if_ixml_document,
            l_node            TYPE REF TO if_ixml_node,
            l_xmldata         TYPE string.
      DATA: l_elem            TYPE REF TO if_ixml_element,
            l_root_node       TYPE REF TO if_ixml_node,
            l_next_node       TYPE REF TO if_ixml_node,
            l_name            TYPE string,
            l_iterator        TYPE REF TO if_ixml_node_iterator.
      DATA: l_xml_table       TYPE TABLE OF t_xml_line,
            l_xml_line        TYPE t_xml_line,
            l_xml_table_size  TYPE i.
      DATA: l_filename        TYPE string.
      PARAMETERS: pa_file TYPE char1024 DEFAULT 'c:\temp\orders_dtd.xml'.
    Validation of XML file: Only DTD included in xml document is supported
      PARAMETERS: pa_val  TYPE char1 AS CHECKBOX.
      START-OF-SELECTION.
      Creating the main iXML factory
        l_ixml = cl_ixml=>create( ).
      Creating a stream factory
        l_streamfactory = l_ixml->create_stream_factory( ).
        PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
      wrap the table containing the file into a stream
        l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
                                                        size  = l_xml_table_size ).
      Creating a document
        l_document = l_ixml->create_document( ).
      Create a Parser
        l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
                                          istream        = l_istream
                                          document       = l_document ).
      Validate a document
        IF pa_val EQ 'X'.
          l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
        ENDIF.
      Parse the stream
        IF l_parser->parse( ) NE 0.
          IF l_parser->num_errors( ) NE 0.
            DATA: parseerror TYPE REF TO if_ixml_parse_error,
                  str        TYPE string,
                  i          TYPE i,
                  count      TYPE i,
                  index      TYPE i.
            count = l_parser->num_errors( ).
            WRITE: count, ' parse errors have occured:'.
            index = 0.
            WHILE index < count.
              parseerror = l_parser->get_error( index = index ).
              i = parseerror->get_line( ).
              WRITE: 'line: ', i.
              i = parseerror->get_column( ).
              WRITE: 'column: ', i.
              str = parseerror->get_reason( ).
              WRITE: str.
              index = index + 1.
            ENDWHILE.
          ENDIF.
        ENDIF.
      Process the document
        IF l_parser->is_dom_generating( ) EQ 'X'.
          PERFORM process_dom USING l_document.
        ENDIF.
    *&      Form  get_xml_table
      FORM get_xml_table CHANGING l_xml_table_size TYPE i
                                  l_xml_table      TYPE STANDARD TABLE.
      Local variable declaration
        DATA: l_len      TYPE i,
              l_len2     TYPE i,
              l_tab      TYPE tsfixml,
              l_content  TYPE string,
              l_str1     TYPE string,
              c_conv     TYPE REF TO cl_abap_conv_in_ce,
              l_itab     TYPE TABLE OF string.
        l_filename = pa_file.
      upload a file from the client's workstation
        CALL METHOD cl_gui_frontend_services=>gui_upload
          EXPORTING
            filename   = l_filename
            filetype   = 'BIN'
          IMPORTING
            filelength = l_xml_table_size
          CHANGING
            data_tab   = l_xml_table
          EXCEPTIONS
            OTHERS     = 19.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      Writing the XML document to the screen
        CLEAR l_str1.
        LOOP AT l_xml_table INTO l_xml_line.
          c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data replacement = space  ).
          c_conv->read( IMPORTING data = l_content len = l_len ).
          CONCATENATE l_str1 l_content INTO l_str1.
        ENDLOOP.
        l_str1 = l_str1+0(l_xml_table_size).
        SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
        WRITE: /.
        WRITE: /' XML File'.
        WRITE: /.
        LOOP AT l_itab INTO l_str1.
          REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
            l_str1 WITH space.
          WRITE: / l_str1.
        ENDLOOP.
        WRITE: /.
      ENDFORM.                    "get_xml_table
    *&      Form  process_dom
      FORM process_dom USING document TYPE REF TO if_ixml_document.
        DATA: node      TYPE REF TO if_ixml_node,
              iterator  TYPE REF TO if_ixml_node_iterator,
              nodemap   TYPE REF TO if_ixml_named_node_map,
              attr      TYPE REF TO if_ixml_node,
              name      TYPE string,
              prefix    TYPE string,
              value     TYPE string,
              indent    TYPE i,
              count     TYPE i,
              index     TYPE i.
        node ?= document.
        CHECK NOT node IS INITIAL.
        ULINE.
        WRITE: /.
        WRITE: /' DOM-TREE'.
        WRITE: /.
        IF node IS INITIAL. EXIT. ENDIF.
      create a node iterator
        iterator  = node->create_iterator( ).
      get current node
        node = iterator->get_next( ).
      loop over all nodes
        WHILE NOT node IS INITIAL.
          indent = node->get_height( ) * 2.
          indent = indent + 20.
          CASE node->get_type( ).
            WHEN if_ixml_node=>co_node_element.
            element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
              WRITE: / 'ELEMENT  :'.
              WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
              IF NOT nodemap IS INITIAL.
              attributes
                count = nodemap->get_length( ).
                DO count TIMES.
                  index  = sy-index - 1.
                  attr   = nodemap->get_item( index ).
                  name   = attr->get_name( ).
                  prefix = attr->get_namespace_prefix( ).
                  value  = attr->get_value( ).
                  WRITE: / 'ATTRIBUTE:'.
                  WRITE: AT indent name  COLOR COL_HEADING INVERSE, '=',
                                   value COLOR COL_TOTAL   INVERSE.
                ENDDO.
              ENDIF.
            WHEN if_ixml_node=>co_node_text OR
                 if_ixml_node=>co_node_cdata_section.
            text node
              value  = node->get_value( ).
              WRITE: / 'VALUE     :'.
              WRITE: AT indent value COLOR COL_GROUP INVERSE.
          ENDCASE.
        advance to next node
          node = iterator->get_next( ).
        ENDWHILE.
      ENDFORM.                    "process_dom
    Any help would be highly apperciated.
    regards,
    Jessica Sam

    Pavel Vera,
    With your example i tries doing the following .....
    I tried  to convert the data of XML file to internal table data. I am collecting the data in internal table to do goos recipt with that data.
    Please find my XML file, ABAP pgm and XSLT pgm . I donu2019t know what I am missing I am not getting any output. I donu2019t know what is wrong please help me with this
    Below is my XML file, My code and XSLT Program. In the below XML file I need to collect Vendor Number, Order Number, and Date tags which occur only once for one XML file.
    I also need to collect the following tags from <Shipmentdetail>
    <Shipmentdetail> has following child nodes and I need to collect them
    TrackingNumber
    Freight
    Weight
    ShipmentDate
    ShipmentMethod
    Need to collect to collect the following tags from <ProductInformation>
    <ProductInformation> has following child nodes and I need to collect them
        LineNumber
        SKUNumber
        OrderedQuantity
        ShippedQuantity
        UOM
    The <Shipmentdetail> and <ProductInformation> are child nodes of <OrderShipment>
    The <Shipmentdetail> occurs only ones but the <ProductInformation> can occur once or many times and will be dynamic and differs depening on the input file.
    My XML file is as follows
    <?xml version="1.0" encoding="iso-8859-1" ?>
    - <ShipmentHeader>
      <AccountID />
    - <OrderShipment>
          <VendorNumber>1000</VendorNumber>
          <OrderNumber>P00009238</OrderNumber>
          <OrderType>Stock</OrderType>
          <Company />
          <Division />
         <Department />
         <Date>20061120</Date>
         <CartonCount>2</CartonCount>
         <ShipAllProducts>No</ShipAllProducts>
    -             <ShipmentDetail>
                      <TrackingNumber>1ZR3W891PG47477811</TrackingNumber>
                      <Freight>000000010000</Freight>
                      <ShipmentDate>20061120</ShipmentDate>
                      <ShipmentMethod>UPS1PS</ShipmentMethod>
                 </ShipmentDetail>
    -            <ProductInformation>
                     <LineNumber>000000001</LineNumber>
                     <SKUNumber>110FR</SKUNumber>
                     <AdvSKUNumber>003 4518</AdvSKUNumber>
                     <SKUID />
                     <OrderedQuantity>00000001000000</OrderedQuantity>
                     <ShippedQuantity>00000001000000</ShippedQuantity>
                     <UOM>EA</UOM>
                     <Factor>1</Factor>
                </ProductInformation>
    -           <ProductInformation>
                    <LineNumber>000000002</LineNumber>
                    <SKUNumber>938EN</SKUNumber>
                    <AdvSKUNumber>001 7294</AdvSKUNumber>
                    <SKUID />
                    <OrderedQuantity>00000000450000</OrderedQuantity>
                    <ShippedQuantity>00000000450000</ShippedQuantity>
                    <UOM>EA</UOM>
                    <Factor>1</Factor>
                </ProductInformation>
    -           <CaseInformation>
                   <LineNumber>000000001</LineNumber>
                   <SKUNumber>110FR</SKUNumber>
                   <AdvSKUNumber>003 4518</AdvSKUNumber>
                   <SKUID />
                   <SSCCNumber>00000001668000002487</SSCCNumber>
                   <CaseQuantity>00000001000000</CaseQuantity>
                   <UOM>EA</UOM>
                   <Factor>1</Factor>
                 </CaseInformation>
                 <CaseInformation>
                   <LineNumber>000000001</LineNumber>
                   <SKUNumber>110FR</SKUNumber>
                   <AdvSKUNumber>003 4518</AdvSKUNumber>
                   <SKUID />
                   <SSCCNumber>00000001668000002487</SSCCNumber>
                   <CaseQuantity>00000001000000</CaseQuantity>
                   <UOM>EA</UOM>
                   <Factor>1</Factor>
                 </CaseInformation>
    -  </OrderShipment>
      </ShipmentHeader>
    My Program
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\temp\test.xml'.
    * This is the structure for the data from the XML file
    TYPES: BEGIN OF ts_shipment,
             VendorNumber(10)     TYPE n,
             OrderNumber(20)      TYPE n,
             OrderType(8)         TYPE c,
             Date(8)              TYPE c,
           END OF ts_shipment.
    TYPES: BEGIN OF ts_shipmentdetail,
             TrackingNumber(30)     TYPE n,
             Freight(12)            TYPE n,
             Weight(14)             TYPE n,
             ShipmentDate(8)        TYPE c,
             ShipmentMethod(8)      TYPE c,
             END OF ts_shipmentdetail.
    TYPES: BEGIN OF ts_productinformation,
             LineNumber(9)          TYPE n,
             SKUNumber(20)          TYPE c,
             OrderedQuantity(14)    TYPE n,
             ShippedQuantity(14)    TYPE n,
             UOM(4)                 TYPE c,
             END OF ts_productinformation.
    * Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048.
    * Table and work ares for the data from the XML file
    DATA: gt_shipment               TYPE STANDARD TABLE OF ts_shipment,
          gs_shipment               TYPE ts_shipment.
    DATA: gt_shipmentdetail         TYPE STANDARD TABLE OF ts_shipmentdetail,
          gs_shipmentdetail         TYPE ts_shipmentdetail.
    DATA: gt_productinformation     TYPE STANDARD TABLE OF ts_productinformation,
          gs_productinformation     TYPE ts_productinformation.
    * Result table that contains references
    * of the internal tables to be filled
    DATA: gt_result_xml TYPE abap_trans_resbind_tab,
          gs_result_xml TYPE abap_trans_resbind.
    * For error handling
    DATA: gs_rif_ex     TYPE REF TO cx_root,
          gs_var_text   TYPE string.
    * Get the XML file from your client
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = gs_file
      CHANGING
        data_tab                = gt_itab
      EXCEPTIONS
        file_open_error         = 1
        file_read_error         = 2
        no_batch                = 3
        gui_refuse_filetransfer = 4
        invalid_type            = 5
        no_authority            = 6
        unknown_error           = 7
        bad_data_format         = 8
        header_not_allowed      = 9
        separator_not_allowed   = 10
        header_too_long         = 11
        unknown_dp_error        = 12
        access_denied           = 13
        dp_out_of_memory        = 14
        disk_full               = 15
        dp_timeout              = 16
        not_supported_by_gui    = 17
        error_no_gui            = 18
        OTHERS                  = 19.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "ISHIPMENT".
    GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
    gs_result_xml-name = 'ISHIPMENT'.
    APPEND gs_result_xml TO gt_result_xml.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "ISHIPDET".
    GET REFERENCE OF gt_shipmentdetail INTO gs_result_xml-value.
    gs_result_xml-name = 'ISHIPDET'.
    APPEND gs_result_xml TO gt_result_xml.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "IPRODDET".
    GET REFERENCE OF gt_productinformation  INTO gs_result_xml-value.
    gs_result_xml-name = 'IPRODDET'.
    APPEND gs_result_xml TO gt_result_xml.
    * Perform the XSLT stylesheet
    TRY.
        CALL TRANSFORMATION z_xml_to_abap3
        SOURCE XML gt_itab
        RESULT (gt_result_xml).
      CATCH cx_root INTO gs_rif_ex.
        gs_var_text = gs_rif_ex->get_text( ).
        MESSAGE gs_var_text TYPE 'E'.
    ENDTRY.
    * Writing the data from file for gt_shipment
    *Collecting the Shipping Data from the XML file to internal table gt_shipment
    *and writing the data to the screen
    LOOP AT gt_shipment INTO gs_shipment.
      WRITE: / 'VendorNumber:', gs_shipment-VendorNumber.
      WRITE: / 'OrderNumber :', gs_shipment-OrderNumber.
      WRITE: / 'OrderType  :', gs_shipment-OrderType.
      WRITE: / 'Date  :',      gs_shipment-Date.
      WRITE : /.
    ENDLOOP. "gt_shipment.
    LOOP AT gt_shipmentdetail INTO gs_shipmentdetail.
      WRITE: / 'TrackingNumber:',     gs_shipmentdetail-TrackingNumber.
      WRITE: / 'Freight :',           gs_shipmentdetail-Freight.
      WRITE: / 'Weight  :',           gs_shipmentdetail-Weight.
      WRITE: / 'ShipmentDate  :',     gs_shipmentdetail-ShipmentDate.
    * WRITE: / 'ShipmentMethod  :'    gs_shipmentdetail-ShipmentMethod
      WRITE : /.
    ENDLOOP. "gt_shipmentdetail.
    LOOP AT gt_productinformation INTO gs_productinformation.
      WRITE: / 'LineNumber:',         gs_productinformation-LineNumber.
      WRITE: / 'SKUNumber :',         gs_productinformation-SKUNumber.
      WRITE: / 'OrderedQuantity  :',  gs_productinformation-OrderedQuantity.
      WRITE: / 'ShippedQuantity  :',  gs_productinformation-ShippedQuantity.
      WRITE: / 'UOM  :',              gs_productinformation-UOM.
      WRITE : /.
    ENDLOOP. "gt_productinformation.
    XSLT Program
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <ISHIPMENT>
              <xsl:apply-templates select="//OrderShipment"/>
            </ISHIPMENT>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="OrderShipment">
        <item>
          <VENDORNUMBER>
            <xsl:value-of select="VendorNumber"/>
          </VENDORNUMBER>
          <ORDERNUMBER>
            <xsl:value-of select="OrderNumber"/>
          </ORDERNUMBER>
          <ORDERTYPE>
            <xsl:value-of select="OrderType"/>
          </ORDERTYPE>
          <DATE>
            <xsl:value-of select="Date"/>
          </DATE>
        </item>
      </xsl:template>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <ISHIPDET>
              <xsl:apply-templates select="//OrderShipment/ShipmentDetail"/>
            </ISHIPDET>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="ShipmentDetail">
        <item>
          <TRACKINGNUMBER>
            <xsl:value-of select="TrackingNumber"/>
          </TRACKINGNUMBER>
          <FREIGHT>
            <xsl:value-of select="Freight"/>
          </FREIGHT>
          <SHIPMENTDATE>
            <xsl:value-of select="ShipmentDate"/>
          </SHIPMENTDATE>
          <SHIPMENTMETHOD>
            <xsl:value-of select="ShipmentMethod"/>
          </SHIPMENTMETHOD>
        </item>
      </xsl:template>
    </xsl:transform> .
    Any help is highly appreciated. If anyone encountered this situation before please let me know where i am going wrong in my XSLT transformation.
    Any Help will be highly apppreciated. Thanks in advance
    Regards,
    Jessica   Sam

  • XML Attributes Created Twice in the XML after Saving in FM

    Hi All,
    I've built a structured application to read and write a custom XML. The file is opened just fine. However, when saving the XML in FM, some XML attributes appear in the XML twice. For example, in the original XML I have the following:
    <object_group doc_name="xxx" parsed_by_sym="false">
    </object_group>
    After I save the XML, it looks like this:
    <object_group doc_name="xxx" parsed_by_sym="false" doc_name="xxx" parsed_by_sym="false">
    </object_group>
    After the XML is saved, FM refuses to re-open it aborting the parsing. If I remove the doubled attributes manually in Notepad, then the XML is opened in FM again.
    Should I define anything in read/write rules? What am I doing wrong?
    I'm using an XSD, which I defined in structapp.fm.
    Thank you very much!

    Alex,
      Without looking at the application and document, I don't have any other ideas. To debug a situation like this, I would try variations such as the following, investigating any change that eliminates the doubled attribute:
    1) If you haven't already, shut your computer down and restart it.
    2) If the application uses a custom client or processing, remove them. If their absence makes a difference, the problem may originate in them.
    3) Simplify the test document as much as possible, probably in several steps. For example, remove all optional attributes and elements. Remove all non-containers (tables, xrefs, graphics, etc.) You may need to change the EDD or schema to create as short a document as you can that fails. The goal is to have a document with just a few elements and only one attribute that fails.
    4) Change the element and attribute names, which shouldn't make a difference, but may be worth testing.
    5) Simplify or eliminate the r/w rules.
    6) Simplify the EDD so that the only defined elements and attributes are the ones that appear in the small sample.
    7) Remove all format rules and autoinsertions from the EDD. The goal is to remove anything that should not be relevant.
    8) Simplify the schema in the same way.
    9) Remove the schema from the application. If doing so eliminates the duplicate, convert the schema to a DTD and see if using a DTD instead of the schema makes a difference.
    10) Make sure your have installed all updates to the version of FM you are using.
    11) If you have access to a different version of FM, see if it behaves the same way.
    Good luck and let us know when you find the problem.
         --Lynne

  • How to process XML into ABAP data?

    Hi,
       I have a string variable which content is a xml file. Then how to extract data from it into corresponding ABAP data objects like internal table or structure?
       Thanks a lot!

    HI Long
    check this code which converts xml to bap internal table using DOM
    REPORT  Z_XML_TO_TABLE.
      TYPE-POOLS: ixml.
      TYPES: BEGIN OF t_xml_line,
              data(256) TYPE x,
            END OF t_xml_line.
      DATA: l_ixml            TYPE REF TO if_ixml,
            l_streamfactory   TYPE REF TO if_ixml_stream_factory,
            l_parser          TYPE REF TO if_ixml_parser,
            l_istream         TYPE REF TO if_ixml_istream,
            l_document        TYPE REF TO if_ixml_document,
            l_node            TYPE REF TO if_ixml_node,
            l_xmldata         TYPE string.
      DATA: l_elem            TYPE REF TO if_ixml_element,
            l_root_node       TYPE REF TO if_ixml_node,
            l_next_node       TYPE REF TO if_ixml_node,
            l_name            TYPE string,
            l_iterator        TYPE REF TO if_ixml_node_iterator.
      DATA: l_xml_table       TYPE TABLE OF t_xml_line,
            l_xml_line        TYPE t_xml_line,
            l_xml_table_size  TYPE i.
      DATA: l_filename        TYPE string.
      PARAMETERS: pa_file TYPE char1024 DEFAULT 'c:\temp\orders_dtd.xml'.
    Validation of XML file: Only DTD included in xml document is supported
      PARAMETERS: pa_val  TYPE char1 AS CHECKBOX.
      START-OF-SELECTION.
      Creating the main iXML factory
        l_ixml = cl_ixml=>create( ).
      Creating a stream factory
        l_streamfactory = l_ixml->create_stream_factory( ).
        PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
      wrap the table containing the file into a stream
        l_istream = l_streamfactory->create_istream_itable( table =
    l_xml_table
                                                        size  =
    l_xml_table_size ).
      Creating a document
        l_document = l_ixml->create_document( ).
      Create a Parser
        l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
                                          istream        = l_istream
                                          document       = l_document ).
      Validate a document
        IF pa_val EQ 'X'.
          l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
        ENDIF.
      Parse the stream
        IF l_parser->parse( ) NE 0.
          IF l_parser->num_errors( ) NE 0.
            DATA: parseerror TYPE REF TO if_ixml_parse_error,
                  str        TYPE string,
                  i          TYPE i,
                  count      TYPE i,
                  index      TYPE i.
            count = l_parser->num_errors( ).
            WRITE: count, ' parse errors have occured:'.
            index = 0.
            WHILE index < count.
              parseerror = l_parser->get_error( index = index ).
              i = parseerror->get_line( ).
              WRITE: 'line: ', i.
              i = parseerror->get_column( ).
              WRITE: 'column: ', i.
              str = parseerror->get_reason( ).
              WRITE: str.
              index = index + 1.
            ENDWHILE.
          ENDIF.
        ENDIF.
      Process the document
        IF l_parser->is_dom_generating( ) EQ 'X'.
          PERFORM process_dom USING l_document.
        ENDIF.
    *&      Form  get_xml_table
      FORM get_xml_table CHANGING l_xml_table_size TYPE i
                                  l_xml_table      TYPE STANDARD TABLE.
      Local variable declaration
        DATA: l_len      TYPE i,
              l_len2     TYPE i,
              l_tab      TYPE tsfixml,
              l_content  TYPE string,
              l_str1     TYPE string,
              c_conv     TYPE REF TO cl_abap_conv_in_ce,
              l_itab     TYPE TABLE OF string.
        l_filename = pa_file.
      upload a file from the client's workstation
        CALL METHOD cl_gui_frontend_services=>gui_upload
          EXPORTING
            filename   = l_filename
            filetype   = 'BIN'
          IMPORTING
            filelength = l_xml_table_size
          CHANGING
            data_tab   = l_xml_table
          EXCEPTIONS
            OTHERS     = 19.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      Writing the XML document to the screen
        CLEAR l_str1.
        LOOP AT l_xml_table INTO l_xml_line.
          c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
    replacement = space  ).
          c_conv->read( IMPORTING data = l_content len = l_len ).
          CONCATENATE l_str1 l_content INTO l_str1.
        ENDLOOP.
        l_str1 = l_str1+0(l_xml_table_size).
        SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
        WRITE: /.
        WRITE: /' XML File'.
        WRITE: /.
        LOOP AT l_itab INTO l_str1.
          REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab
    IN
            l_str1 WITH space.
          WRITE: / l_str1.
        ENDLOOP.
        WRITE: /.
      ENDFORM.                    "get_xml_table
    *&      Form  process_dom
      FORM process_dom USING document TYPE REF TO if_ixml_document.
        DATA: node      TYPE REF TO if_ixml_node,
              iterator  TYPE REF TO if_ixml_node_iterator,
              nodemap   TYPE REF TO if_ixml_named_node_map,
              attr      TYPE REF TO if_ixml_node,
              name      TYPE string,
              prefix    TYPE string,
              value     TYPE string,
              indent    TYPE i,
              count     TYPE i,
              index     TYPE i.
        node ?= document.
        CHECK NOT node IS INITIAL.
        ULINE.
        WRITE: /.
        WRITE: /' DOM-TREE'.
        WRITE: /.
        IF node IS INITIAL. EXIT. ENDIF.
      create a node iterator
        iterator  = node->create_iterator( ).
      get current node
        node = iterator->get_next( ).
      loop over all nodes
        WHILE NOT node IS INITIAL.
          indent = node->get_height( ) * 2.
          indent = indent + 20.
          CASE node->get_type( ).
            WHEN if_ixml_node=>co_node_element.
            element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
              WRITE: / 'ELEMENT  :'.
              WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
              IF NOT nodemap IS INITIAL.
              attributes
                count = nodemap->get_length( ).
                DO count TIMES.
                  index  = sy-index - 1.
                  attr   = nodemap->get_item( index ).
                  name   = attr->get_name( ).
                  prefix = attr->get_namespace_prefix( ).
                  value  = attr->get_value( ).
                  WRITE: / 'ATTRIBUTE:'.
                  WRITE: AT indent name  COLOR COL_HEADING INVERSE, '=',
                                   value COLOR COL_TOTAL   INVERSE.
                ENDDO.
              ENDIF.
            WHEN if_ixml_node=>co_node_text OR
                 if_ixml_node=>co_node_cdata_section.
            text node
              value  = node->get_value( ).
              WRITE: / 'VALUE     :'.
              WRITE: AT indent value COLOR COL_GROUP INVERSE.
          ENDCASE.
        advance to next node
          node = iterator->get_next( ).
        ENDWHILE.
      ENDFORM.                    "process_dom
    regards
    kishore
    reward if helpful

  • To convert XML to ABAP internal table can we do it with DOM or we need XSLT

    I have a requirement where I need to collect the data from XML file into an internal table.
    I need to collect this data into an internal table as I should make use of this data and do Goods Receipt in SAP.
    My XML file is very very complex and the child nodes in my XML file may occur ones or 10 times and change dynamically.
    I want to know if XML to ABAP internal table is possible with DOM or does it need XSLT too.
    I used the blog of Robert which uses DOM, but it I am unable to collect the data in internal table. The blog explains only how to wtite the out put to screen as element and value.
    I want to know if XML to ABAP internal table is possible with DOM or do I need XSLT too? I am confused please help.
    Any help will be highly appreciated.
    Regards,
    Jessica Sam

    Hello Jessica
    Why not using the DOM itself for processing?
    Below you see the post-processing coding which I use to add the interchange control number (ICN) into an EDI message (which at this stage is still an XML-EDI stream). This is done on SAP-XI yet on the ABAP stack so you could use this approach on your R/3 system as well.
    method POSTPROCESSING.
    * Post-Processing of outbound EDI invoices & dispatch advices
      me->map_icn( ).
    endmethod.
    method MAP_ICN.
    * define local data
      DATA: lo_node       TYPE REF TO if_ixml_node,
            ld_name       TYPE string,
            ld_value      TYPE string,
            ld_error_code type MPG_ERRCODE,
    **        ld_control_number   TYPE char13,
            ld_rc         TYPE i,
            ld_msg        TYPE string.  " bapi_msg.
      DATA: ld_interface  TYPE string.
      DATA: incode TYPE REF TO if_ixml_node_collection.
      LOG-POINT ID zedi
        SUBKEY mc_subkey_method_trace.
      ld_error_code = md_clsname.
    * Get next interchange control number (ICN)
      me->md_next_number = me->get_next_number(
          id_nrobj  = me->md_nrobj   " Object (SNRO)
          id_nrnr   = me->md_nrnr ). " Number Range
      CALL METHOD zcl_edi_uk_counter=>calculate_modulo_n09
        EXPORTING
          id_input  = me->md_next_number
        receiving
          rd_output = me->md_next_number.
    * Build ICN according to naming conventions agreed with EDI customer
      me->md_icn = me->generate_icn( me->md_next_number ).
      ld_value = me->md_icn.  " type conversion to string
      CLEAR: incode,
             lo_node.
      incode  = me->mo_document->get_elements_by_tag_name( mc_d_0020 ).
      lo_node = incode->get_item( index = 0 ).
      CALL METHOD lo_node->set_value
        EXPORTING
          value = ld_value
        RECEIVING
          rval  = ld_rc.
      IF ( ld_rc NE 0 ).
        CONCATENATE 'Error [' mc_d_0020
                    ']: Method SET_VALUE (IF_IXML_NODE)'
                    INTO ld_msg.
        CONDENSE ld_msg.
        me->mif_trace->trace2( message = ld_msg ).
        RAISE EXCEPTION TYPE cx_mapping_fault
          EXPORTING
    *        textid =
    *        previous =
            error_code = ld_error_code
            error_text = ld_msg.
    **    MESSAGE ld_msg TYPE 'A'.
      ENDIF.
      CLEAR: incode,
             lo_node.
      incode  = me->mo_document->get_elements_by_tag_name( mc_d_0020_2 ).  " element for ICN
      lo_node = incode->get_item( index = 0 ).
      CALL METHOD lo_node->set_value
        EXPORTING
          value = ld_value
        RECEIVING
          rval  = ld_rc.
      IF ( ld_rc NE 0 ).
        CONCATENATE 'Error [' mc_d_0020_2
                    ']: Method SET_VALUE (IF_IXML_NODE)'
                    INTO ld_msg.
        CONDENSE ld_msg.
        me->mif_trace->trace2( message = ld_msg ).
        RAISE EXCEPTION TYPE cx_mapping_fault
          EXPORTING
    *        textid =
    *        previous =
            error_code = ld_error_code
            error_text = ld_msg.
    **    MESSAGE ld_msg TYPE 'A'.
      ENDIF.
    * define local data
      DATA: ls_record       TYPE mpp_dynamic.
      CLEAR: ls_record.
      ls_record-namespace = mc_dynamic_namespace.
      ls_record-name      = mc_icn.
      ls_record-value     = ld_value.
      mif_dynamic->add_record( ls_record ).
    endmethod.
    In your case you would need to do a DO...ENDDO loop until you parsed all required nodes.
    NOTE: ME->MO_DOCUMENT is of TYPE REF TO IF_IXML_DOCUMENT.
    Regards
       Uwe

  • How to convert xml file into internal table in ABAP Mapping.

    Hi All,
    I am trying with ABAP mapping. I have one scenario in which I'm using below xml file as a sender from my FTP server.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MTO_ABAP_MAPPING xmlns:ns0="http://Capgemini/Mumbai/sarsingh">
      <BookingCode>2KY34R</BookingCode>
    - <Passenger>
      <Name>SARVESH</Name>
      <Address>THANE</Address>
      </Passenger>
    - <Passenger>
      <Name>RAJESH</Name>
      <Address>POWAI</Address>
      </Passenger>
    - <Passenger>
      <Name>CARRON</Name>
      <Address>JUHU</Address>
      </Passenger>
    - <Flight>
      <Date>03/03/07</Date>
      <AirlineID>UA</AirlineID>
      <FlightNumber>125</FlightNumber>
      <From>LAS</From>
      <To>SFO</To>
      </Flight>
      </ns0:MTO_ABAP_MAPPING>
    AT the receiver side I wnat to concatenate the NAME & ADDRESS.
    I tried Robert Eijpe's weblog (/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach)
    but couldnt succeed to convert the xml file into internal table perfectly.
    Can anybody help on this. 
    Thanks in advance!!
    Sarvesh

    Hi Sarvesh,
    The pdf has details of ABAP mapping. The example given almost matches the xml file you want to be converted.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how to use abap-mapping in xi 3.0.pdf
    Just in case you have not seen this
    regards
    Vijaya

Maybe you are looking for

  • Mini-DVI to VGA cable... LCD TV has female input

    I recently bought a mini-DVI to VGA adapter from an Apple store, to connect my MacBook with a broken screen to a UMC LCD TV. When it came to plugging the VGA end into the TV, I realised it has exactly the same connector (female I think) as the TV. Th

  • Need script to export Indesign to word and keep word index codes

    Hi, I have a document and the index was created by importing word docs with indexentries. Now the client wants to revise the book and wants the text converted back to Word, but he wants to keep the orginal word index codes. Is that possible? Exportin

  • Draging tabs to a new position in firefox 14 not working

    Today I noticed I could not drag tabs to a new position (the feature where you can click and hold on a tab, and drag it to a different position on the tab bar, new window, etc.) I have started in safe mode and the issue continued, so it seems unlikel

  • BI content is displayed or not.

    Hi all, I want to know about the status of BI_content. That is whether BI content is deployed in the particular system.How is it possible to see the status of the BI content Regards Vijay

  • How to rename seller name in iTunes connect

    HI, In app Store we see that App Name and exactly below that seller name i.e. the name of individual or company name how to rename this name in itunes store?