CALL FUNCTION SYNTAX FOR SAP ABAP part three

Variant 2

CALL FUNCTION func ...STARTING NEW TASK

Additions

1. ... DESTINATION dest
2. ... PERFORMING form ON END OF TASK
3. ... EXPORTING p1 = f1 ... pn = fn
4. ... TABLES p1 = itab1 ... pn = itabn
5. ... EXCEPTIONS syst_except = rc MESSAGE mess

Effect

Starts the function module func asynchronously in a new mode. In contrast to normal function module calls, the calling program resumes processing as soon as the function module is started in the target system. It does not wait until the function module has finished. Through CALL SCREEN , the called function module can, for example, display a screen and thus interact with the user.

Notes

This variant applies only from R/3 Release 3.0. Both partner systems (the client and the server systems) must have a Release 3.0 version of the R/3 System.

With this variant, the called function module must also be
flagged in the Function Library as externally callable, even if it is executed locally (without the addition DESTINATION).

Addition 1

... DESTINATION dest

Effect

Executes the function module externally as a Remote Function Call ( RFC ); dest can be a literal or a variable. The R/3 System where the function module is executed depends on the specified destination. Externally callable function modules must be flagged as such in the Function Library (of the target system).

Addition 2

... PERFORMING form ON END OF TASK
Whereas the parameters for receiving results (i.e. IMPORTING and TABLES parameters) are specified directly as additions in the case of "conventional" function modules (see variant 2), these are logged in the FORM routine form when making an asynchronous call .

Note

If a function module returns no result, this addition ( ... PERFORMING form ON END OF TASK ) can be omitted.

Addition 3

... EXPORTING p1 = f1 ... pn = fn

Effect

EXPORTING passes values of fields and field strings from the calling program to the function module. In the function module, the formal parameters are defined as import parameters.

Addition 4

... TABLES p1 = itab1 ... pn = itabn

Effect

TABLES passes references to internal tables. All table parameters of the function module must contain values.

Addition 5

... EXCEPTIONS syst_except = rc MESSAGE mess

Effect

While any exceptions arising in the called function module are handled by the second addition (in the FORM routine), this addition can handle two special system exceptions, as with function module calls with the addition DESTINATION :
SYSTEM_FAILURE

is triggered, if a system crash occurs on the receiving side.
COMMUNICATION_FAILURE
is triggered if there is a connection or communication problem.
In both cases, you can get a description of the error with the optional addition

... MESSAGE mess

Example

 
DATA: MSG_TEXT(80). "Message text
...
* Asynchronous call to Transaction SM59 -->
* Create a new session
CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'TEST'
  DESTINATION 'NONE'
  EXPORTING
      TCODE = 'SM59'
  EXCEPTIONS COMMUNICATION_FAILURE MESSAGE MSG_TEXT.
  IF SY-SUBRC NE 0.
    WRITE: MSG_TEXT.
  ELSE.
    WRITE: 'O.K.'.
  ENDIF.

Note

Runtime errors
CALL_FUNCTION_TASK_YET_OPEN : Task already open.

RELATED POST

CALL FUNCTION SYNTAX PART TWO

No comments :

Post a Comment