Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

STARTING NEW TASK

Former Member
0 Kudos
1,742

can ny 1 give me a simple example as to WHY call function STARTING NEW TASK is used ???

i need a very very simple example to demonstrate the concept

3 REPLIES 3

Former Member
0 Kudos
370

hi there...

Syntax

CALL FUNCTION func STARTING NEW TASK task

DESTINATION {dest

parameter list

{PERFORMING subr}.

Additions:

1. ...DESTINATION IN GROUP { group |DEFAULT}

2. ...{PERFORMING subr}|{CALLING meth} ON END OF TASK

Effect

Asynchronous call of a remote-capable function module specified in func using the RFC interface. You can use the addition DESTINATION to specify a single destination in dest, or to specify a group of application servers by using IN GROUP. The latter supports parallel processing of multiple function modules. The calling program is continued using the statement CALL FUNCTION, as soon as the remotely called function has been started in the target system, without having to wait for its processing to be finished. You can use PERFORMING and CALLINGto specify callback routines for copying results when the remotely called function is finished. Character-type data objects are expected for func and dest.

If the destination has not been specified, the destination NONE is used implicitly. When the destination NONE is used, a new main session is opened for the current user session. The asynchronous RFC does not support communication with external systems or programs written in other programming languages.

A character-type data object must be specified for task, one which contains for the remotely called function module a freely definable task ID that has a maximum eight digits. This task ID must be unique for each call, and is handed to the callback routines for identifying the function. Each task ID defines a separate RFC connection with its own context, meaning that, in the case of repeated function module calls of the same task ID, the global data of the relevant function group can be accessed, if the connection still exists.

In dialog processing, note that the maximum number of six main sessions cannot be exceeded, else an error message is displayed.

Addition 1

... DESTINATION IN GROUP {group|DEFAULT}

Effect

Specifying IN GROUP as a destination allows you to execute multiple function modules in parallel on a predefined group of application servers in the current SAP system.

For group, you must specify a data object of the type RZLLI_APCL from the ABAP Dictionary, one that is either initial, or one that includes the name of an RFC server group created in transaction RZ12. When specifying DEFAULT, or if group is initial, all application servers that are currently available in the current SAP system are used as a group. Only one RFC server group may be used within a program. During the first asynchronous RFC using the addition IN GROUP, the specified RFC server group is initialized. For each asynchronous RFC where the group is specified, the most suitable application server is determined automatically, and the called function module is executed on this.

If the function module cannot be executed on any application server, due to not enough resources being currently available, this leads to the predefined exception RESOURCE_FAILURE, to which a return value can be assigned, in addition to the remaining RFC exceptions. For this exception, the addition MESSAGE is not permitted.

· The parallel processing of function modules using the addition IN GROUP makes optimum use of the resources available, and is preferred to self-programmed parallel processing with destinations that are specified explicitly.

· An application server that is used as part of an RFC server group for parallel processing must have at least three dialog work processes, of which one is currently free. Other resources such as requests in the queue, number of system logons and so on, are also taken into account, and are not allowed to exceed certain limit values.

· To ensure that only those application servers that have enough resources are accessed, we recommend that you work with explicitly defined RFC server groups instead of working with the addition DEFAULT.

· The function modules of the function group SPBT provide service functions for parallel processing, for example, initialization of RFC server groups, determining the used destination, or temporarily removing an application server from an RFC server group.

Addition 2

... {PERFORMING subr}|{CALLING meth} ON END OF TASK

Effect

You can use this addition to specify either a subprogram subr or, as of Release 6.20, a method meth as a callback routine, which is executed after the asynchronously called function module has finished. For subr, you have to directly specify a subprogram of the same program. For meth, you can enter the same details as for the general method call.

The specified subprogram subr can have exactly one SING parameter of type clike only. The method meth must be public, and can have only one non-optional input parameter p_task of type clike. When the RFC interface is called, this parameter is supplied with the task ID of the remotely called function that was specified in the call in task. The results of the remote function can be received in the subprogram subr or method meth using the statement RECEIVE. In the callback routine, no statements can be executed that cause the program run to terminate or end an SAP LUW. Statements for list output are not executed.

Prerequisite for executing a callback routine is that, after the remote function has ended, the calling program is still internally available. It is then executed the next time the work process is changed. If the program has ended, or if it is part of a call sequence in the stack, then the callback routine is not executed. The statement WAIT can be used to stop the program execution until certain or all callback routines have been executed.

CALL FUNCTION - STARTING NEW TASK parameter_list

Syntax

...

[EXCEPTIONS exc1 = n1 exc2 = n2 ...

].

Effect

These additions are used to assign actual parameters to the formal parameters of the function module, and return values to exceptions that are not class-based. These additions have the same meaning as for the synchronous RFC. The only exception is that no values can be copied with IMPORTING and CHANGING.

do reward if helpful

0 Kudos
370

i have this material from help in printed form ALREADY .....

I NEED A SIMPLE EXAMPLE MANNNNNNNN

Former Member
0 Kudos
370

hi...

chk the following example....

DATA: INFO LIKE RFCSI,

  • Result of RFC_SYSTEM_INFO function

SYSTEM_MSG(80) VALUE SPACE.

  • Exception handling

CALL FUNCTION 'RFC_SYSTEM_INFO'

STARTING NEW TASK 'INFO'

PERFORMING 'RETURN_INFO' ON END OF TASK.

WRITE: 'Wait for reply'.

...

AT USER-COMMAND.

  • Return from FORM routine RETURN_INFO

IF SYSTEM_MSG = SPACE.

WRITE: 'Destination =', INFO-RFCDEST.

ELSE.

WRITE SYSTEM_MSG.

ENDIF.

...

FORM RETURN_INFO USING TASKNAME.

RECEIVE RESULTS FROM FUNCTION 'RFC_SYSTEM_INFO'

IMPORTING RFCSI_EXPORT = INFO

EXCEPTIONS SYSTEM_FAILURE MESSAGE SYSTEM_MSG.

REFRESH SCREEN. "Simulate command field = return key

ENDFORM.

will this help ..?? do reward if it does