You are on page 1of 2

UPDATE ( SAP ABAP Keyword) < br/> UPDATE is a keyword used in SAP ABAP programming.

This tutorial covers its introd uction & syntax details. UPDATE Variants 1. UPDATE dbtab SET s1 sn. 2. UPDATE dbtab. or UPDATE *dbtab. or UPDATE (dbtabname) . 3. UPDATE dbtab FROM TABLE itab. or UPDATE (dbtabname) FROM TABLE itab. Effect Updates values in a database table (see Relational database ). You can specify the name of the database table either directly in the form dbtab or at runtime as content s of the field dbtabname . In both cases, the table must be known to the ABAP/4 Dictionary. If you specify the name of the database table directly, the program must also contain an appropriate TABLES statement. Normally, lines are updated o nly in the current client. Data can only be updated using a view if the view ref ers to a single table and was created in the ABAP/4 Dictionary with the maintena nce status No restriction . UPDATE belongs to the Open SQL command set. Notes Authorization checks are not supported by the UPDATE statement. You must include these in the program yourself. Changes to lines made with the UPDATE command only become final after a database commit (see LUW ). Prior to this, any database update can be canceled by a database rol lback (see Programming transactions ). In the dialog system, you cannot rely on the database system locking mechanism a lone to synchronize simultaneous access to the same database by several users. T herefore, it is often necessary to use the SAP locking mechanism . Variant 1 UPDATE dbtab SET s1 sn. Additions 1. WHERE condition 2. CLIENT SPECIFIED Effect Updates values in a database table. If there is no WHERE clause , all lines (in the curr ent client) are updated. If a WHERE condition is specified, only those records w hich satisfy the condition are updated. The SET clause s1 sn identifies the columns to be updated and assigns values to them . Three types of SET statements si are supported: f = g In all selected lines, the database table column determined by f receives the values of the ABAP/4 field or literal g . f = f + g In all selected lines, the contents of the ABAP/4 field or literal g is added to the value in the database table column determined by f . The NULL value remains unchanged. This statement can only be applied to a numeric field. f = f g In all selected lines, the contents of the ABAP/4 field or literal g is subtracted from the value in the database table column determined by f . The NULL value remains unchanged. This statement can only be applied to a numeric field. When the command has been executed, the system field SY-DBCNT contains the numbe r of updated lines.

The return code SY-SUBRC = 0 At SY_SUBRC = 4 No Note With pooled and

value is set as follows: least one line was updated, line was updated because no line could be selected. cluster tables, an UPDATE cannot change any primary key field.

You might also like