I had the problem on a DEV-environment that the PY-results were a mess. I had double keys in the PCL2 table that made it impossible to remove the data via the standard SAP-programs RPUDEL20 or RPCDPU01.
That is why I created my own program that is based on the Logical database PNP.
Please handle with care, you don't want to execute this program on you Productive-systems
REPORT ZHR_DEL_PY.
TABLES: pernr.
DATA: BEGIN OF rgdir OCCURS 0.
INCLUDE STRUCTURE pc261.
DATA: END OF rgdir.
DATA: C_PERNR(8), C_SEQNR(5).
DATA: SORTFIELD(40).
RANGES: SORTFD FOR SORTFIELD.
START-OF-SELECTION.
GET PERNR.
* READ THE RGDIR
REFRESH RGDIR.
CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
persnr = pernr-pernr
no_authority_check = 'X'
TABLES
in_rgdir = rgdir
EXCEPTIONS
no_record_found = 1
OTHERS = 2.
LOOP AT rgdir.
MOVE pernr-pernr TO C_PERNR.
MOVE rgdir-SEQNR TO C_SEQNR.
CONCATENATE C_PERNR C_SEQNR INTO SORTFD-LOW.
SORTFD-SIGN = 'I'. "in
SORTFD-OPTION = 'EQ'. "equal
APPEND SORTFD.
ENDLOOP.
CHECK SY-SUBRC = 0.
DELETE FROM PCL2
WHERE RELID = 'RB'
AND SRTFD IN SORTFD.
DELETE FROM PCL2
WHERE RELID = '$$'
AND SRTFD IN SORTFD.
DELETE FROM PCL2
WHERE RELID = 'CU'
AND SRTFD = pernr-pernr.
IF SY-SUBRC = 0.
LOOP AT RGDIR.
DELETE FROM HRPY_RGDIR WHERE
PERNR = pernr-pernr AND
SEQNR = rgdir-SEQNR.
DELETE FROM HRPY_WPBP WHERE
PERNR = pernr-pernr AND
SEQNR = RGDIR-SEQNR.
DELETE FROM HRPY_GROUPING WHERE
PERNR = pernr-pernr AND
SEQNR = RGDIR-SEQNR.
DELETE FROM P01O_ZVB_RR WHERE
PERNR = pernr-pernr AND
EAPER = RGDIR-FPPER.
ENDLOOP.
ENDIF.
COMMIT WORK.
WRITE: / 'You deleted <', pernr-pernr, '>'.
END-OF-SELECTION.
Geen opmerkingen:
Een reactie posten