수색…
내부 테이블 유형
DATA: <TABLE NAME> TYPE <SORTED|STANDARD|HASHED> TABLE OF <TYPE NAME>
WITH <UNIQUE|NON-UNIQUE> KEY <FIELDS FOR KEY>.
표준 표
이 테이블은 모든 항목이 선형 방식으로 저장되며 레코드는 선형 방식으로 액세스됩니다. 큰 테이블 크기의 경우 테이블 액세스가 느려질 수 있습니다.
정렬 된 테이블
WITH UNIQUE 필요함 | NON-UNIQUE KEY . 이진 검색을 수행하면 검색 속도가 빨라집니다. 정렬 순서를 깨뜨릴 수 있으므로 항목을이 테이블에 추가 할 수 없으므로 항상 INSERT 키워드를 사용하여 INSERT 됩니다.
해쉬 테이블
WITH UNIQUE 필요함 | NON-UNIQUE KEY . 독점적 인 해싱 알고리즘을 사용하여 키 - 값 쌍을 유지합니다. 이론적으로 검색은 STANDARD 표만큼 느릴 수 있지만 표의 크기와 관계없이 일정한 시간을 소비하는 SORTED 표보다 실제로 빠릅니다.
ABAP 내부 테이블 선언
로컬 타입 정의에 기반한 내부 테이블 선언
" Declaration of type
TYPES: BEGIN OF ty_flightb,
id TYPE fl_id,
dat TYPE fl_date,
seatno TYPE fl_seatno,
firstname TYPE fl_fname,
lastname TYPE fl_lname,
fl_smoke TYPE fl_smoker,
classf TYPE fl_class,
classb TYPE fl_class,
classe TYPE fl_class,
meal TYPE fl_meal,
service TYPE fl_service,
discout TYPE fl_discnt,
END OF lty_flightb.
" Declaration of internal table
DATA t_flightb TYPE STANDARD TABLE OF ty_flightb.
데이터베이스 테이블에 기반한 선언
DATA t_flightb TYPE STANDARD TABLE OF flightb.
인라인 내부 테이블 선언
ABAP 버전> 7.4가 필요합니다.
TYPES t_itab TYPE STANDARD TABLE OF i WITH EMPTY KEY.
DATA(t_inline) = VALUE t_itab( ( 1 ) ( 2 ) ( 3 ) ).
헤더 행 선언이있는 내부 테이블
ABAP에는 헤더 행이있는 테이블과 헤더 행이없는 테이블이 있습니다. 헤더 행이있는 테이블은 오래된 개념이므로 새 개발에 사용하면 안됩니다.
내부 테이블 : 헤더 라인이 있거나없는 표준 테이블
이 코드는 테이블 i_compc_all 을 i_compc_all 의 기존 구조로 compc_str 합니다.
DATA: i_compc_all TYPE STANDARD TABLE OF compc_str WITH HEADER LINE.
DATA: i_compc_all TYPE STANDARD TABLE OF compc_str.
내부 테이블 : 헤더 라인이 있거나없는 해시 테이블
DATA: i_map_rules_c TYPE HASHED TABLE OF /bic/ansdomm0100 WITH HEADER LINE
DATA: i_map_rules_c TYPE HASHED TABLE OF /bic/ansdomm0100
헤더가없는 테이블의 작업 영역 선언
작업 영역 (일반적으로 약 기함 WA)는 테이블과 동일한 구조를 갖지만, 하나의 라인을 포함 할 수있다 (a WA는 하나의 치수를 갖는 테이블의 구조이다).
DATA: i_compc_all_line LIKE LINE OF i_compc_all.
내부 테이블에 읽기, 쓰기 및 삽입
읽기, 쓰기 및 헤더 행이있는 내부 테이블에 삽입 :
" Read from table with header (using a loop):
LOOP AT i_compc_all. " Loop over table i_compc_all and assign header line
CASE i_compc_all-ftype. " Read cell ftype from header line from table i_compc_all
WHEN 'B'. " Bill-to customer number transformation
i_compc_bil = i_compc_all. " Assign header line of table i_compc_bil with content of header line i_compc_all
APPEND i_compc_bil. " Insert header line of table i_compc_bil into table i_compc_bil
" ... more WHENs
ENDCASE.
ENDLOOP.
주의 사항 : 객체 지향 컨텍스트에서는 헤더 행이있는 내부 테이블을 사용할 수 없습니다. 헤더 행 없이 내부 테이블 을 사용하는 것이 항상 권장됩니다.
헤더 행없이 읽기, 쓰기 및 내부 테이블에 삽입 :
" Loop over table i_compc_all and assign current line to structure i_compc_all_line
LOOP AT i_compc_all INTO i_compc_all_line.
CASE i_compc_all_line-ftype. " Read column ftype from current line (which as assigned into i_compc_all_line)
WHEN 'B'. " Bill-to customer number transformation
i_compc_bil_line = i_compc_all_line. " Copy structure
APPEND i_compc_bil_line TO i_compc_bil. " Append structure to table
" more WHENs ...
ENDCASE.
ENDLOOP.
" Insert into table with Header:
INSERT TABLE i_sap_knb1. " insert into TABLE WITH HEADER: insert table header into it's content
insert i_sap_knb1_line into table i_sap_knb1. " insert into HASHED TABLE: insert structure i_sap_knb1_line into hashed table i_sap_knb1
APPEND p_t_errorlog_line to p_t_errorlog. " insert into STANDARD TABLE: insert structure / wa p_t_errorlog_line into table p_t_errorlog_line