讀寫並插入內部表

使用標題行讀取,寫入和插入內部表:

" 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