SAP BW - Delete Process Chain Logs
SAP BW - Delete Process Chain Logs
SAP BW - Delete Process Chain Logs
Applies to:
SAP BW 3.x and higher versions as BW system. For more information, visit the Business Intelligence
homepage.
Summary
This document is intended to show how to delete old process chain execution logs in SAP BW system
using ABAP program in order to clear database space occupied by not required old process chain
execution logs.
Author Bio
Amol Jaiswal is a BI consultant with over 2.5 years of industry experience in implementation and
maintenance of SAP BW/BI systems. Presently, Amol is working with Infosys Technologies Ltd
and is involved in execution of SAP BW/BI projects.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 1
Deletion of Old Process Chain Execution Logs in BW/BI
Table of Contents
Introduction to Process Chains ........................................................................................................................... 3
Process Chain Log Deletion Program ............................................................................................................. 6
Related Content ................................................................................................................................................ 16
Disclaimer and Liability Notice .......................................................................................................................... 17
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 2
Deletion of Old Process Chain Execution Logs in BW/BI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 3
Deletion of Old Process Chain Execution Logs in BW/BI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 4
Deletion of Old Process Chain Execution Logs in BW/BI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 5
Deletion of Old Process Chain Execution Logs in BW/BI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 6
Deletion of Old Process Chain Execution Logs in BW/BI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 7
Deletion of Old Process Chain Execution Logs in BW/BI
*&---------------------------------------------------------------------*
* The purpose of this program is to keep only useful process chain logs*
* and delete other logs in tables RSPCLOGCHAIN and RSPCPROCESSLOG as *
* some process chain logs are not required any more and they *
* unnecessarily occupy database space. *
*&---------------------------------------------------------------------*
REPORT Z_DEL_OLD_PROCESSLOG.
*----------------------------------------------------------------------*
* Start of Program
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* DB-Tables
*----------------------------------------------------------------------*
TABLES: RSPCLOGCHAIN, " Cross-Table Log ID / Chain ID
RSPCPROCESSLOG. " Logs for the Chain Runs
*----------------------------------------------------------------------*
* Variables/Internal Tables
*----------------------------------------------------------------------*
DATA: COUNT1 TYPE P,
COUNT2 LIKE COUNT1.
DATA : LV_RC LIKE SY-SUBRC.
DATA: tb_chain LIKE RSPCLOGCHAIN OCCURS 0 WITH HEADER LINE.
*----------------------------------------------------------------------*
* Selection-Screen
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(31) text-002 FOR FIELD pa_lat.
PARAMETERS: pa_lat RADIOBUTTON GROUP rad1 USER-COMMAND CLICK DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(31) text-003 FOR FIELD pa_dat.
PARAMETERS: pa_dat RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE text-004.
SELECT-OPTIONS: so_date FOR RSPCLOGCHAIN-DATUM MODIF ID ABC OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b02.
SELECTION-SCREEN END OF BLOCK b01.
*----------------------------------------------------------------------*
* At Selection-Screen
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'ABC'.
IF pa_dat = 'X'.
screen-active = 1.
modify screen.
ELSE.
screen-active = 0.
modify screen.
ENDIF.
ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 8
Deletion of Old Process Chain Execution Logs in BW/BI
* Start-Of-Selection
*----------------------------------------------------------------------*
START-OF-SELECTION.
*take complete data from RSPCLOGCHAIN into internal table tb_chain.
select * from RSPCLOGCHAIN into table tb_chain.
*sort tb_chain in descending order according to chain_id, datum, zeit
* so that latest record for particular chain id should be at top.
SORT tb_chain descending by CHAIN_ID DATUM ZEIT.
clear tb_chain.
LOOP AT tb_chain.
*delete latest record from internal table so that it should contain only
*those records which we need to delete from both tables.
ON CHANGE OF tb_chain-CHAIN_ID.
* keep latest records only
IF pa_lat = 'X'.
delete tb_chain.
* delete only those records which meet date range selection option
ELSEIF pa_dat = 'X'.
delete tb_chain where CHAIN_ID = tb_chain-CHAIN_ID
and DATUM NOT IN so_date.
ENDIF.
ENDON.
ENDLOOP.
LOOP AT tb_chain.
*delete RSPCPROCESSLOG records where log_id is matching with that of tb_chain.
DELETE FROM RSPCPROCESSLOG WHERE LOG_ID = tb_chain-log_id.
*counter for taking note of how many records are deleted
count1 = count1 + SY-DBCNT.
CLEAR SY-DBCNT.
*delete RSPCLOGCHAIN records where log_id is matching with that of tb_chain.
DELETE FROM RSPCLOGCHAIN WHERE LOG_ID = tb_chain-log_id.
*counter for taking note of how many records are deleted
count2 = count2 + SY-DBCNT.
CLEAR SY-DBCNT.
ENDLOOP.
WRITE: / 'The no. of records deleted from RSPCPROCESSLOG :', count1,
/ 'The no. of records deleted from RSPCLOGCHAIN:', count2.
*----------------------------------------------------------------------*
* End of Program
*----------------------------------------------------------------------*
The text symbols and Selection texts for selection screen should be maintained as well. This can be done
as shown in fig-7.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 9
Deletion of Old Process Chain Execution Logs in BW/BI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 10
Deletion of Old Process Chain Execution Logs in BW/BI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 11
Deletion of Old Process Chain Execution Logs in BW/BI
chain can be deleted in one go, but if we use above discussed program, we can delete unnecessary logs
of all process chains in one go. Another problem with the program ‘RSPC_LOG_DELETE’ is that it can
deactivate some steps in the process chain which needs to be reactivated after execution of program.
But this standard program ‘RSPC_LOG_DELETE’ can be integrated in our program in BI 7.0 system, so
that all the standard checks done by the program ‘RSPC_LOG_DELETE’ would be done by our program.
Please find below BI 7.0 system version of above discussed program in order to use standard program
‘RSPC_LOG_DELETE’.
*----------------------------------------------------------------------*
* Start of Program
*----------------------------------------------------------------------*
REPORT Z_DEL_OLD_PROCESSLOG.
*----------------------------------------------------------------------*
* DB-Tables
*----------------------------------------------------------------------*
TABLES: rspclogchain, " Cross-Table Log ID / Chain ID
rspcprocesslog. " Logs for the Chain Runs
*----------------------------------------------------------------------*
* Variables/Internal Tables
*----------------------------------------------------------------------*
DATA: count1 TYPE p,
count2 LIKE count1.
DATA: lv_rc LIKE sy-subrc,
l_s_logs TYPE rspclogchain,
l_msg TYPE char255,
l_datum TYPE sy-datum,
l_zeit TYPE sy-uzeit.
DATA: tb_chain LIKE rspclogchain OCCURS 0 WITH HEADER LINE.
*----------------------------------------------------------------------*
* Selection-Screen
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(31) text-002 FOR FIELD pa_lat.
PARAMETERS: pa_lat RADIOBUTTON GROUP rad1 USER-COMMAND click DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(31) text-003 FOR FIELD pa_dat.
PARAMETERS: pa_dat RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE text-004.
SELECT-OPTIONS: so_date FOR rspclogchain-datum MODIF ID abc OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b02.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 12
Deletion of Old Process Chain Execution Logs in BW/BI
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'ABC'.
IF pa_dat = 'X'.
screen-active = 1.
MODIFY SCREEN.
ELSE.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
* Start-Of-Selection
*----------------------------------------------------------------------*
START-OF-SELECTION.
CLEAR tb_chain.
LOOP AT tb_chain.
*delete latest record from internal table so that it should contain only
*those records which we need to delete from both tables.
ON CHANGE OF tb_chain-chain_id.
* keep latest records only
IF pa_lat = 'X'.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 13
Deletion of Old Process Chain Execution Logs in BW/BI
DELETE tb_chain.
* delete only those records which meet date range selection option
ELSEIF pa_dat = 'X'.
DELETE tb_chain WHERE chain_id = tb_chain-chain_id
AND datum NOT IN so_date.
ENDIF.
ENDON.
ENDLOOP.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 14
Deletion of Old Process Chain Execution Logs in BW/BI
IMPORTING
e_datum_loc = l_datum
e_uzeit_loc = l_zeit
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
l_datum = l_s_logs-datum.
l_zeit = l_s_logs-zeit.
ENDIF.
MESSAGE s129(rspc) WITH l_s_logs-log_id l_datum l_zeit INTO l_msg.
WRITE / l_msg.
ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
* End of Program
*----------------------------------------------------------------------*
Generally this program should be used in 3 months to delete 3 months before old logs of process chains, as
these logs won’t be required normally.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 15
Deletion of Old Process Chain Execution Logs in BW/BI
Related Content
https://www.sdn.sap.com/irj/sdn/weblogs
http://help.sap.com/
http://www.tli-usa.com/download/TipsTricks_and_Techniques_for_OptimalUseofProcessChains.pdf
For more information, visit the Business Intelligence homepage.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 16
Deletion of Old Process Chain Execution Logs in BW/BI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 17