‎2020 Oct 01 9:05 AM
how can I cancel the execution of the bapi BAPI_PRODORD_CREATE after it has been executed and I must necessarily commit because after this bapi I have to perform other operations and if these go wrong then I have to cancel the BAPI_PRODORD_CREATE so that the order is no longer present?
‎2020 Oct 01 9:12 AM
nick99999,
There are two BAPIs which are used for commit and Rollback. If the BAPI operation is successful you can go for Commit BAPI else Rollback BAPI. Code samples below for reference:
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true
IMPORTING
return = ls_return.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.Regards!
‎2020 Oct 01 10:07 AM
Hello nick99999
The answer of satishkumarbalasubramanian is valid in general as it follows SAP best practice of BAPI implementation. However BAPI_PRODORD_CREATE doesn't follow it (don't ask me why; it's just how SAP has chosen to implement it). You don't need to explicitly call BAPI_TRANSACTION_COMMIT. See the documentation of BAPI_PRODORD_CREATE - it reads:
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.
Also refer to note 2587249 - Does the BAPI need COMMIT Work?
If you need to cancel/delete a production order, you can use BAPI_PRODORD_SET_DELETION_FLAG function. It's also doesn't need explicit commit work.
Best regards
Dominik Tylczynski
‎2020 Oct 01 11:16 AM
Thank you for your answer, a question, is there a fm to remove the delete flag set with the bapi BAPI_PRODORD_SET_DELETION_FLAG?
thanks it's very urgent
‎2020 Oct 01 11:36 AM