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

calling a function in tasks

Former Member
0 Likes
778

HI gurus

Is the following implementation in-correct. This for me should be creating invoices as the function module YSHELL_INCOMING is calling a bapi inturn...however I do not get any tables filled and there is no return in the return table.

DO 5 TIMES.

WRITE SY-INDEX TO V_TASK.

CALL FUNCTION 'YSHELL_INCOMING'

STARTING NEW TASK V_TASK

performing set_function1 on end of task

EXPORTING

HEADERDATA = G_INV_HEADER

TABLES

ITEMDATA = G_INV_ITEMDATA

ACCOUNTINGDATA = G_INV_ACCDATA

GLACCOUNTDATA = G_INV_GLDATA

WITHTAXDATA = G_INV_WITHTAXDATA

RETURN = G_INV_RETURN.

ENDDO.

form set_function1 using taskname.

receive results from function 'YSHELL_INCOMING'

IMPORTING

INVOICEDOCNUMBER = G_INVOICE

FISCALYEAR = G_FYEAR.

endform.

endform.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
745

Hi Rich,

One question : Does my Z-function module have to RFC enabled to make this work .

6 REPLIES 6
Read only

ThomasZloch
Active Contributor
0 Likes
745

Move Add

> TABLES

> RETURN = G_INV_RETURN

to the RECEIVE RESULTS section. Also add this to the aRFC-call and check sy-subrc, as there might be a technical problem with the aRFC:

> EXCEPTIONS

> communication_failure = 1

> system_failure = 2

> resource_failure = 3

> others = 4.

Thomas

P.S. you should also do a COMMIT WORK inside YSHELL_INCOMING

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
745

Pretty sure you need to WAIT till its done. Here is an example program using the WAIT.

report zrich_0001.

data: functioncall1(1) type c.
constants: done(1) type c value 'X'.

data: cstgdetail1 type bapicustomer_kna1.

parameters: p_kunnr1 type kna1-kunnr.

start-of-selection.

  call function 'BAPI_CUSTOMER_GETDETAIL2'
           starting new task 'FUNC1'
             destination 'NONE'
              performing set_function1_done on end of task
    exporting
      customerno                  = p_kunnr1.


* Receive remaining asynchronous replies
  wait until functioncall1 = done.

  write:/  cstgdetail1.

************************************************************************
*       FORM FUNCTION1_DONE
************************************************************************
form set_function1_done using taskname.

  receive results from function 'BAPI_CUSTOMER_GETDETAIL2'
   importing
      customergeneraldetail       = cstgdetail1.

  functioncall1 = done.

endform.

Regards,

Rich Heilman

Read only

0 Likes
745

Hi Rich , should my Z- Function Module be RFC enabled to make this work , I am receiving a short dump right now.

Read only

Former Member
0 Likes
746

Hi Rich,

One question : Does my Z-function module have to RFC enabled to make this work .

Read only

0 Likes
745

In case Rich is out for lunch: yes

Also I strongly recommend you see my answer above. I am using aRFC and it works nicely.

Thomas

http://help.sap.com/saphelp_nw70/helpdata/EN/22/042592488911d189490000e829fbbd/frameset.htm

Read only

Former Member
0 Likes
745

Thomas and Rich , thank you very much for your help , it seems to be working now , my function module was missing RFC enabled and few other tinkering .