First of all, Deletion of shopping cart is not a standard solution.
Please refer to knowledge base article 1649794 – Status dependent control of Shopping Cart
The administrator can only change shopping carts when:
– the shopping cart was created by himself,
– the shopping cart items have the status ‘Error in transfer process’ (I1112).
Shopping Carts with item Status ‘Error in transfer process’, can be only proceed by the administrator. The administrator can in transaction Monitor Shopping Cart:
– edit the erroneous Shopping Cart items to resolve the error and reorder them again,
– delete the erroneous line items,
– retransfer the erroneous line items without change.
I had a need to delete a shopping cart, which has not been transferred to backend – have active status “error in transmission”.
SAP provides a standard shopping cart monitor, which allow to delete shopping carts as administrator, but unfortunatelly, not for approved shopping carts.
But there is a simple solution for this. All you need is to implement a BADI /SAPSRM/BD_PDO_MONITOR_SC.
Here are some steps, how to do this.
First you should go to transaction SE18 – Business Add-Ins: Definitions, select a BADI and click on “Display” button.
Then click on “Create BADI Implementation” Button.
A new popup window will be opened.
You should enter a name for enhancement Implementation and composite enhancement implementation.
Please do it according to your naming conventions. If you want to create new composite enhancement implementation – first click on create button,
then you need to define a Package, where you want to save your implementation (Z_BADI in my case).
And define a request number for transport to Test and Productive.
After saving all the changes you’ll get a new popup for BADI Implementation (will be created inside of newly created enhancement implementation).
Please enter BADI Implementation and implementation class names according to your naming conventions.
Confirm your changes.
After confirming you’ll jump to windows with BADI Implementation.
Here you should navigate to implementation class (just double click).
You need to imeplement MODIFY_LIST method of the BADI. Make a double click on method name.
In the opened popup you will be prompted to implement the method.
I used following code, to change standard system behaviour.
METHOD /sapsrm/if_ex_bd_pdo_mon_sc~modify_list. FIELD-SYMBOLS: <fs_header> LIKE LINE OF ct_sc_result_header, <fs_item> LIKE LINE OF ct_sc_result_item. LOOP AT ct_sc_result_header ASSIGNING <fs_header> WHERE status = /sapsrm/if_pdo_status_c=>gc_pdo_sc_released AND flag_delete_allowed = abap_false. <fs_header>-flag_delete_allowed = abap_true. LOOP AT ct_sc_result_item ASSIGNING <fs_item> WHERE header = <fs_header>-guid AND del_ind = abap_false AND status <> /sapsrm/if_pdo_status_c=>gc_pdo_transfer_err. <fs_header>-flag_delete_allowed = abap_false. EXIT. ENDLOOP. UNASSIGN <fs_item>. ENDLOOP. UNASSIGN <fs_header>. ENDMETHOD.
Method has a following logic: first loop via all shopping cart headers, which are approved but deletion is not allowed. For every shopping cart is by default allowed to delete it. Then is checked, whether all not deleted positions have active status “error in transfer”, if not – disable deletion.
Changes should be activated.
Additionally you should implement the rest 2 mthods of the class. You may leave implementation empty (don’t forget to actiovate newly implemented methods).
After activation you should be able to delete shopping carts, which have not been transferred.