In the above example we have created a RFC destination and RFC function module, now we need call this function module in our program, see the example program for calling RFC.
To call a RFC function module with a destination we use keyword 'DESTINATION'.
Syntax for calling RFC.
CALL FUNCTION <RFC_FM_NAME> DESTINATION <RFC_DESTINATION>
Example program for calling RFC function module.
Go to SE38, create a program ZSAPN_RFC_CALL, save it in a local object and add below code.
REPORT ZSAPN_RFC_CALL. DATA : WA_MARA TYPE MARA. "MARA work area PARAMETERS P_MATNR TYPE MARA-MATNR. "material no input CALL FUNCTION 'ZSAPN_RFC_FM' DESTINATION 'RFCCLNT810' "calling RFC EXPORTING IM_MATNR = P_MATNR IMPORTING EX_MARA = WA_MARA. **display data WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS.
Program is created, now we need to test the program.
We have done all the above steps in client 800, to test the above program we need a material not exists in 800 client and exited in 810 client, log on to 810 client, get a material from MARA table.
Execute the above program, provide material number (which we got from 810 client) input, execute.