+|
+Reading a row from a database table into a structure that has a compatible type
+ |
+
+
+Note that, since database tables are flat, the
target structure must also be flat. In the example below, the [`SINGLE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapselect_single.htm)
addition reads only a single row into the structure. It returns the first entry that matches the `WHERE` condition.
@@ -650,7 +668,15 @@ SELECT SINGLE FROM zdemo_abap_fli
WHERE carrid = 'LH'
INTO @DATA(ls_fli2).
```
-**Reading a row from a database table into a structure that has an incompatible type**.
+ |
+
+
+
+|
+
+Reading a line from an internal table into a structure using an ABAP SQL `SELECT` statement
+ |
+
+
+Note the specified alias name and that ABAP variables like internal tables must be escaped with `@`. The addition `INTO CORRESPONDING FIELDS OF` also applies here.
``` abap
SELECT SINGLE FROM @itab AS itab_alias
FIELDS *
@@ -669,25 +703,17 @@ SELECT SINGLE FROM @itab AS itab_alias
INTO @DATA(ls_struc).
"INTO CORRESPONDING FIELDS OF @some_existing_struc.
```
-... using a `READ TABLE` statement. The code snippet below shows the reading of a line into a [work area](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenwork_area_glosry.htm "Glossary Entry"), a [field symbol](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfield_symbol_glosry.htm "Glossary Entry"), and a [data reference variable](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abendata_reference_variable_glosry.htm "Glossary Entry"), all of which
-represent structured data objects that are declared inline. In the following example, a line is read based on the line number by
-specifying `INDEX`. For more details, see the section *Determining the target area* in the cheat sheet [Internal Tables](01_Internal_Tables.md#).
-``` abap
-READ TABLE itab INTO DATA(wa) INDEX 1.
+ |
+
-READ TABLE itab ASSIGNING FIELD-SYMBOL() INDEX 2.
-READ TABLE itab REFERENCE INTO DATA(dref) INDEX 3.
-```
-... using a [table expression](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentable_expression_glosry.htm "Glossary Entry").
-The code snippet shows how to read a line into a structure declared inline. The index is given in square brackets.
-``` abap
-DATA(ls_table_exp) = itab[ 3 ].
-```
+
+|
+Sequentially reading a row from a database table into a structure
+ |
+
-**Sequentially reading** ...
-
-... a row from a database table into a structure. A `SELECT` loop can be specified with the syntax `SELECT ... ENDSELECT.`.
+A `SELECT` loop can be specified with the syntax `SELECT ... ENDSELECT.`.
In the following example, the row found and returned in a structure declared inline can be processed further.
``` abap
SELECT FROM zdemo_abap_fli
@@ -700,16 +726,18 @@ SELECT FROM zdemo_abap_fli
ENDIF.
ENDSELECT.
```
-... a line from an internal table into a structure using a [`LOOP AT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_variants.htm) statement. There are many ways to specify the condition on which the loop is based. The following example covers the option of reading all lines sequentially into a field symbol declared inline. When using a field symbol, you can, for example, directly modify components.
-``` abap
-LOOP AT itab ASSIGNING FIELD-SYMBOL().
- -comp1 = ...
- ...
-ENDLOOP.
-```
+ |
+
-**Inserting a single row into a database table from a structure** using ABAP SQL statements with
-[`INSERT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapinsert_dbtab.htm). The following statements can be considered as alternatives. The third statement shows that instead of inserting a row from an existing structure, you can create and fill a structure directly.
+
+|
+
+Inserting a single row into a database table from a structure using ABAP SQL statements with
+[`INSERT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapinsert_dbtab.htm)
+ |
+
+
+The following statements can be considered as alternatives. The third statement shows that instead of inserting a row from an existing structure, you can create and fill a structure directly.
Note that you should avoid inserting a row with a particular key into the database table if a row with the same key already exists. Note that with this and the followig syntax, various options/expressions are possible.
``` abap
INSERT INTO dbtab VALUES @struc.
@@ -718,7 +746,17 @@ INSERT dbtab FROM @struc.
INSERT dbtab FROM @( VALUE #( comp1 = ... comp2 = ... ) ).
```
-**Updating a single row in a database table from a structure** using ABAP SQL statements with [`UPDATE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapupdate.htm). Note that this syntax changes the entire row and all of its components.
+ |
+
+
+
+|
+
+Updating a single row in a database table from a structure using ABAP SQL statements with [`UPDATE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapupdate.htm)
+ |
+
+
+Note that this syntax changes the entire row and all of its components.
``` abap
UPDATE dbtab FROM @struc.
@@ -733,15 +771,117 @@ SELECT SINGLE *
UPDATE dbtab FROM @( VALUE #( BASE wa comp2 = ... comp4 = ... ) ).
```
-**Updating or creating a single row in a database table from a structure** using ABAP SQL statements with
-[`MODIFY`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmodify_dbtab.htm). If a row with the same key as specified in the structure already exists in the database table, the row is updated. If no row with the keys specified in the structure exists, a new row is created in the database table.
+ |
+
+
+
+|
+
+Updating or creating a single row in a database table from a structure using ABAP SQL statements with
+[`MODIFY`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmodify_dbtab.htm)
+ |
+
+
+If a row with the same key as specified in the structure already exists in the database table, the row is updated. If no row with the keys specified in the structure exists, a new row is created in the database table.
``` abap
MODIFY dbtab FROM @struc.
MODIFY dbtab FROM @( VALUE #( comp1 = ... comp2 = ... ) ).
```
-**Adding lines to and updating single lines in an internal table from a structure** using `INSERT`,
-`APPEND`, and `MODIFY` statements.
+ |
+
+
+
+|
+
+Deleting a single row in a database table from a structure using ABAP SQL statements with
+[`DELETE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapdelete_dbtab.htm)
+ |
+
+
+If a row with the same key as specified in the structure already exists in the database table, the row is updated. If no row with the keys specified in the structure exists, a new row is created in the database table.
+``` abap
+DELETE dbtab FROM @struc.
+
+DELETE dbtab FROM @( VALUE #( comp1 = ... ) ).
+```
+ |
+
+
+