Purpose
From time to time it comes up that customers need to run report "COM_PRODUCT_DELETE_ALL" in the background, but it is not possible. This document describes some workarounds to enable this.
Background
Before continuing, it is important to mention that this report (also COM_PRODUCT_DELETE_SINGLE) cannot be run in a production environment as per SAP standard. This is because SAP do not recommend deleting master data in a production system. Instead you should use transaction SARA to archive the product instead.
The report is available in all other system types (test/development etc.) to allow customers delete products if required. The reason it cannot be run in the background is because there is a Pop up confirmation in this report. Since user interaction is required, the report does not work in background.
Workaround:
The following are two suggestions provided as workarounds only:
Option 1
1. Copy the report COM_PRODUCT_DELETE_ALL into a Z report e.g. ZOM_PRODUCT_DELETE_ALL.
2. Change the Constant gc_program on Line 17 to ZOM_PRODUCT_DELETE_ALL.
3. Comment the code 'PERFORM confirmation_popup' on line 85.
4. Register the report ZOM_PRODUCT_DELETE_ALL in COMC_PR_TOOL_REG.
5. Schedule the report ZOM_PRODUCT_DELETE_ALL to run in background.
Option 2
You can create a Z* Program using the following code and schedule in background using the transaction SM36. XX denotes the logical system name that is defined in field LOGSYS in table COMM_PRODUCT
DATA: lt_product TYPE comt_product_tab WITH HEADER LINE.
SELECT * FROM comm_product INTO TABLE lt_product UP TO 1000 ROWS
WHERE logsys = 'XX'
AND object_family = space
AND product_type = '01' .
LOOP AT lt_product.
SUBMIT zcom_product_delete_single
WITH p_logs = 'XX'
WITH p_objf = space
WITH p_prid = lt_product-product_id
WITH p_prty = '01' AND RETURN.
ENDLOOP. " at lt_product.
This report will delete 1000 records at a time so you will have to schedule it such that it runs at an interval of 30 seconds till all the products are deleted.