Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
STALANKI
Active Contributor
0 Kudos


I find irresistible to demonstrate the exercise using XI “WebService” since the utility is useful to any XI developers across the globe. But unfortunately I don’t have access for installing the SAP developer Netweaver studio that implies I cannot demonstrate the exercise using a “WebService”. After all XI developers who are familiar SAP NW studio can use this piece and implement it as webservice.


“Why the heck I need to create all the 50 fields of BSEG Table in the XI editor? Is there any one around who is smarter enough to solve the problem with a different solution?” –SDN forum.


This is very common scenario when either the outbound or inbound interface is BAPI/RFC.

Ex: File - RFC scenario.

I need to create a file structure that is in line with the RFC structure. This is very common when we deal with any SAP systems on one end.
Yes. There are ways out. With WAS > 6.0 we can convert any ABAP structures to XSD format.



Existing Solutions:




1.Blog from Michal:[ XI: Importing an R/3 structure or table into Repository not possible? | The specified item was not found.]


Gaps:




1.Michal showed really a nice way but we need to manually export table structure and moreover we should have Microsoft SQL Server experience to work with it.
2.XI developer would not even have had a chance to look at sanjay’s article as it is posted as an article and a minor draw back is that we need to execute the report and the output is displayed on a XML editor, which has to be then downloaded manually.
I was successful in finding out the function group SDIXML during my R & D process. ‘R & D’ turned to be “Re-Search” option the moment I found out the article whilst googling the documentation for SDIXML FM :).Otherwise I would not have even known that the article is existent. Not many XI developers are friendly with reports and ABAP XML editors.


Proposed Solutions (by Me):




The article is upgraded as an RFC (It is a report originally) and some new API’s are used for exporting the R/3 structures as XSD-String Format instead of transferring the raw data into a ABAP XML Editor.


Code Sample: RFC Z_CONVERT_ABAPTABLE_TO_XSD takes the table name I_ABAP_TABLE_NAME and target name space I_XI_NAMESPACE and exports XSD E_XSD in string format.Create the RFC and try it any SAP system with WAS > 6.0 and bounce back in the XI forum for any errors.




FUNCTION Z_CONVERT_ABAPTABLE_TO_XSD.

*"----


""Local Interface:

*"  IMPORTING

*"     VALUE(I_ABAP_TABLE_NAME) TYPE  DCXMLTYPNM-TABNAME

*"     VALUE(I_XI_NAMESPACE) TYPE  DCXMLSCHCL-TARGETNS

*"  EXPORTING

*"     VALUE(E_XSD) TYPE  STRING

*"----


************DATA DECLARATION***********************

  DATA ls_control TYPE dcxmlddscl.

  DATA ls_elements TYPE dcxmlelems.

  DATA: document TYPE REF TO if_ixml_document.

  DATA ls_types TYPE dcxmltypns.

  DATA ls_dcxmltypnm TYPE dcxmltypnm.

  DATA xsd TYPE xstring.

  DATA xml_schema TYPE REF TO if_ixml_element.

  DATA lv_rc TYPE sy-subrc.

  DATA ls_schema_control TYPE    dcxmlschcl.

  FIELD-SYMBOLS  TYPE REF TO if_ixml_element.

*********************************************************

***********Feed the Header information for forming XSD****

  ls_control-langu = sy-langu.

  ls_control-atom_text = ls_control-stru_text

                       = ls_control-ttyp_text

                       = ls_control-num1extr = 'X'.

  .

  ls_control-xsdnsp = 'xsd'.

  ls_control-targetns = i_xi_namespace.

*************ABAP Table Name that has to be converted*****

  ls_dcxmltypnm-tabname = i_abap_table_name.

************************************************************

  APPEND ls_dcxmltypnm TO ls_types.

  MOVE-CORRESPONDING ls_control TO ls_schema_control.

********************Create Schema Object*********************

  CALL FUNCTION 'SDIXML_SCHEMA_CREATE'

    EXPORTING

      control        = ls_schema_control

    IMPORTING

      schema         = xml_schema

    CHANGING

      document       = document

    EXCEPTIONS

      internal_error = 1

      OTHERS         = 2.

***************Convert ABAP Table to schema elements************

  CALL FUNCTION 'SDIXML_DDIC_TO_SCHEMA'

    EXPORTING

      control        = ls_control

    IMPORTING

      elements       = ls_elements

    CHANGING

      types          = ls_types

      document       = document

    EXCEPTIONS

      internal_error = 1

      OTHERS         = 2.

****************Add XML schema instance*************************

  CALL METHOD document->append_child

    EXPORTING

      new_child = xml_schema

    RECEIVING

      rval      = lv_rc.

  CHECK lv_rc = 0.

**************ADD xsd types to XML schema************************

  LOOP AT ls_elements ASSIGNING

        RECEIVING

          rval      = lv_rc.

      IF lv_rc NE 0. EXIT. ENDIF.

    ENDIF.

  ENDLOOP.

*************Convert XSD document to XSTRING*****************

  CALL FUNCTION 'SDIXML_DOM_TO_XML'

    EXPORTING

      document      = document

      pretty_print  = 'X'

    IMPORTING

      xml_as_string = xsd.

***********Convert XSTRING TO STRING****************************

  CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'

    EXPORTING

      im_xstring  = xsd

      im_encoding = 'UTF-8'

    IMPORTING

      ex_string   = e_xsd.

ENDFUNCTION.




2 cents to anyone who will develops it as a Web Service-RFC scenario with a clearly defined interface and publish it in the UDDI registry.I wish to do that but unfortunately couldn't.

8 Comments