CALL FUNCTION ... DESTINATION

CALL FUNCTION


1. The same as with
CALL FUNCTION func
2. ... EXCEPTIONS syst_except = rc MESSAGE mess

Effect

Executes the function module from an external source (as a Remote Function Call or RFC); dest can be a literal or a variable.
Depending on the specified destination, the function module is executed in another R/3 or R/2 System. Externally callable function modules must be flagged as such in the Function Builder (of the target system).
Since each destination defines its own program context, further calls to the same or different function modules with the same destination can access the local memory (global data) of these function modules.

To maintain existing destinations, choose
Tools -> Administration, Administration -> Network -> RFC destinations.


When you pass data to an externally called function module, there are some differences to the normal function module call:

Note

If an error occurs in the target system, the details are passed to the calling system (SY-MSGNO, SY-MSGID, SY-MSGTY and SY-MSGV*).


You can call external function modules from C programs. It is also possible to store function modules in a C program and call them with CALL FUNCTION ... DESTINATION . For this purpose, SAP provides a C interface.


If the instance profile parameter 'auth/rfc_authority_check' is set (to 1), the system automatically performs an RFC authorization check. The authorization check refers to the relevant function group for the function module to be called. If no authorization is found, a runtime error occurs. You can check the authorization in advance with the function module AUTHORITY_CHECK_RFC.

Note

Note that there is a database commit after every Remote Function Call (RFC). Consequently, you may not use RFCs between SQL statements that open and close a database cursor (example: SELECT...ENDSELECT).

Effect

Function module calls with the addition DESTINATION can handle two special system exceptions:

SYSTEM_FAILURE

This is triggered if a system crash occurs on the receiving side.

COMMUNICATION_FAILURE

This is triggered if there is a connection or communication problem.

In both cases, you can use the optional addition

... MESSAGE mess

to receive a description of the error.

Note

In principle, you should always handle these two system exceptions when the function module is called.

DATA: INFO LIKE RFCSI, "Importing parameter 
	MSG_TEXT(80) TYPE C. "Message text 
... 
* Synchronous call to function module RFC_SYSTEM_INFO 
 
 CALL FUNCTION 'RFC_SYSTEM_INFO' 
   DESTINATION 'NONE' 
   IMPORTING 
	 RFCSI_EXPORT = INFO 
   EXCEPTIONS 
	 COMMUNICATION_FAILURE = 1 MESSAGE MSG_TEXT 
	 SYSTEM_FAILURE		= 2 MESSAGE MSG_TEXT. 
 
 IF SY-SUBRC NE 0. 
	WRITE: MSG_TEXT. 
 ELSE. 
   WRITE: 'O.K.'. 
 ENDIF. 
...

0) Valid security key but incorrect logon data.

1) Calling system is not a Trusted System or

security key is invalid.

2) User either has no RFC authorization (authorization

object S_RFCACL), or you tried to log on using

one of the protected users 'DDIC' or 'SAP*'.

3) The timestamp of the logon data is invalid.