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_PRODORD_CREATE delete order

Former Member
0 Likes
2,505

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?

4 REPLIES 4
Read only

former_member1716
Active Contributor
2,019

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!

Read only

Dominik_Tylczynski
SAP Champion
SAP Champion
2,019

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

Read only

0 Likes
2,019

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

Read only

Dominik_Tylczynski
SAP Champion
SAP Champion
0 Likes
2,019

Hello nick99999

I don't think there is a BAPI to revoke deletion flag. However you can revoke it in CO02 transaction.

Best regards

Dominik Tylczynski