sapdev logo background
sapdev logo sapdev logo
Comments

ABAP UPDATE SET EXPRESSION Statement syntax, information and example SAP source code



Return to Statement index



UPDATE dbtab - set_expression

Short Reference

ABAP Syntax ... [col1 = f1 col2 = f2 ... ]
[col1 = col1 + f1 col2 = col2 + f2 ...]
[col1 = col1 - f1 col2 = col2 - f2 ...]
[(expr_syntax1) (expr_syntax2) ...] ... .

ABAP_ADDITIONS:
1 ... col = f
2 ... col = col + f
3 ... col = col - f
4 ... (expr_syntax)

What does it do? Change expressions for the addition SET of the statement UPDATE . The individual modifying expressions can be defined in any number of ways.

ABAP_ADDITION_1 ... col = f

What does it do? Assigning a value. For col , columns of the database table given in target or in the specified view dbtab can be specified using a column name comp or dbtab~comp . For f , data objects of the ABAP program or a column name dbtab~comp of another column in the database table can be used.
The statement UPDATE assigns the content of f to the columns col in all the rows defined by the WHERE condition. If the data types are not
compatible , they are converted as follows:
When assigning a data object that is not a reference variable for a LOB handle , the content is converted, if required, to the ABAP data type appropriate to the data type of the column (and in accordance with the conversion rules ). Any errors in the conversion raise the appropriate non-handleable exception.
When assigning a data object that is a reference variable for a LOB handle , the column col must be a LOB with an appropriate type. If the reference has a writer stream type, then a writer stream is created. In this case of a type for a locator : this must exist and is used as a source. For details, see LOB handle s .
When assigning a different column, the content is converted, if required, in the database system. Whether a conversion is possible and the conversion rules are specific to the database system. Any errors in the conversion raise the handleable exception CX_SY_OPEN_SQL_DB .
In the assignment, the assigned value must fit in the value range of the column. Otherwise the handleable exception CX_SY_OPEN_SQL_DB is raised. This applies in particular for:
Assignments to numeric columns
Assignments to columns of the type SSTRING , STRING , or RAWSTRING . The assigned content must not be longer than the maximum length of the columns in the database structure. This length can be determined using the predefined function dbmaxlen .
If a column is specified for f , changes to this column that are made in the same UPDATE statement are ignored during the assignment.
If a column col appears in multiple change expressions, the last change expression applies.

ABAP_ADDITION_2 ... col = col + f

What does it do? Addition of a value. For col and f , the same applies as for the assignment of a value. However, col must have a numeric data type. The data types DF16_RAW , DF16_SCL
, DF34_RAW , and DF34_SCL are not permitted.
The statement UPDATE adds the value of f to the content of the column col , in all the rows defined by the WHERE condition. Otherwise, the same rules apply as for the assignment of a value.

ABAP_ADDITION_3 ... col = col - f

What does it do? Subtraction of a value. For col and f , the same applies as for the assignment of a value. However, col must have a numeric data type. The data types DF16_RAW , DF16_SCL
, DF34_RAW , and DF34_SCL are not permitted.
The statement UPDATE subtracts the value of f from the content of the column col , in all the rows defined by the
WHERE condition. Otherwise, the same rules apply as for the assignment of a value.

ABAP_ADDITION_4 ... (expr_syntax)

What does it do? Dynamic specification of change expressions. A change expression can be specified as a parenthesized data object
expr_syntax that, when the statement is executed, either contains the syntax of one or more static change expressions or is initial. The data object expr_syntax can be a character-like data object or a standard table without secondary table keys and with a character-like data object. The syntax in expr_syntax is not case-sensitive, as in ABAP Editor. When an internal table is specified, the syntax can be distributed across multiple rows.
If expr_syntax is initial when the statement is executed, the change expression is ignored.
See SQL Injections Using Dynamic Tokens .
Latest notes: If expr_syntax is an internal table with a header line , the table body is evaluated and not the header line.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




UPDATE_OBSOLETE
UPDATE_SOURCE




comments powered by Disqus