Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem by using type ABAP_METHDESCR_TAB in class CL_ABAP_OBJECTDESCR

Attribute METHODS of class CL_ABAP_OBJECTDESCR is type to ABAP_METHDESCR_TAB, now we want to create one import parameter in FM to use this associated type.

But in SE37, system error show, the type ABAP_METHDESCR_TAB is unknown when created parameter.

So why this happen? and if we want to create a parameter by using this type, how can we realize? thanks for your kind hlep.!!

Former Member
Former Member replied

Hello

You did not mention that your function module is RFC-enabled. Since ABAP_METHDESCR_TAB is a <b>complex </b>itab this cannot be used as RFC parameter.

However, there is a very simple trick available: transform your complex itab into an <b>XML string</b>!!!

The following two function module show you how to achieve this:

FUNCTION zus_sdn_abap_type .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(ID_CLSNAME) TYPE  SEOCLSNAME DEFAULT 'CL_GUI_ALV_GRID'
*"  EXPORTING
*"     VALUE(ET_METHODS) TYPE  ABAP_METHDESCR_TAB
*"----------------------------------------------------------------------

" NOTE: type-pool abap defined in TOP include

* define local data
  DATA:
    ld_xml_string       TYPE string.


* initialization
  REFRESH: et_methods.


" Call RFC function module
  CALL FUNCTION 'ZUS_SDN_ABAP_TYPE_RFC'
    DESTINATION 'NONE'
    EXPORTING
      id_clsname     = id_clsname
    IMPORTING
      ed_xml_methods = ld_xml_string.


" Re-tranfrom XML to complex itab !!!
  CALL TRANSFORMATION id
    SOURCE XML ld_xml_string
    RESULT itab = et_methods.

ENDFUNCTION.

FUNCTION zus_sdn_abap_type_rfc .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(ID_CLSNAME) TYPE  SEOCLSNAME
*"  EXPORTING
*"     VALUE(ED_XML_METHODS) TYPE  STRING
*"----------------------------------------------------------------------

* define local data
  DATA:
    lo_typedescr    TYPE REF TO cl_abap_typedescr,
    lo_objdescr     TYPE REF TO cl_abap_objectdescr.


* initialization
  CLEAR: ed_xml_methods.

  CALL METHOD cl_abap_objectdescr=>describe_by_name
    EXPORTING
      p_name         = id_clsname
    RECEIVING
      p_descr_ref    = lo_typedescr
    EXCEPTIONS
      type_not_found = 1
      OTHERS         = 2.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  lo_objdescr ?= lo_typedescr.  " casting


" XML transformation for RFC !!!
  CALL TRANSFORMATION id
    SOURCE itab = lo_objdescr->methods
    RESULT XML ed_xml_methods.

ENDFUNCTION.

Regards

Uwe

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question