*&---------------------------------------------------------------------*
*& Title: deleting tables ACCT* *
*&---------------------------------------------------------------------*
REPORT ZZTTAMAC.
TABLES:
ACCTHD, ACCTIT, ACCTCR.
CONSTANTS:
PACKAGE_SIZE TYPE I VALUE 1000000.
"核心关键点在这里,此处是调整一次性删除多少数据,这个值我的系统的极值点,
"如果你想使用,请自己去调整这个数值,系统原来的默认值是1000
DATA:
ACCTHD_KEY_TAB LIKE ACCHD_KEY OCCURS PACKAGE_SIZE WITH HEADER LINE,
ACCTIT_KEY_TAB LIKE ACCIT_KEY OCCURS PACKAGE_SIZE WITH HEADER LINE.
DATA:
BEGIN OF ACCTCR_KEY_TAB OCCURS PACKAGE_SIZE.
INCLUDE STRUCTURE ACCCR_KEY.
DATA:
WAERS LIKE ACCTCR-WAERS,
END OF ACCTCR_KEY_TAB,
DEL_COUNT TYPE I.
PARAMETERS: P_TEST AS CHECKBOX DEFAULT 'X'.
* Delete table ACCTHD completely
CLEAR DEL_COUNT.
IF P_TEST IS INITIAL.
DO.
* for runtime-estimations only: Just check how long 1000 deletes
* would take via taking off the asterix of the following line
* and commenting off the latter one:
* DO 1 TIMES.
*
SELECT MANDT
AWTYP
AWREF
AWORG
FROM ACCTHD
INTO TABLE ACCTHD_KEY_TAB
UP TO PACKAGE_SIZE ROWS.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
DELETE ACCTHD FROM TABLE ACCTHD_KEY_TAB.
COMMIT WORK.
DEL_COUNT = DEL_COUNT + SY-DBCNT.
REFRESH ACCTHD_KEY_TAB.
CLEAR ACCTHD_KEY_TAB.
ENDDO.
WRITE: / 'Table ACCTHD: ', DEL_COUNT, ' records deleted'.
ELSE.
SELECT COUNT(*) FROM ACCTHD INTO DEL_COUNT.
WRITE: / 'Table ACCTHD: ', DEL_COUNT, ' records read'.
ENDIF.
* DELETE TABLE ACCTIT COMPLETELY
CLEAR DEL_COUNT.
IF P_TEST IS INITIAL.
DO.
* for runtime-estimations only: Just check how long 1000 deletes
* would take via taking off the asterix of the following line
* and commenting off the latter one:
* DO 1 TIMES.
*
SELECT MANDT
AWTYP
AWREF
AWORG
POSNR
FROM ACCTIT
INTO TABLE ACCTIT_KEY_TAB
UP TO PACKAGE_SIZE ROWS.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
DELETE ACCTIT FROM TABLE ACCTIT_KEY_TAB.
COMMIT WORK.
DEL_COUNT = DEL_COUNT + SY-DBCNT.
REFRESH ACCTIT_KEY_TAB.
CLEAR ACCTIT_KEY_TAB.
ENDDO.
WRITE: / 'Table ACCTIT: ', DEL_COUNT, ' records deleted'.
ELSE.
SELECT COUNT(*) FROM ACCTIT INTO DEL_COUNT.
WRITE: / 'Table ACCTIT: ', DEL_COUNT, ' records read'.
ENDIF.
* Delete table ACCTCR completely
CLEAR DEL_COUNT.
IF P_TEST IS INITIAL.
DO.
* for runtime-estimations only: Just check how long 1000 deletes
* would take via taking off the asterix of the following line
* and commenting off the latter one:
* DO 1 TIMES.
*
SELECT MANDT
AWTYP
AWREF
AWORG
POSNR
CURTP
WAERS
FROM ACCTCR
INTO TABLE ACCTCR_KEY_TAB
UP TO PACKAGE_SIZE ROWS.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
DELETE ACCTCR FROM TABLE ACCTCR_KEY_TAB.
COMMIT WORK.
DEL_COUNT = DEL_COUNT + SY-DBCNT.
REFRESH ACCTCR_KEY_TAB.
CLEAR ACCTCR_KEY_TAB.
ENDDO.
WRITE: / 'Table ACCTCR: ', DEL_COUNT, ' records deleted'.
ELSE.
SELECT COUNT(*) FROM ACCTCR INTO DEL_COUNT.
WRITE: / 'Table ACCTCR: ', DEL_COUNT, ' records read'.
ENDIF.
网友评论