Accessing import parameters passed to a function module in SAP ABAP

ABAP provides several approaches to access import parameters passed to a function module dynamically. This capability is essential when you need to inspect or process function module parameters at runtime without knowing their structure beforehand.

Using RPY_FUNCTIONMODULE_READ Function Module

ABAP has a function module named RPY_FUNCTIONMODULE_READ which lets you extract metadata about the function module. To be more precise, it lets you extract the parameter structure of function module and once you know the parameters then you can access them dynamically. But it comes at a cost ? if you need to accomplish it, you should have S_DEVELOP authorization permissions and it will be a performance intensive operation.

Example

Here's how to use RPY_FUNCTIONMODULE_READ to access function module parameters ?

DATA: lt_import TYPE TABLE OF rsimp,
      ls_import TYPE rsimp.

CALL FUNCTION 'RPY_FUNCTIONMODULE_READ'
  EXPORTING
    functionname           = 'YOUR_FUNCTION_MODULE'
  TABLES
    import_parameter       = lt_import
  EXCEPTIONS
    cancelled              = 1
    not_found              = 2
    permission_failure     = 3.

LOOP AT lt_import INTO ls_import.
  WRITE: / 'Parameter:', ls_import-parameter,
         / 'Type:', ls_import-typ,
         / 'Reference:', ls_import-dbfield.
ENDLOOP.

Using CL_FB_FUNCTION_UTILITY Class

In addition to this, ABAP has a utility class CL_FB_FUNCTION_UTILITY which has various methods. One of them is METH_GET_INTERFACE which lets you extract parameters and corresponding data types of the function module.

Example

Using the utility class method to retrieve function interface ?

DATA: lo_utility TYPE REF TO cl_fb_function_utility,
      lt_interface TYPE funct_int_tab,
      ls_interface TYPE funct_int.

CREATE OBJECT lo_utility.

CALL METHOD lo_utility->meth_get_interface
  EXPORTING
    iv_funcname = 'YOUR_FUNCTION_MODULE'
  IMPORTING
    et_interface = lt_interface.

LOOP AT lt_interface INTO ls_interface WHERE kind = 'I'. "Import parameters
  WRITE: / 'Parameter:', ls_interface-pname,
         / 'Data Type:', ls_interface-type.
ENDLOOP.

Manual Tracing Alternative

Another way around will be to add tracing or logging to function parameters manually. This approach involves explicitly capturing parameter values within the function module code itself, which provides better performance but requires code modifications.

Conclusion

You can choose either of these approaches as per your convenience and applicability, considering the trade-offs between authorization requirements, performance impact, and implementation complexity.

Updated on: 2026-03-13T18:07:11+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements