Skip to Content
0

Unable to capture errors when BAPI_PO_CHANGE in BACK GROUND TASK

Dec 29, 2016 at 10:43 AM

30

avatar image

Hi,

I'm trying to call BAPI_PO_CHANGE in back ground task. In this scenario , it is not returning any errors. I need to capture the errors in order to proceed further.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Raghu Govindarajan Dec 29, 2016 at 12:13 PM
0

Read the help... CALL FUNCTION - IN BACKGROUND TASK - Application Development on AS ABAP - SAP Library

Quoting -

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

One possible way that you can get around this is to write a wrapper which logs the return to a table and then call that wrapper function instead of the BAPI_PO_CHANGE directly.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Raghu,

Thanks for quick reply..

The main reason for using BACK GROUND TASK with BAPI is bcz of below issue.

In my functionality,this BAPI_PO_CHANGE is being called 2 times via custom FM.

If i dont use user "BACK GROUND TASK" with BAPI_PO_CHANGE,

>>>I am getting error like "User XYZQWE already processing Purchase order 1234567".

>>> Wierd thing is, If try to run my functinality in debugging mode.Po change is happening successfully (no errors like above).

If i execute without debugging mode only, i am getting this error.

Here is my code:

SET UPDATE TASK LOCAL.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = lv_ebeln
poheader = ls_hdr
poheaderx = ls_hdrx
TABLES
return = it_return
poitem = it_poitem
poitemx = it_poitemx
poschedule = it_poschd
poschedulex = it_poschdx
poaccount = it_poacct
poaccountx = it_poacctx
poaddrdelivery = it_poaddr
extensionin = it_ext.


READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
IF sy-subrc IS NOT INITIAL.
COMMIT WORK AND WAIT.
WAIT UP TO 5 SECONDS.
ENDIF.

0
Raghu Govindarajan Dec 29, 2016 at 07:34 PM
0

If the issue is the locking on subsequent calls, rather than set to background task - which can still have trouble with locks - try waiting for the locks from the first call release. You can try this either before or after calling your BAPI. I have written a blog about how to do it that you can read here Waiting for lock objects to release – using lock modes U and V | SAP Blogs. Try using Option 4 from the blog using the appropriate lock object.

Share
10 |10000 characters needed characters left characters exceeded