Handling function module interfaces in bulk?

1.3k views Asked by At

Is there a way to access the import parameters passed into a function module without addressing them individually? Does ABAP store them in some internal table, so I can work with them by looping through rows in some table, or fields of a structure?

We can use the PATTERN function, knowing only the function module's name, to have ABAP print out the function module's interface for us, so I'm wondering where this information is stored and if I can work with it once the function group has been loaded into memory.

Thanks in advance!

2

There are 2 answers

2
vwegert On BEST ANSWER

You can use the function module RPY_FUNCTIONMODULE_READ to obtain information about the parameter structure of a function module and then access the parameters dynamically. This has several drawbacks - most noticeably, the user doing so will need (additional) S_DEVELOP authorizations, and logging this way will usually impose a serious performance impact.

I'd rather add the function module parameters to the logging/tracing function manually once - with a sufficiently generic method call, it's not that difficult. I also tend to group individual parameters into structures to facilitate later enhancements.

0
Suncatcher On

PARAMETER-TABLE construct exists in ABAP since ancient times, it allows passing params in batch:

One should create two parameter tables of types abap_func_parmbind_tab and abap_func_excpbind_tab and fill them like this:

DATA: ptab TYPE abap_func_parmbind_tab,
      etab TYPE abap_func_excpbind_tab,
      itab TYPE TABLE OF string.

ptab = VALUE #( 
         ( name  = 'FILENAME' kind  = abap_func_exporting value = REF #( 'c:\text.txt' ) )
         ( name  = 'FILETYPE' kind  = abap_func_exporting value = REF #( 'ASC' ) )
         ( name  = 'DATA_TAB' kind  = abap_func_tables    value = REF #( itab ) )
         ( name  = 'FILELENGTH' kind  = abap_func_importing value = REF #( space ) ) ).

etab = VALUE #( ( name = 'OTHERS' value = 10 ) ) .

CALL FUNCTION 'GUI_DOWNLOAD'
  PARAMETER-TABLE ptab
  EXCEPTION-TABLE etab.