1

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!

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Greg Day
  • 13
  • 5
  • Do you want to examine the interface or call the function module with dynamic parameters? – vwegert Dec 30 '16 at 18:30
  • 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 Dec 30 '16 at 18:32
  • 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 Dec 30 '16 at 18:41

2 Answers2

2

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.

vwegert
  • 18,371
  • 3
  • 37
  • 55
  • I also found this class CL_FB_FUNCTION_UTILITY that has a method METH_GET_INTERFACE that will get all the parameters and their datatypes. – Greg Day Dec 30 '16 at 22:58
  • Just be aware that some utility classes and functions that belong to non-SAP_BASIS software components may not be available in all systems. – vwegert Dec 31 '16 at 08:59
0

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.
Suncatcher
  • 10,355
  • 10
  • 52
  • 90