The term ‘Native SQL’ refers to all statements that can be statically transferred to the Native SQL interface of the database interface. Native SQL statements do not fall within the language scope of ABAP and do not follow the ABAP syntax. ABAP merely contains statements for isolating program sections in which Native SQL statements can be listed.
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.
Following is the syntax −
EXEC SQL PERFORMING <form>.
<Native SQL statement>
ENDEXEC.
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 −
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.
DATA c1 TYPE SPFLI-carrid VALUE 'LH'.
EXEC SQL PERFORMING loop_output.
SELECT connid, cityfrom, cityto
INTO :wa
FROM SPFLI
WHERE carrid = :c1
ENDEXEC.
FORM loop_output.
WRITE: / wa-connid, wa-cityfrom, wa-cityto.
ENDFORM.
The above code produces the following output −
0400 FRANKFURT NEW YORK
2402 FRANKFURT BERLIN
0402 FRANKFURT NEW YORK
73 videos|68 docs
|
1. What is SAP ABAP Native SQL? |
2. How is SAP ABAP Native SQL different from Open SQL? |
3. Can SAP ABAP Native SQL be used for all database operations? |
4. What are the advantages of using SAP ABAP Native SQL? |
5. Are there any limitations to using SAP ABAP Native SQL? |
|
Explore Courses for Software Development exam
|