SYNCHRONOUS R F C:
With synchronous RFC, processing stops in the calling program until the called remote function is processed and its output is returned. Then in the calling program, the processing continues after the call.
The statement CALL FUNCTION ... DESTINATION enables you to call remote ABAP function modules or C routines in external server programs.
When you call a function in this way, always include handling for the standard exceptions COMMUNICATION_FAILURE and SYSTEM_FAILURE.
The exception COMMUNICATION_FAILURE is resolved by the system if the specified destination in the sideinfo table RFCDES is not maintained, or if the connection to the remote system cannot be established.
The exception SYSTEM_FAILURE is resolved if the function module or C routine that you want to start in the remote system is not available.
The connection to a remote destination remains intact for as long as the context of the calling program remains active. The function groups addressed in the remote destination remain active for as long as the calling program itself remains active (this is the same as with local calls). This means that if you call two function modules from the same function group one after the other, they can both access the same global data of the function group.
Each function module called using synchronous RFC forms its own logical unit of work (LUW) (exception:
You can debug function modules called remotely in R/3 - R/3 connections.
If a remotely-called function module uses dialogs (for example, CALL SCREEN,
CALL TRANSACTION or lists), they are executed in the session of the caller (and are fully functional).
Note that RFC dialogs in background processing lead to a program termination with the exception SYSTEM_FAILURE (but you can use RFC within background processing).
ASYNCHRONOUS RFC :
In an asynchronous Remote Function Call, the called remote function is started and then continues processing on its own immediately in the calling program. Remote function processing is separate from the calling program. The function output can be received later in the program.
Asynchronous RFC is intended for parallel processing of processes.
With the addition STARTING NEW TASK you can call a remote function module asynchronously. You can use any task name.
The function module that you call is executed in its own work process.
You can also use aRFC in background processing. Note, however, that even here, each aRFC call occupies a dialog work process.
In the sideinfo table RFCDES, you can set the number of aRFC calls for each destination using the aRFC options. After these aRFC calls an automatic load check is performed on the target server. If resource bottlenecks are detected, the system waits for a short time for the next aRFC call,
meant for the same remote system, and the client program is rolled out of its work process. It can then receive results from previous aRFC calls.
During the call, you may not specify an IMPORTING addition since the call does not wait for the end of the function module. Here, you can only handle the two system exceptions, COMMUNICATION_FAILURE and SYSTEM_FAILURE for the same reason. The function module output must be received and the function module-specific exceptions must be handled later on in a different place. (See following slides)
Receiving the function module output and handling the function module-specific exceptions are optional, however.
A program can receive output (parameters and exceptions) from a function module that is running asynchronously.
To implement this, when you call use the addition "PERFORMING ON END OF TASK", where the specified subroutine must exist in your program, and through which the output of the function module is received using command "RECEIVE RESULTS FROM FUNCTION . .". When the function module ends, the subroutine is called automatically.
The subroutine must also have a formal parameter with any name you choose. When the subroutine is called, it receives the accompanying task name. This parameter lets you see which aRFC call just ended, and you can receive the relevant
output using the RECEIVE RESULTS FROM FUNCTION command.
The subroutine may not contain any statements that interrupt the program execution (such as CALL SCREEN, SUBMIT, COMMIT WORK, WAIT, RFCs, W or I messages). WRITE statements in this subroutine specially defined for aRFC have no effect.
The subroutine can only be executed automatically if the calling program is in rollout status. -> "WAIT UNTIL" statements (see next slide).
The addition KEEPING TASK with the RECEIVE statement causes the function group context that was loaded remotely to wait until the calling program has ended. This lets you use the old remote context with later aRFC calls with the same task name.
The language element WAIT UNTIL with the addition PERFORMING is only useful with aRFC, and otherwise has no effects.
When the WAIT UNTIL statement is executed, the conditions specified are checked.
If it is fulfilled, the program processing continues directly after the WAIT UNTIL statement.
Otherwise the system waits in rollout status for the output from the aRFCs. If the aRFC output is now returned, the form routine specified during the call is executed and is sent back to the WAIT UNTIL statement.
This check/wait procedure repeats until the WAIT conditions are fulfilled, or until there are no more open RFC calls.
Note that the WAIT UNTIL statement sets the SY-SUBRC. Therefore, store the SY-SUBRC value (set in the form routine by exceptions-handling in RECEIVE RESULTS) in its own global variable before leaving the form routine, if you need this value again later (after WAIT UNTIL).
aRFC is particularly suited for implementing parallel processing in several R/3 Systems.
You can also use aRFC within the same SAP R/3 System, for example, to move some of the processing load to an application server specially used for this.
Enter the RFC destination that refers to the corresponding application server. (You can find this under Internal connections in Transaction SM59.)
You can also use aRFC locally within the same application server to implement parallel processing in several work processes.
Here you do not need to specify a destination.
Note, however, that several work processes will be occupied by your program at the same time.
LOAD BALANCING USING RFC GROUPS:
You can divided the application servers for an SAP R/3 System into different RFC groups using Transaction SM59.
When calling a function module within this R/3 System, you can specify one of the defined RFC groups using the addition DESTINATION IN GROUP , which selects the server that has the lowest load in order to execute the function module.
Instead of specifying a specific RFC group, you can also enter the word DEFAULT. The server is selected from all the application servers of the R/3 System.
If all the servers of the specified group are overloaded (see next slide), the exception RESOURCE_FAILURE is triggered.
Note that:
- You have to specify the addition DESTINATION IN GROUP after STARTING NEW TASK as opposed to the DESTINATION addition.
- You can only use this addition within the current SAP R/3 System (you cannot have additional DESTINATION entries).
For each server in the specified RFC group, the system checks if the application server has:
- a dispatcher queue load of <> No IMPORTING . . . / PERFORMING . . . ON END OF TASK when calling;
-> No RECEIVE RESULTS FROM FUNCTION . . .
In the source system, you can use the administration transaction SM58 that lets you display and modify tRFC-LUWs.
EXECUTION:
tRFC calls are first stored in the local tRFC tables ARFCSSTATE and ARFCSDATA. The execution status of the LUWs is logged in table ARFCSSTATE, while ARFCSDATA contains the input data for the tRFCs.
If you do not want to execute a remote LUW immediately, rather trigger it at a later time, call the function module START_OF_BACKGROUNDTASK before the COMMIT WORK statement locally. Here, you must enter the date and time of execution.
The COMMIT WORK statement automatically schedules an immediate job or a job set for a later start time to remotely call the LUW. In the job execution, the relevant data is read from the tRFC tables, and the corresponding tRFCs are transmitted. If the remote LUW is executed successfully, the accompanying entries are deleted from the tRFC tables. If an error occurs, an automatic repeat mechanism, or rollback mechanism is activated (see next slide).
If the update is triggered locally because of the COMMIT WORK statement, the tRFCs are only executed when the local update is successfully completed.
WHEN ERROR COMES:
If a connection cannot be made to the partner, this is logged in the tRFC status table ARFCSSTATE (which you can see by using Transaction SM58), and the job is rescheduled. You can set in the destination the number of times the system repeats the effort to connect, and the time intervals, by using the tRFC options. The default is a maximum 30 times with a 15 minute interval.
If, after a tRFC-LUW is successfully executed in the partner system in one of the function modules, the program terminates with an A/X-message (MESSAGE A/X...) or triggers an exception (RAISE...),
- all the changes made in the current LUW are automatically rolled back in the remote system, and
- the remote program termination is logged in the tRFC status table ARFCSSTATE (viewable using SM58) in the source system.
The entries relevant to the LUW remain in the tRFC tables and the execution job is not rescheduled. In this case, you can find the remote error using Transaction SM58, and you have to correct the problem in the remote system. Afterward you must trigger the remote execution again also in Transaction SM58.
If you want to cancel and roll back this remote execution from a remote function module of a tRFC-LUW, but you also want to reschedule the job in the source system (for example, because a master record that is to be processed is locked and the LUW must be executed again), call the function module RESTART_OF_BACKGROUNDTASK in the remote function module instead of MESSAGE A... or RAISE...
LUW BUILDING:
If tRFCs are transmitted with different destinations before the COMMIT WORK, they are grouped into different LUWs according to their destination.
A tRFC call with the addition AS SEPARATE UNIT is always processed as a separate LUW independently of the other tRFCs.
Each tRFC-LUW is assigned a unique transaction ID (viewable with Transaction SM58).
The function module ID_OF_BACKGROUNDTASK (which is called before the COMMIT WORK) returns this ID.
You can determine the LUW execution status using the function module STATUS_OF_BACKGROUNDTASK under the transaction ID (which is called after the COMMIT WORK).
If you also called the update function modules locally before the COMMIT WORK, tRFC calls are only processed when the local update function modules have been processed successfully.
You can also call transactional C functions. However, you must use the rollback mechanism in the external server program .
RELATED POSTS
QUEUED RFC
RFC PART 2
RFC PART 1
With synchronous RFC, processing stops in the calling program until the called remote function is processed and its output is returned. Then in the calling program, the processing continues after the call.
The statement CALL FUNCTION ... DESTINATION enables you to call remote ABAP function modules or C routines in external server programs.
When you call a function in this way, always include handling for the standard exceptions COMMUNICATION_FAILURE and SYSTEM_FAILURE.
The exception COMMUNICATION_FAILURE is resolved by the system if the specified destination in the sideinfo table RFCDES is not maintained, or if the connection to the remote system cannot be established.
The exception SYSTEM_FAILURE is resolved if the function module or C routine that you want to start in the remote system is not available.
The connection to a remote destination remains intact for as long as the context of the calling program remains active. The function groups addressed in the remote destination remain active for as long as the calling program itself remains active (this is the same as with local calls). This means that if you call two function modules from the same function group one after the other, they can both access the same global data of the function group.
Each function module called using synchronous RFC forms its own logical unit of work (LUW) (exception:
You can debug function modules called remotely in R/3 - R/3 connections.
If a remotely-called function module uses dialogs (for example, CALL SCREEN,
CALL TRANSACTION or lists), they are executed in the session of the caller (and are fully functional).
Note that RFC dialogs in background processing lead to a program termination with the exception SYSTEM_FAILURE (but you can use RFC within background processing).
ASYNCHRONOUS RFC :
In an asynchronous Remote Function Call, the called remote function is started and then continues processing on its own immediately in the calling program. Remote function processing is separate from the calling program. The function output can be received later in the program.
Asynchronous RFC is intended for parallel processing of processes.
With the addition STARTING NEW TASK
No comments :
Post a Comment