TRFC (Transactional RFC):
Syntax for TRFC:
call function <remote function>
in background task
destination <rfc destination>
[exporting parameters].
It is recommended to call only those F.M's in TRFC Mode which doesn't return
any value.
In case of TRFC call, the remote server need not be available at the time of
communication. In this case, if the remote server is not available at the time of
communication, the request is stored in the db tables 'ARFCSSTATE' and
'ARFCSDATA'of the calling system (RFC Client).
After this, SAP schedules the program 'RSARFCSE' in the background which is
executed for every 15 minutes for 20/30 attempts for processing the request.
Within these attempts, if the remote server is not available, a fresh request needs
to send.
Whenever a remote function is called in TRFC mode, we need to provide the
statement 'commit work' as part of calling program, so that the request is stored
in the above db tables. We can check the execution status of TRFC using 'SM58'.
TRFC Steps:
RFC server (EHP7)
1. Consider/create a db table
DB Table: ZCUSTOMERS
Fields:
Kunnr kunnr char 10
Name1 name1_gp char 35
Ort01 ort01_gp char 35
2. Consider/create a function group (zrfcgrp)
3. Create a remote function module(ZINSERTCUSTOMER)
import:
i_customer type zcustomers passbyval
source code :
insert zcustomers from i_customer.
RFC client (EHP5):
1. Consider/create a RFC destination (RFCDESTEHP7)
2. Create an executable program to call the remote function in TRFC mode
Executable program name --> ZCALLTRFC
REPORT ZCALLTRFC.
types : begin of ty_customer,
f1(10) type c,
f2(35) type c,
f3(35) type c,
end of ty_customer.
data wa_customer type ty_customer.
wa_customer-f1 = '0000000101'.
wa_customer-f2 = 'Kiran'.
wa_customer-f3 = 'Mumbai'.
call function 'ZINSERTCUSTOMER'
in background task
DESTINATION 'RFCDESTEHP7'
exporting
i_customer = wa_customer.
commit work.
write :/ 'End of RFC client program'.
Note: Before executing the above RFC client program, Switch off the Remote SAP
Server (EHP7) and then execute, SAP schedules a program ‘RSARFCSE’ in the
background as a background job which gets executed every 15 minutes to check
whether remote SAP server is switched on for processing the request. Following is
the status of Background job after successful execution. Check the status of the
background job using SM37.
Job log:
Check the entry in RFC server (EHP7): DB table ‘ZCUSTOMERS’