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: 

Do 10 Times

kuanchin
Explorer
1,841

Hi All,

Good day, I need opinion on this DO X Times logic.

Recently we facing many implementation using this syntax. Reason was , SAP database not updating immediately even after TRANSACTION COMMIT with WAIT.

For example, after called BAPI_PRODORD_CHANGE to change the Production Order Document and called BAPI_TRANSACTION_COMMIT with parameter = WAIT.

Unfortunately Total Order Quantity (AFKO-gamng) still not immediately updated. So developer need to

Do 10 Times,

CLEAR lv_gamng.
SELECT SINGLE
gamng
FROM afko
INTO @lv_gamng
WHERE aufnr = @vl_orderno.
IF l_gamng = iv_order-qty_assigned.
EXIT.
ENDIF.
ENDDO.

I would like to double check, any other alternative solution instead of using DO X Time ?

Many thanks.

Best Regards,

CTK

7 REPLIES 7

DominikTylczyn
Active Contributor
1,444

Hello kuanchin

Usually BAPI_TRANSACTION_COMMIT with WAIT = X does the trick of synchronous update. But that is not the case with BAPI_PRODORD_CHANGE. As per the BAPI documentation:

Update Control

The method independently triggers the update to the database. You do not need to execute a COMMIT WORK again after the method has been called.

So you do not need to call BAPI_TRANSACTION_COMMIT after BAPI_PRODORD_CHANGE. In fact that call is superfluous and does not do anything.

Instead you can try executing SET UPDATE TASK LOCAL before executing BAPI_PRODORD_CHANGE. As per SAP Help to local update:

Update in the current work process. It is executed in a separate internal session of the current ABAP session and not in a dedicated update session.

Best regards

Dominik Tylczynski

1,444

Hi Dominik,

Good day, thanks for your valuable sharing.

Sorry I forgotten to refer BAPI documentation and thanks for this hints.

Will inform the developer for the same.

Best Regards,

CTK

Sandra_Rossi
Active Contributor
1,444

Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!

kuanchin
Explorer
0 Kudos
1,444

Hi,

Good day, thanks for your hints.

DO 10 Times,


CLEAR lv_gamng.

SELECT SINGLE gamng

FROM afko

INTO @lv_gamng

WHERE aufnr = @vl_orderno.

IF l_gamng = iv_order-qty_assigned.

EXIT.

ENDIF.

ENDDO.

raymond_giuseppi
Active Contributor
0 Kudos
1,444

As this BAPI handles the commit itself, you can't rely on a WAIT option.

If you don't want to use the SET UPDATE TASK LOCAL, you could try to lock the Production Order Number (ENQUEUE_ESORDER with wait option) in a DO/ENDDO loop, release and exit loop when locked else iterate.

0 Kudos
1,444

Hi,

Good day, would like to double check, if the ENQUEUE_ESORDER locked successful, is it mean the Total Order Quantity (AFKO-gamng) was updated already ?

Many thanks.

Best Regards,

CTK

0 Kudos
1,444

In case of doubt, or poor performance of the database server/buffer management, you can keep the loop on the 'select from table' after the loop on the order lock. (it is better to be safe than sorry. ) This case should be very rarely necessary.