Tuesday, 10 January 2012

ABAP/4 Basics : Open SQL


OPEN SQL

In the R/3 System, long-life data is stored in relational database tables. Structured Query Language (SQL) was created for accessing relational Database. SQL has two statement types: Data Definition Language (DDL) statements and Data Manipulation Language (DML) statements. TO include SQL statements in an ABAP/4 program, use Native SQL. To avoid incompatibilities between different database tables and also to make ABAP/4 program independent of the database system in use, SAP has created a set of separate SQL statements called Open SQL. Open SQL contains a subset of standard SQL statements as well as some enhancements, which are specific to SAP.

Using Open SQL enables you to access any database tables available to the SAP system regardless of the manufacturer be it Oracle, Informix etc. The difference between Open SQL and Native SQL is as follows: A database interface translates SAP’s Open SQL statements into SQL commands specific to the database in use. Native SQL statements access the database directly.

Open SQL keywords
· SELECT: Reading Data from Database Tables
· INSERT: Adding Lines to Database Tables
· UPDATE: Changing Lines in Database Tables
· MODIFY: Adding or Changing Lines
· DELETE: Deleting Lines from Database Tables

When using Open SQL statements in an ABAP/4 program, you must ensure
the following:

1) The database system being addressed must be supported by SAP.
2) The database tables being addressed must be defined in the ABAP/4 Dictionary.

The following system fields play an important role in Open SQL operations:

SY-SUBRC

As with other ABAP/4 statements, the return code value in the system field SY-SUBRC indicates after each Open SQL operation whether or not the operation was successful. If an operation is successful, SY-SUBRC = 0. If an operation is unsuccessful – SY-SUBRC <> 0

SY-DBCNT

The value in the SY-DBCNT field indicates how many lines were affected by the operation or how many lines have already been processed.

No comments:

Post a Comment