Open SQL is a subset of the standard SQL92 language. Open SQL contains only Data Manipulation Language (DML) statements (SELECT, INSERT, and DELETE). Open SQL does not contain any Data Definition Language (DDL) statements (CREATE TABLE or CREATE INDEX).

Functions of OPEN SQL type are contained in the ABAP Dictionary. Open SQL contains all the DML functions from SQL92 that are common to all of the database systems supported by SAP.

ABAP programs that use only Open SQL statements to access the database are fully portable. The database interface converts the OPEN SQL commands into commands of the relevant database.

Open SQL is a set of ABAP statements that perform operations on the database in the SAP ABAP. The results of the operations or any error messages are independent of the database system where the operations are performing currently.

Open SQL provides a same syntax and semantics for all the database systems supported by SAP. ABAP programs that are coded with Open SQL statements works as same in any SAP system regardless of the database system in use.

Open SQL statements can only work with database tables created in the ABAP Dictionary. Open SQL statements that performs operations like read, write, modify, insert, update or delete on the data in the SAP database.

Open SQL statements are passed to the database interface. The database interface converts the open SQL to native SQL and passes it to the database to get the results.

Views are handled in the same way as database tables in open SQL statements. Below diagram specifies the architecture of the Open SQL interface with relational database -

Open SQL Diagram

List of Open SQL Statements -

CLEARClears the data from a field or variable.
SELECT Reads the data from database tables.
INSERT Inserts data as row or line to database tables.
UPDATE Changes the row or line contents of database tables.
MODIFY Changes the row or line contents of existing lines.
DELETE Deleting row or line from Database Tables.

Return Codes -

All Open SQL statements return codes fill in the following two system fields -

sy-subrc -

After every Open SQL statement execution, the system field sy-subrc updated with value 0 if the operation was successful, other than 0 if not successful.

sy-dbcnt -

After an open SQL statement execution, the system field sy-dbcnt contains the number of database lines processed.


Clear statement clears out the data from a variable or a field. It allows to reuse the same variables or fields to fill with new data after clearing.

Syntax -

CLEAR variable/field.

Normally, the variables/field cleared out when the variable/fields used for the next performing operation as a new. It is not mandatory to clear the data everytime. However it is better to perform CLEAR operation before moving any data to a variable or field.