Get Example source ABAP code based on a different SAP table
INSERT>, FROM SELECT> This example demonstrates the statement INSERT>> with the addition FROM SELECT>>.
ABAP_SOURCE_CODE DEMO CL_DEMO_INSERT_FROM_SELECT
ABAP_DESCRIPTION The DDIC database table DEMO_SUMDIST_AGG >> is filled with aggregated data from the tables SCARR>> and SPFLI>>.
First, a standalone SELECT> statement is used to read the aggregated data into an internal table and then the statement INSERT > is used to write it to the DDIC database table. This requires two database reads and the transport of the data between the database server and the AS ABAP.
The same SELECT> statement is then used directly as a subquery in the INSERT> statement. Only a single database read and no transport of data between the database server and the AS ABAP is then required. The result of both INSERT> statements is the same. DEMO_SUMDIST_AGG> is a global temporary table (GTT)> , which means that its content must be deleted before the results are produced, since this creates an implicit database commit.