サーチ…
内部テーブルのタイプ
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キーワードを使用して常に挿入されます。
ハッシュテーブル
WITH UNIQUE追加する必要があります。 NON-UNIQUE KEY 。独自のハッシングアルゴリズムを使用して、キーと値のペアを維持します。理論的にはSTANDARDテーブルと同じくらい遅くても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の既存の構造と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を省略)は、表とまったく同じ構造を持ちますが、1行しか含めることはできません(WAは1次元のみの表の構造です)。
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