최종 작성일: 2024-05-29
목표: Collect 구문 이해하기
*&---------------------------------------------------------------------*
*& Report ZTEST_COLLECT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZTEST_COLLECT.
* internal table Structure creation
"같은 것 끼리 집계하는 것이 collect 문임
TYPES: BEGIN OF t_product,
pid(10) TYPE C,
pname(40) TYPE C,
pamount(10) TYPE P, "pack number (실수)
END OF t_product.
* Data & internal table declaration
DATA: wa TYPE t_product,
it TYPE TABLE OF t_product.
* inserting data to the internal table of INDEX 1
wa-pid = 'IFB1'.
wa-pname = 'IFB WASHING MACHINE'.
wa-pamount = 31000.
COLLECT wa INTO it.
* inserting data to the internal table of INDEX 1
wa-pid = 'IFB1'.
wa-pname = 'IFB WASHING MACHINE'.
wa-pamount = 30000.
COLLECT wa INTO it.
* inserting data to the internal table of INDEX 2
wa-pid = 'IFB2'.
wa-pname = 'IFB SPLIT AC'.
wa-pamount = 38000.
COLLECT wa INTO it.
* inserting data to the internal table of INDEX 2
wa-pid = 'IFB2'.
wa-pname = 'IFB SPLIT AC'.
wa-pamount = 32000.
COLLECT wa INTO it.
* Reading internal table for all the records
LOOP AT it INTO wa.
IF sy-subrc = 0.
WRITE :/ wa-pid, wa-pname, wa-pamount.
ELSE.
WRITE 'No Record Found'.
ENDIF.
ENDLOOP.
'SAP > ABAP' 카테고리의 다른 글
ALV로 집계테이블 만들기 (LOOP AT, COLLECT) (0) | 2024.05.31 |
---|---|
Loop 구문과 Collect 구문의 구조 (0) | 2024.05.29 |
Loop 구문 (1) | 2024.05.29 |
중첩 Join시 유의 사항 (0) | 2024.05.29 |
중첩 INNER (0) | 2024.05.20 |