ABAP bapi_salesorder_change to Delete Sales Order in SAP
I used ABAP BAPI bapi_salesorder_change to delete sales order in SAP system recently.
During ABAP development for migration of sales orders from an older SAP system to a newer SAP system, I had to delete sales orders I created for test purposes.
I chosed to use the ABAP BAPI bapi_salesorder_change to delete sales orders in SD (Sales and Distribution) since it is very easy to use.
I created an ABAP report which takes a range of VBELN (sales order document number) which defines the list of SAP sales orders created during migration tests.
The below SAP screenshot displays the SAP GUI selection screen of the sample ABAP program.
Note that the BAPI_SALESORDER_CHANGE pattern requires salesdocument and order_header_inx parameters to be set for a successfull call.
To delete an SAP Sales Order, call bapi_salesorder_change function module with sales order number (VBELN) as the salesdocument parameter and set order_header_inx-updateflag to 'D' (indicates DELETE action).