Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

internal table to xml , pass xml through RFC module

Former Member
0 Likes
667

Hi,

I want to pass an xml through my rfc. This code below will convert table to xml.

But I can't get it working to push the xml_tab into xml_output.

I've tried to create a structure like this in SE11 :

BEGIN OF xml_tab OCCURS 0,

d LIKE LINE OF xml,

END OF xml_tab.

My purpose is just to pass a xml that is based on a internal table via RFC module. So I can work with it later on.

Any idea's?

Kind regards,

Jonas

FUNCTION Z_RETURN_PROJECTS.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(OUTPUT) TYPE  RLGRAP-FILENAME OPTIONAL
*"  EXPORTING
*"     VALUE(XML_OUTPUT) TYPE  ?????????
*"----------------------------------------------------------------------

DATA : itab_project TYPE STANDARD TABLE OF zprojects.


  REFRESH itab_project.
  CLEAR itab_project.

  SELECT * FROM zprojects INTO CORRESPONDING FIELDS OF TABLE itab_project.


  DATA: l_dom TYPE REF TO if_ixml_element,
                m_document TYPE REF TO if_ixml_document,
                g_ixml TYPE REF TO if_ixml,
                w_string TYPE xstring,
                w_size TYPE i,
                w_result TYPE i,
                w_line TYPE string,
                it_xml TYPE dcxmllines,
                s_xml LIKE LINE OF it_xml,
                w_rc LIKE sy-subrc.

  DATA: xml TYPE dcxmllines.
  DATA: rc TYPE sy-subrc,
  BEGIN OF xml_tab OCCURS 0,
                d LIKE LINE OF xml,
  END OF xml_tab.

  CLASS cl_ixml DEFINITION LOAD.
  g_ixml = cl_ixml=>create( ).
  CHECK NOT g_ixml IS INITIAL.
  m_document = g_ixml->create_document( ).
  CHECK NOT m_document IS INITIAL.
  WRITE: / 'Converting DATA TO DOM 1:'.
  CALL FUNCTION 'SDIXML_DATA_TO_DOM'
    EXPORTING
      name         = 'PROJECTS'
      dataobject   = itab_project[]
    IMPORTING
      data_as_dom  = l_dom
    CHANGING
      document     = m_document
    EXCEPTIONS
      illegal_name = 1
      OTHERS       = 2.
  IF sy-subrc = 0.
    WRITE 'Ok'.
  ELSE.
    WRITE: 'Err =',
    sy-subrc.
  ENDIF.
  CHECK NOT l_dom IS INITIAL.
  w_rc = m_document->append_child( new_child = l_dom ).
  IF w_rc IS INITIAL.
    WRITE 'Ok'.
  ELSE.
    WRITE: 'Err =',
    w_rc.
  ENDIF.
  CALL FUNCTION 'SDIXML_DOM_TO_XML'
    EXPORTING
      document      = m_document
    IMPORTING
      xml_as_string = w_string
      size          = w_size
    TABLES
      xml_as_table  = it_xml
    EXCEPTIONS
      no_document   = 1
      OTHERS        = 2.
  IF sy-subrc = 0.
    WRITE 'Ok'.
  ELSE.
    WRITE: 'Err =',
    sy-subrc.
  ENDIF.

  LOOP AT it_xml INTO xml_tab-d.
    APPEND xml_tab.
  ENDLOOP.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> i want to pass the xml_tab 


  CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      bin_filesize = w_size
      filename     = output
      filetype     = 'BIN'
    TABLES
      data_tab     = xml_tab
    EXCEPTIONS
      OTHERS       = 10.




  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


ENDFUNCTION.

Edited by: Jonas Vanderkelen on Nov 19, 2009 10:19 AM

2 REPLIES 2
Read only

former_member194669
Active Contributor
0 Likes
427

May be you need to convert the XML to XSTRING then you can pass the XSTRING to RFC please check fm SCMS_STRING_TO_XSTRING and its paramters

a®

Read only

Former Member
0 Likes
427

Hi,

I tried that but i have a long X typed variable it is not the same as xstring. Anyway to convert these two?

kind regards

Jonas

Because function SCMS_XSTRING_TO_BINARY wants an xstring typed import parameter.