Skip to Content
0
Oct 06, 2009 at 09:56 AM

Problem in coverting XML data to Interal Table.

131 Views

Hello,

I have to write an application which converts an Internal Table Data to XML String and then from XML String to an Internal Table.

The reason for doing is that I am using an RFC Function module and the internal table is dynamically generated one.

But somehow the XML data is not getting converted to Internal Table.

The RFC returns Internal Table Data as XML and the Field Catalogue table

Now in the application which calls RFC, I am trying to convert XML data to a dynamic Internal table

CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
  CALL FUNCTION 'SCMS_BINARY_TO_STRING'
.

Now convert XML String to Internal table

Using FMs 'SCMS_STRING_TO_XSTRING'

"Now XString to Binary

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

CALL FUNCTION 'TEXT_CONVERT_XML_TO_SAP'
    EXPORTING
      i_tab_raw_data             = lt_xml_data
      i_totalsize                = lv_file_size
    TABLES
      i_tab_converted_data       = <fst_dyn_table>
   EXCEPTIONS
     conversion_failed          = 1
     OTHERS                     = 2

In the FM 'TEXT_CONVERT_XML_TO_SAP' I am getting error Conversion failed.

Now I tried with transformations.

Here also my table is a dynamically created Internal table.

TRY.
      CALL TRANSFORMATION ('ID')
       SOURCE root = lt_zmt_tdm_fmap
          RESULT XML lv_output_str.

    CATCH cx_root INTO gs_rif_ex.

      gs_var_text = gs_rif_ex->get_text( ).
      MESSAGE gs_var_text TYPE 'I'.
  ENDTRY.

Now the lv_output_str gets populated with data

But when I call Transformation again to convert XML to internal table, it does not throw error, but does not return any data also.

TRY.
      CALL TRANSFORMATION ('ID')
      SOURCE XML = lv_output_str
      RESULT ref = <fst_dyn_table> .
    CATCH cx_root INTO gs_rif_ex.

      gs_var_text = gs_rif_ex->get_text( ).
      MESSAGE gs_var_text TYPE 'I'.
  ENDTRY.

How can this be resolved.

As pointed I am using RFC Function module, the parameters will be

1) XML String with Internal table data

2) Field Catalogue for Internal Table to be created dynamically.

Regards,

Vikas