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

BAPI_PO_CHANGE issue

Former Member
0 Likes
1,300

Hi Experts,

I am using BAPI_PO_CHANGE to update Delivery Completed Indicator in item level.

I am running this program based on small condition.

This program is working fine in foreground.

when i schedule it in background through SM36 the PO line items are not getting updated.

loop at gt_eket into wa_eket.

l_po = wa_eket-ebeln.

w_poitem-po_item = wa_eket-ebelp.

w_poitem-no_more_gr = 'X'.

append w_poitem to l_poitem.

w_poitemx-po_item = wa_eket-ebelp.

w_poitemx-po_itemx = 'X'.

w_poitemx-no_more_gr = 'X'.

append w_poitemx to l_poitemx.

call function 'BAPI_PO_CHANGE'

exporting

purchaseorder = l_po

tables

return = l_return

poitem = l_poitem

poitemx = l_poitemx.

read table l_return with key type = c_err transporting no fields.

if sy-subrc ne 0.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = c_x

importing

return = l_return_c.

endif.

clear:wa_eket,l_po,w_poitem,l_poitem,w_poitemx,l_poitemx,l_return,l_return_c,

w_return,wa_ekko.

endloop.

Please suggest why my program is not running in background.

Thanks & Regards.

Praveen.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,005

BAPIs are designed so that all updates are done through a single COMMIT after the call to the BAPI is completed.,

I see some issues with your coding

1. Why are you calling BAPI_PO_CHANGE for each schedule item in a LOOP? You can append all items to relevant tables and call BAPI_PO_CHANGE only once and do BAPI_TRANSACTION_COMMIT once for each PO

2. Calling BAPI_PO_CHANGE in a loop on the same PO will cause issues because of locking and luws competing to complete

3. You are not refreshing the internal tables, so the first call to BAPI is taking item 1, second call items 1 and 2, third 1, 2, and 3 and so on.

Please ensure that you call the BAPI once for each PO

BAPIs are designed so that all updates are done through a single COMMIT after the call to the BAPI is completed.,

I see some issues with your coding

1. Why are you calling BAPI_PO_CHANGE for each schedule item in a LOOP? You can append all items to relevant tables and call BAPI_PO_CHANGE only once and do BAPI_TRANSACTION_COMMIT once for each PO

2. Calling BAPI_PO_CHANGE in a loop on the same PO will cause issues because of locking and luws competing to complete

3. You are not refreshing the internal tables, so the first call to BAPI is taking item 1, second call items 1 and 2, third 1, 2, and 3 and so on.

Please ensure that you call the BAPI once for each PO

4 REPLIES 4
Read only

Former Member
0 Likes
1,006

BAPIs are designed so that all updates are done through a single COMMIT after the call to the BAPI is completed.,

I see some issues with your coding

1. Why are you calling BAPI_PO_CHANGE for each schedule item in a LOOP? You can append all items to relevant tables and call BAPI_PO_CHANGE only once and do BAPI_TRANSACTION_COMMIT once for each PO

2. Calling BAPI_PO_CHANGE in a loop on the same PO will cause issues because of locking and luws competing to complete

3. You are not refreshing the internal tables, so the first call to BAPI is taking item 1, second call items 1 and 2, third 1, 2, and 3 and so on.

Please ensure that you call the BAPI once for each PO

Read only

0 Likes
1,005

Hi Vishnu,

This same program is running fine in foreground.

when i schedule in background it is having issues of updating.

1)If a PO has for example 3 line items.their may be chance that 1 st line item may have some issue with verion management

we have to deal it with some another parameters. 2 nd line item may have some another error .let us say 3rd line item is fine.

so if we try to apply Delivery Completed Indicator for all 3 line items at a time i think we will get error because only 3 rd line item is fine and remaning have some error.

2)can we include wait upto 2 seconds to get ride to locking and luws issues.

3)since the decleration is done as under.

data:l_return type standard table of bapiret2,

l_return type standard table of bapiret2,

l_poitemx type standard table of bapimepoitemx.

so clear is working fine.

Edited by: S.Praveen Kumar on Dec 4, 2011 5:30 PM

Read only

0 Likes
1,005

Hi Vishnu,

I am getting the fallowing message

E SG 105 :- Enter rate INR / rate type M for 04.12.2011 in the system settings

This message in not appearing when we do manually in change mode..

Edited by: S.Praveen Kumar on Dec 4, 2011 5:31 PM

Read only

Former Member
0 Likes
1,005

Hello.

Problem is solved.