Read, write and insert into internal tables with a header line:
" 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.
Reminder: Internal tables with header lines are forbidden in object oriented contexts. Usage of internal tables without header lines is always recommended.
Read, write and insert into internal tables without a header line:
" 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