ABAP에서 Work Area와 Internal Table(ITAB)은 데이터를 처리하는 데 핵심적인 구조입니다.
Work Area는 단일 레코드를 저장하는 데 사용되는 메모리 영역입니다. 주요 특징은 다음과 같습니다:
예시 코드:
DATA: wa_employee TYPE ty_employee. " 직원 정보를 담는 Work Area 선언
" Work Area에 값 할당
wa_employee-empid = '1001'.
wa_employee-name = '홍길동'.
wa_employee-department = 'IT'.
Internal Table은 메모리에 여러 개의 레코드를 저장할 수 있는 테이블 구조입니다. 주요 특징은 다음과 같습니다:
예시 코드:
" Internal Table 선언
DATA: it_employees TYPE TABLE OF ty_employee.
" 데이터 추가
APPEND wa_employee TO it_employees.
" Internal Table 순회
LOOP AT it_employees INTO wa_employee.
WRITE: / wa_employee-name, wa_employee-department.
ENDLOOP.
" 특정 조건으로 데이터 읽기
READ TABLE it_employees INTO wa_employee WITH KEY empid = '1001'.
Work Area와 Internal Table은 밀접하게 연관되어 사용됩니다:
이 두 구조를 효과적으로 활용하면 ABAP 프로그램에서 데이터를 효율적으로 처리할 수 있습니다.