SAP OO OBS SQL WA 1

Get Example source ABAP code based on a different SAP table
  


ABAP Code Snippet
ARTICLE

Cannot Use Short Forms
In ABAP Objects, you must declare work areas explicitly in each SQL statement. You can create data objects with the appropriate type with reference to the definition of the database in the ABAP Dictionary for this purpose.

In ABAP Objects, the following statements cause an error message:

SELECT ... FROM dbtab

INSERT dbtab.

UPDATE dbtab.

DELETE dbtab.

MODIFY dbtab.
Correct syntax:

DATA wa TYPE dbtab.

SELECT ... FROM dbtab INTO wa.

INSERT dbtab FROM wa.
or
INSERT INTO dbtab VALUES wa.

UPDATE dbtab FROM wa.
or
UPDATE dbtab SET ... .

DELETE dbtab FROM wa.
or
DELETE FROM dbtab WHERE ...

MODIFY dbtab FROM wa.
Cause:

Separating database names and ABAP work areas makes programs easier to read. To work with short forms, you need to declare table work areas using the TABLES, which is not allowed in ABAP objects.
Note:

This does not apply to SELECT statements in sub-queries. You cannot use the INTO clause with a sub-query. See the EXISTS construction of the WHERE and HAVING clauses of the SELECT, UPDATE, DELETE, and OPEN CURSOR statements.