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

function module parameter

former_member184611
Active Participant
0 Likes
4,382

Hi all,

I want to extract the parameters for a given function module. I found this FM RPY_FUNCTIONMODULE_READ_NEW is useful for that. But I want the parameter attributes in more detail, like whether the parameter is table or structure or variable. If structure, its components, component's dictionary type, etc. I want to know, is there any other function modules or methods, that return the parameters of FM in detail.

1 ACCEPTED SOLUTION
Read only

RicardoRomero_1
Active Contributor
0 Likes
2,862

Hi,

Check this thread:

you can use FM FUNCTION_IMPORT_INTERFACE.

11 REPLIES 11
Read only

Former Member
0 Likes
2,862

if the type has a '-' in it that means its for a structure or a table else its a data element.

now if '-' is there then pass the first part of it to dd02L. and pick the table category

TRANSP Transparent table

INTTAB Structure

please search a bit, we posted 3 threads for the same requirement today

Read only

RicardoRomero_1
Active Contributor
0 Likes
2,863

Hi,

Check this thread:

you can use FM FUNCTION_IMPORT_INTERFACE.

Read only

0 Likes
2,862

hi ricardo,

that link was really useful.. i found RFC_GET_FUNCTION_INTERFACE_US very useful. Still have some problems. The changing, exporting parameters may contain, structures, tables, variables. Need to differentiate between that .

Thank you

Read only

0 Likes
2,862

Hi,

You can find the type in table TADIR, searching by field OBJ_NAME. Here you have the field OBJECT that indicates the object type. Or as said Soumyaprakash in table DD02L.

If it's a table or a structure you can find all its components in table DD03L.

Hope this help you.

Read only

0 Likes
2,862

The changing, exporting parameters may contain, structures, tables, variables. Need to differentiate between that .

aby,

that was the sole suppose of me telling you about DD02L

Read only

0 Likes
2,862

Hello ,

You will have to use the FM 'RFC_GET_STRUCTURE_DEFINITION' in conjunction with the FM RFC_GET_FUNCTION_INTERFACE_US to get the desired details.

Regards,

Rajesh

Read only

0 Likes
2,862

hi ricardo,

Finding all the components and their technical details, that I have already done using the help of RTTS classes. But the issue is, since the FM return only the structure type, i am not able to find dynamically whether its a structure or internal table. In my requirement the output table should mention whether its a structure or internal table.

Thank you

Read only

0 Likes
2,862

the out of RFC_GET_FUNCTION_INTERFACE_US is like this

PARAMCLASS I ==> i means import, E is export, T is table..

PARAMETER WAIT

TABNAME BAPITA

FIELDNAME WAIT

so a combination of paramclass and tabname can help you determine if its a table or a structure

if I or E and a tabname is not a 'table type' then its a structure

if I or E and a tabname is a 'table type' then its a table

if T then its a table

Read only

0 Likes
2,862

hi soumyaprakash,

for example, if the iput is BAPI_PO_CREATE...

In input parameter it has a structure po_header type BAPIEKKOC

and in Tables po_item type BAPIEKPOC.

Like that in changing and exporting parameter there could be tables and structures. Then how would i find whether that is a internal table or structure?

Thanks

Read only

0 Likes
2,862

I will give you an example

P PARAMETER                      TABNAME
I PO_HEADER                      BAPIEKKOC     ==> PO_HEADER will be a structure as BAPIEKKOC  is not in DD40L(so its not a table type)
E PURCHASEORDER                  BAPIEKKOC  ==> same as above
T PO_ITEMS                       BAPIEKPOC        ==>po_item is a internal table 
T RETURN                         BAPIRETURN        ==> return is a internal table  

Read only

0 Likes
2,862

hi Soumyaprakash,

Thanks for your great help. Your method is ok. In my case, I have to loop the changing and export parameter table. So if I use your method I have to write the SELECT statements inside the loop, which I feel not as an optimized way. Instead, I have tried another way using the help of RTTI Classes and found helpful. Below am adding the sample code.

DATA: lo_tabledescr TYPE REF TO cl_abap_tabledescr,
      lo_structdescr TYPE REF TO cl_abap_structdescr,
      lo_elemdescr TYPE REF TO cl_abap_elemdescr,
      lv_linetypename  TYPE string,
      t_tabdescr      TYPE abap_compdescr_tab.


CALL FUNCTION 'RPY_FUNCTIONMODULE_READ_NEW'
  EXPORTING
    functionname       = 'BAPI_PO_CREATE'
  TABLES
    import_parameter   = t_imp_para
    changing_parameter = t_cha_para
    export_parameter   = t_exp_para
    tables_parameter   = t_tab_para
    exception_list     = t_exc_list
    documentation      = t_docu
    SOURCE             = t_source.


LOOP AT t_cha_para INTO x_cha_para.

  TRY.
**If this try is success then it is a table type. If its fails it goes to next TRY for Structure type.

**Note: To create a table in Changing Parameter, the type should be a dictionary table type.

      lo_tabledescr   ?= cl_abap_typedescr=>describe_by_name( x_cha_para-dbfield ).
      lo_structdescr  ?= lo_tabledescr->get_table_line_type( ).
      lv_linetypename = lo_structdescr->get_relative_name( ).
      lo_structdescr ?= cl_abap_typedescr=>describe_by_name( lv_linetypename ).
       t_tabdescr[]  =  lo_structdescr->components[].


    CATCH cx_root.

      TRY.
**If this try is success then it is a structure type.

          lo_structdescr ?= cl_abap_typedescr=>describe_by_data( x_cha_para-dbfield ).
           t_tabdescr[] = lo_structdescr->components[].

        CATCH cx_root.
**If both the above TRY throws exception, it means its a variable.

          lo_elemdescr ?= cl_abap_typedescr=>describe_by_name( x_cha_para-dbfield ).

      ENDTRY.

  ENDTRY.
ENDLOOP.

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

There may be other solution for this requirement. Since my issue is solved, am closing this thread. Thanks all for your great support.