1
votes

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
Do you want to examine the interface or call the function module with dynamic parameters?vwegert
I'd like to work with the parameters passed into the function module, without addressing them one by one. Say, passing them off to a subroutine within the FM would be nice to be able to do without referring to them individually. Does that make sense?Greg Day
Reason why...? In our environment SAP functionality is being accessed via RFC by our SOA applications -- it becomes useful to return the values of import parameters along with the FM's actual output for validation/debugging purposes. I find myself creating subroutines to do this, and passing them all the parameters that were provided to the FM. I guess I'm just being lazy/looking for a better way. I appreciate you looking at my question!Greg Day

2 Answers

2
votes

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
votes

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.