ABAP 내부 테이블 중복 제거

1856 단어 abap
내부 테이블을 정렬하고 반복 행을 삭제합니다.
SORT <내부 테이블> BY<필드> [ascending/descending].
DELETE ADJACENT DUPLICATES FROM <내표> COMPARING ALL FIELDS.
*&---------------------------------------------------------------------*
*&      Form  FM_BUTTON_PRT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM FM_BUTTON_PRT.
  LOOP AT IT_DATA INTO WA_DATA.
    IF WA_DATA-SEL = 'X'.
      WA_SELS-PUR_NUM  = WA_DATA-PUR_NUM.
      WA_SELS-CRT_DATE = WA_DATA-CRT_DATE.
      WA_SELS-VEND_NUM = WA_DATA-VEND_NUM.
      WA_SELS-PAY_KEY  = WA_DATA-PAY_KEY .
      WA_SELS-MAT_NUM  = WA_DATA-MAT_NUM .
      WA_SELS-PUR_TXT  = WA_DATA-PUR_TXT .
      WA_SELS-PLT_NUM  = WA_DATA-PLT_NUM .
      WA_SELS-STOR_LOC = WA_DATA-STOR_LOC.
      APPEND WA_SELS TO IT_SELS.
    ENDIF.
  ENDLOOP.
  LOOP AT IT_DATA INTO WA_DATA.
    IF WA_DATA-SEL = 'X'.
      WA_PURNM-PURNM   = WA_DATA-PUR_NUM.
      APPEND WA_PURNM TO IT_PURNM.
      SORT IT_PURNM BY PURNM ASCENDING.
      DELETE ADJACENT DUPLICATES FROM IT_PURNM COMPARING ALL FIELDS.
    ENDIF.
  ENDLOOP.
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      FORMNAME           = 'ZXLI_TEST_002'
    IMPORTING
      FM_NAME            = L_FM_NAME
    EXCEPTIONS
      NO_FORM            = 1
      NO_FUNCTION_MODULE = 2
      OTHERS             = 3.
  CALL FUNCTION L_FM_NAME
    TABLES
      IT_DATA  = IT_SELS
      IT_PURNM = IT_PURNM.
  CLEAR IT_SELS[].

ENDFORM.                    "FM_BUTTON_PRT

좋은 웹페이지 즐겨찾기