直接从agr_usrs 里面删除新的
*&---------------------------------------------------------------------*
*& Report ZRPT_BC_ROLEASSIGN_RM_DUP
*&---------------------------------------------------------------------*
*&角色授权去重
*&---------------------------------------------------------------------*
REPORT ZRPT_BC_ROLEASSIGN_RM_DUP.
SELECT AGR_NAME,UNAME,FROM_DAT,TO_DAT
FROM AGR_USERS WHERE AGR_NAME LIKE 'Z%'
ORDER BY AGR_NAME,UNAME,FROM_DAT
INTO TABLE @DATA(LTAGRUSER).
DATA:LTDELTAB LIKE TABLE OF AGR_USERS WITH HEADER LINE.
DATA:LSDEL TYPE AGR_USERS.
DATA:PINDEX TYPE I.
DATA:TMPTO TYPE I.
DATA:TMPEND TYPE I.
DATA:CNT TYPE I.
DESCRIBE TABLE LTAGRUSER[] LINES CNT.
LOOP AT LTAGRUSER INTO DATA(LSTMP).
PINDEX = SY-TABIX + 1.
TMPTO = PINDEX + 10.
IF TMPTO > CNT.
TMPTO = CNT.
ENDIF.
LOOP AT LTAGRUSER INTO DATA(LSTMP1) FROM PINDEX TO TMPTO.
IF LSTMP1-AGR_NAME = LSTMP-AGR_NAME AND LSTMP1-UNAME = LSTMP-UNAME AND LSTMP1-FROM_DAT > LSTMP-FROM_DAT.
MOVE-CORRESPONDING LSTMP1 TO LSDEL.
APPEND LSDEL TO LTDELTAB[].
ENDIF.
ENDLOOP.
ENDLOOP.
DELETE AGR_USERS FROM TABLE LTDELTAB[].