Skip to Content
author's profile photo
Former Member

Abap to XML

Subject: Abap to XML

hi.

i try to use the command CALL TRANSFORMATION id in order to move abap data to XML file.

the XML file had been created without the data.

please advise me.

here is some of the code:

g_ixml = cl_ixml=>create( ).

g_stream_factory = g_ixml->create_stream_factory( ).

  • ABAP to XML

REFRESH restab.

resstream =

g_stream_factory->create_ostream_itable

( table = restab ).

CALL TRANSFORMATION id

SOURCE source = reserch_details_tbl

RESULT XML resstream.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • May 04, 2004 at 03:23 PM

    hi ronan.

    the coding seems to be correct. But what's the type of RESTAB? Only "flat" tables are supported, tables of STRING or tables of XSTRING are not supported.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      The following (untested) logic might get you on the right track. It's not exactly the structure you were after (I omitted the ProcessHRDataSAP node) but it should be enough to get you going.

      ==================

        DATA:
          lo_xml                   TYPE REF TO cl_xml_document,
          lo_xml_child             TYPE REF TO cl_xml_document,
          lo_node                  TYPE REF TO if_ixml_node,
          lv_name                  TYPE string,
          lv_retcode               TYPE sysubrc,
          lt_data                  TYPE typ_xml_tab,
          lv_data                  LIKE LINE OF lt_data.
      
      * Create the XML document
        CREATE OBJECT lo_xml.
      
        lv_data = '<Request></Request>'.
        APPEND lv_data TO lt_data.
      
        CALL METHOD lo_xml->create_with_table
          EXPORTING
            table   = lt_data
          RECEIVING
            retcode = lv_retcode.
      
        IF lv_retcode NE 0.
      *   Unexpected return code...
        ENDIF.
      
        CALL METHOD lo_xml->get_first_node
          RECEIVING
            node = lo_node.
      
        IF lo_node IS INITIAL.
      *   Unexpected outcome...
        ENDIF.
      
        CREATE OBJECT lo_xml_child.
      
        CALL METHOD lo_xml_child->create_with_data
          EXPORTING
            name       = 'HumanResources'
            dataobject = << Human Resources Internal Table >>
          RECEIVING
            retcode    = lv_retcode.
      
        IF lv_retcode NE 0.
      *   Unexpected return code...
        ENDIF.
      
        CALL METHOD lo_xml->insert_document_as_child
          EXPORTING
            node        = lo_node
            document    = lo_xml_child
          RECEIVING
            retcode     = lv_retcode.
      
        FREE lo_xml_child.
      
        IF lv_retcode NE 0.
      *   Unexpected return code...
        ENDIF.
      
        CREATE OBJECT lo_xml_child.
      
        CALL METHOD lo_xml_child->create_with_data
          EXPORTING
            name       = 'OrganizationStructure'
            dataobject = << Org Structure Internal Table >>
          RECEIVING
            retcode    = lv_retcode.
      
        CALL METHOD lo_xml->insert_document_as_child
          EXPORTING
            node        = lo_node
            document    = lo_xml_child
          RECEIVING
            retcode     = lv_retcode.
      
        FREE lo_xml_child.
      
        IF lv_retcode NE 0.
      *   Unexpected return code...
        ENDIF.
      
      * CALL METHOD lo_xml->export_to_file...