Application Development and Automation 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: 
Read only

CALL FUNCTION WITH STARTING NEW TASK

Former Member
36,888

Hi All,

i'm call a function module through

CALL FUNCTION 'Y_WIN' DESTINATION 'rfc_destination' then it's give right result but when i want to call with starting new task then

CALL FUNCTION 'Y_WIN' STARTING NEW TASK 'INFO' DESTINATION 'rfc_destination'

it does nt provide me any data. i have check in debugger call fm is wkging fine so pls clear me why i'm nt geeting result.

pls give ur suggestions,

Anuj

5 REPLIES 5
Read only

Former Member
0 Likes
16,922

As per my knowledge, It will be called in a new session like Update task. you will not get any output from these.

Read only

MarcinPciak
Active Contributor
16,922

Hi Anuj,

CALL FUNCTION 'XXX' STARTING NEW TASK starts new FM in asynchronous mode. It doesn't interrupt your current program processing. Instead it runs pararelly to your program, therefore the results are not visible until this fm concludes (you can't determine when it happens). Moreover it also starts new SAP LUW, so after fm finishes there is made an implicit DB commit and changes done within this FM can't be rollbacked anymore. During all this time, your program goes ahead and the fm results don't affect it.

On the other hande, when you use normal CALL FUNCTION without the addtion it runs in synchronous mode, so the program holds until the execution of FM is ended. Then it continues its processing. Depending on what you want to achieve you should consider both (any)synchronous approach.

Regards

Marcin

Read only

RaymondGiuseppi
Active Contributor
16,922

Did you use the PERFORMING <form> ON END OF TASK to get the results back; like in the following sample

          CALL FUNCTION 'SAPWL_STATREC_READ_FILE'
               STARTING NEW TASK taskname
               DESTINATION list-name
               PERFORMING read_outtab ON END OF TASK
               EXPORTING
                    read_start_date   = s_date
                    read_start_time   = '000000'
                    read_end_date     = s_date
                    read_end_time     = '235959'
               EXCEPTIONS " failure when calling RFC
                    communication_failure = 1 MESSAGE msg_text
                    system_failure        = 2 MESSAGE msg_text
                    RESOURCE_FAILURE      = 3.

and

FORM read_outtab USING taskname.
* Receive results back
  RECEIVE RESULTS FROM FUNCTION 'SAPWL_STATREC_READ_FILE'
    TABLES
      v2_normal_records = outtab
    EXCEPTIONS " from the called FM
      nodata    = 1.

Regards

Read only

Former Member
0 Likes
16,922

thanks all.

Read only

0 Likes
16,922

*&---------------------------------------------------------------------*

*& Report  ZSRINU_FUNCTION

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  ZSRINU_FUNCTION.

TABLES KNA1.

*PARAMETERS P_LAND1 TYPE KNA1-LAND1.

SELECT-OPTIONS SO_KUNNR FOR KNA1-KUNNR.

DATA I_TAB1 TYPE TABLE OF KNA1.

DATA W_KNA1 TYPE KNA1.

SELECT * FROM KNA1 INTO TABLE I_TAB1 WHERE KUNNR IN SO_KUNNR.

DATA I TYPE N.

DATA I1 TYPE STRING.

DATA EX_DATA TYPE VBAK.

DATA K TYPE I.

DESCRIBE TABLE I_TAB1 LINES K.

LOOP AT I_TAB1 INTO W_KNA1.

  I = I + 1.

  CONCATENATE 'SRINU' 'I' INTO I1.

  CALL FUNCTION 'ZSRINU_RFC' STARTING NEW TASK I1 DESTINATION 'NONE'

    PERFORMING SRINU ON END OF TASK

    EXPORTING

      KUNNR1        = W_KNA1-KUNNR

*    IMPORTING

*     EX_DATA       = EX_DATA.

    EXCEPTIONS

      CALL_TRANSACTION_DENIED = 1.

    IF SY-SUBRC = 1.

           WRITE : 'HEY ERROR'.

           ELSEIF SY-SUBRC = 0.

             WAIT UNTIL I = K.

             WRITE : / EX_DATA-KUNNR , EX_DATA-VBELN.

    ENDIF.

ENDLOOP.

*&---------------------------------------------------------------------*

*&      Form  SRINU

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM SRINU USING NAME.

RECEIVE RESULTS FROM FUNCTION 'ZSRINU_RFC'

IMPORTING

   EX_DATA       = EX_DATA

          .

*WRITE : / EX_DATA-KUNNR , EX_DATA-VBELN.

ENDFORM.                    " SRINU