
As you already learned, the simplest way to add a new row to an internal table is the APPEND statement with a data object whose type corresponds to the row type of the internal table. This data object is sometimes referred to as work area.
For simple internal tables the work area used in APPEND can be a scalar variable, constant, or a literal. For complex internal tables, the work area has to be structured.
In the example, structured variable connection is used to fill internal table connections.
In principle, there are two ways to declare work area connection:
- Reference the row type st_connection directly
- Reference the row type indirectly using LIKE LINE OF <internal_table>.
Defining work areas with LIKE LINE OF has two advantages:
- It reveals the purpose of the structured variable as work area for the internal table
- It ensures that the work area fits to the internal table, even if the definition of the internal table changes

If you do not fill the work area before the APPEND statement, the new row of the internal table will be filled with type-specific initial values.
Hint
You get the same result with the special variant APPEND INITIAL LINE TO <internal_table>. This variant does not even require a work area.To fill the structured work area, you can either fill the individual components or, as you can see in the example, use a VALUE #( ) expression.

As you can see in the example, you can also use a VALUE #( ) expression directly in the APPEND statement. In this case, you do not need a work area.
Note
This can have a positive effect on the overall memory consumption of your program.
There is a variant of the VALUE #( ) expression that you can assign directly to an internal table. In this variant of VALUE #( ) additional pairs of brackets are used to separate the table rows from each other.
The code example fills internal table carriers with three rows, each with a different value for carrier_id and carrier_name. As a result of this, column currency_code is not mentioned, it is filled with the type specific initial value.
Note
With the assignment above, all existing table rows are removed before the table is filled with the new rows.
To copy data between identically-named fields of two internal tables, use the CORRESPONDING operator. This works similarly to CORRESPONDING for structures: for each row of the source internal table, the system creates a new row in the target internal table and copies data between identically-named fields. Source fields for which there is no identically named field in the target are not copied. Target fields for which there is no identically named field in the source are filled with type-specific initial values.
In the example, the source internal table carriers contains three rows. Therefore, after the value assignment, the target internal table connections also contains three rows.
Fields carrier_id and carrier_name exist in both internal tables. They are copied from source to target. Field currency_code only exists in the source. It is not copied. Fields connection_id, airport_from_id, and airport_to_id exist only in the target. They are filled with initial values.
Note
If the target internal table contains data before the assignment, the system deletes it.