Application Development and Automation 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: 
Read only

Dynamic call to Function module.

Former Member
0 Likes
459

Hi

In one of the program, we have found a FM ' rfc_update_taxes_doc', and which does not has any code,

but what i think that this Fm is called dynamically from some prog and is calling external system.

As it has 'targt server' in importing parameters.

So can anybody tell me if this is the way we call to External system.

And please if anyone can tell me the real meaning of calling a Fm dynamically.

Please dont provide links.

Thanks and Regards

Manu

2 REPLIES 2
Read only

naimesh_patel
Active Contributor
0 Likes
379

Use the DESTINATION addition of the CALL FUNCTION statement.

Press F1 on the CALL FUNCTION and get the online help

Regards

Naimesh Patel

Read only

Former Member
0 Likes
379

Hi Manu,

You can try with this example. I connect Bussiness system with R/3 system, because I need R/3 table in Bw system.

IF SY-SYSID EQ 'BWD'. "SYSID = Name sap system

    D_DESTINATION = 'DESD47020'.

  ELSEIF SY-SYSID EQ 'BWC'.

    D_DESTINATION = 'DESW47420'.

  ELSEIF SY-SYSID EQ 'BWP'.

    D_DESTINATION = 'DESP47420'.

  ENDIF.


  CAMPOS-FIELDNAME = 'MANDT'.
  CAMPOS-OFFSET = '000000'.
  CAMPOS-LENGTH = '000003'.
  CAMPOS-FIELDTEXT = 'Mandant'.
  APPEND CAMPOS.
  CLEAR CAMPOS.
  CAMPOS-FIELDNAME = 'BUKRS'.
  CAMPOS-OFFSET = '000004'.
  CAMPOS-LENGTH = '000004'.
  CAMPOS-FIELDTEXT = 'Society'.
  APPEND CAMPOS.
  CLEAR CAMPOS.

  CALL FUNCTION 'RFC_READ_TABLE' DESTINATION D_DESTINATION
    EXPORTING
      QUERY_TABLE                = 'TZBZ'
*   DELIMITER                  = ' '
*   NO_DATA                    = ' '
*   ROWSKIPS                   = 0
*   ROWCOUNT                   = 0
    TABLES
      OPTIONS                    = OPTIONS1
      FIELDS                     = CAMPOS
      DATA                       = DATOS
* EXCEPTIONS
*   TABLE_NOT_AVAILABLE        = 1
*   TABLE_WITHOUT_DATA         = 2
*   OPTION_NOT_VALID           = 3
*   FIELD_NOT_VALID            = 4
*   NOT_AUTHORIZED             = 5
*   DATA_BUFFER_EXCEEDED       = 6
*   OTHERS                     = 7

That's all.

About the real meaning of calling a FM dynamically could be something like that because

you can generate the call dynamically to just call with the needed parameters (you can change

the parameters).

types: begin of s_codigo,

Lines type string,

End of s_codigo.

Data: it_codigo type standard table of s_codigo with header line.

APPEND 'Title.' TO it_codigo.

APPEND 'form Calculate_sum.' TO it_codigo.

APPEND 'call function ''RFC FUNCTION ''' TO it_codigo.

APPEND 'destination ''D_DESTINATION''' TO it_codigo.

APPEND 'exporting PARAM1 = ''2''' TO it_codigo.

APPEND 'PARAM2 = IT_TABLE ' TO it_codigo.

APPEND 'importing PARAM_I1 = RESULT.' TO it_codigo.

APPEND 'endform.' TO it_codigo.

DATA prog_name LIKE sy-cprog.

DATA resultado(1) TYPE c.

GENERATE SUBROUTINE POOL it_codigo NAME prog_name.

PERFORM Calculate_sum IN PROGRAM (prog_name) CHANGING nok.

Best regards .

Ana