Application Development 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: 

How to Call a Function Module Dynamically

former_member376453
Contributor
0 Kudos

Hi,

Can any one plz tell me the way to call a function Module dynamically. And any way out to find whether a FM has called dynamically or not.

Thanks,

3 REPLIES 3

andreas_mann3
Active Contributor
0 Kudos

try:

DATA: BEGIN OF TKOMP OCCURS 5,
        FUNCTION LIKE TRWPR-FUNCTION,
      END OF TKOMP.

       LOOP AT TKOMP.
         CALL FUNCTION   TKOMP-FUNCTION
              EXPORTING  BLTXT            = PA_BLTXT
                         GJAHR            = PA_GSJHR
                         KOKRS            = X-KOKRS
                      PERAB            = T_PLZ-PERAB       " n. 168475
                      PERBI            = T_PLZ-PERBI       " n. 168475
                         UPDATE_VALUES    = 'X'
                         DELTA            = L_DELTA
                         COMMIT           = ' '
                         VERSN            = PA_VERSI
                         VRGNG            = 'RKP1'
                         MESSAGES_SHOW    = ' '
                         IRKU01_CUR       = RKU01_CUR
                         TESTMODE         = PA_TESTL           "n.525131
              TABLES     IRKU01JA         = HLP_RKU01JA
              EXCEPTIONS OTHERS           = 04.
         IF PA_TESTL EQ SPACE.                                "msg
            PERFORM ABEND_WHEN_POSTING_ERROR.                 "msg
         ENDIF.                                               "msg
       ENDLOOP.
     ENDIF.

  ENDDO.

  ENDLOOP.                                                 " n. 168475

A.

Message was edited by:

Andreas Mann

Former Member
0 Kudos

HI,

instead of call function 'function_module'.

data:var(30) value 'function_module'.

and <b>call function var</b>.

this will be supported only when the importing,exporting,changing,tables parameters of the function modules match.other wise u should not use this type of calling.

rgds,

bharat.

Former Member
0 Kudos

Based on your different scenarios, store the name of function module in a variable.

Call function <var>

But here you must be sure about the interface of the function module and required to pass the mandatory fields while calling function module.

Sy-subrc check will let you know whether the function call is successful of not.