메뉴 건너뛰기

SAP 한국 커뮤니티



ASSIGN COMPONENT Tip

꿀꿀윤뚱67 2019.12.13 17:40 조회 수 : 352

FIELD-SYMBOLS : <WA_TAB> TYPE ANY.

 

DATA : BEGIN OF GT_TEMP OCCURS 0,
        BUKRS    LIKE ZSDPRDN021T-BUKRS,
        BUKRST   LIKE T001-BUTXT,
      END OF GT_TEMP.

DATA : BEGIN OF GT_BUKRS OCCURS 0,
          BUKRS  LIKE T001-BUKRS,
          BUKRST LIKE T001-BUTXT,
        END   OF GT_BUKRS.
DATA : GV_BUKRS LIKE GT_BUKRS,
       GT_BUKRST LIKE GT_BUKRS OCCURS 0 WITH HEADER LINE.
FIELD-SYMBOLS : <FS_BUKRS>  TYPE ANY,
                <FS_BUKRST> TYPE ANY,
                <WA_BUKRST> LIKE LINE OF GT_BUKRST.

SELECT BUKRS BUTXT INTO TABLE GT_TEMP FROM T001.

LOOP AT GT_TEMP ASSIGNING <WA_TAB>.

  ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <WA_TAB> TO <FS_BUKRS>.
  IF SY-SUBRC = 0.
    GV_BUKRS-BUKRS = <FS_BUKRS>.
    INSERT GV_BUKRS INTO TABLE GT_BUKRS.

    SORT GT_BUKRS.
    DELETE ADJACENT DUPLICATES FROM GT_BUKRS.
  ENDIF.
ENDLOOP.