26 - SAP ABAP - Native SQL Overview
26 - SAP ABAP - Native SQL Overview
In native SQL, mainly database-specific SQL statements can be used. These are
transferred unchanged from the native SQL interface to a database system and
executed. The full SQL language scope of the relevant database can be used and the
addressed database tables do not have to be declared in the ABAP Dictionary. There is
also a small set of SAP specific Native SQL statements that are handled in a specific way
by the native SQL interface.
To use a Native SQL statement, you have to precede it with the EXEC SQL statement and
end with ENDEXEC statement.
https://www.tutorialspoint.com/sap_abap/sap_abap_native_sql_overview.htm 1/3
Page 2 of 3
These statements define an area in an ABAP program where one or more Native SQL
statements can be listed. The statements entered are passed to the Native SQL interface
and then processed as follows −
All SQL statements that are valid for the program interface of the addressed
database system can be listed between EXEC and ENDEXEC, in particular the DDL
(data definition language) statements.
These SQL statements are passed from the Native SQL interface to the database
system largely unchanged. The syntax rules are specified by the database
system, especially the case sensitivity rules for database objects.
If the syntax allows a separator between individual statements, you may include
many Native SQL statements between EXEC and ENDEXEC.
SAP specific Native SQL language elements can be specified between EXEC and
ENDEXEC. These statements are not passed directly from the Native SQL
interface to the database, but they are transformed appropriately.
Example
SPFLI is a standard SAP Table that is used to store Flight schedule information. This is
available within R/3 SAP systems depending on the version and release level. You can
view this information when you enter the Table name SPFLI into the relevant SAP
transaction such as SE11 or SE80. You can also view the data contained in this database
table by using these two transactions.
REPORT ZDEMONATIVE_SQL.
DATA: BEGIN OF wa,
connid TYPE SPFLI-connid,
cityfrom TYPE SPFLI-cityfrom,
cityto TYPE SPFLI-cityto,
END OF wa.
https://www.tutorialspoint.com/sap_abap/sap_abap_native_sql_overview.htm 2/3
Page 3 of 3
FORM loop_output.
WRITE: / wa-connid, wa-cityfrom, wa-cityto.
ENDFORM.
https://www.tutorialspoint.com/sap_abap/sap_abap_native_sql_overview.htm 3/3