Software Development Exam  >  Software Development Notes  >  Learn and Master SAP ABAP  >  SAP ABAP - Native SQL Overview

SAP ABAP - Native SQL Overview | Learn and Master SAP ABAP - Software Development PDF Download

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.
SAP ABAP - Native SQL Overview | Learn and Master SAP ABAP - Software Development

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 −

  • 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. 

    

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

The document SAP ABAP - Native SQL Overview | Learn and Master SAP ABAP - Software Development is a part of the Software Development Course Learn and Master SAP ABAP.
All you need of Software Development at this link: Software Development
73 videos|68 docs

Top Courses for Software Development

FAQs on SAP ABAP - Native SQL Overview - Learn and Master SAP ABAP - Software Development

1. What is SAP ABAP Native SQL?
Ans. SAP ABAP Native SQL is a feature that allows developers to execute SQL statements within ABAP programs directly without using Open SQL.
2. How is SAP ABAP Native SQL different from Open SQL?
Ans. SAP ABAP Native SQL allows for more flexibility and advanced database operations compared to Open SQL, as it enables developers to write and execute complex SQL queries directly.
3. Can SAP ABAP Native SQL be used for all database operations?
Ans. While SAP ABAP Native SQL provides greater flexibility, it is recommended to use it only for specific scenarios where Open SQL limitations are reached, such as complex queries or database-specific operations.
4. What are the advantages of using SAP ABAP Native SQL?
Ans. Some advantages of using SAP ABAP Native SQL include improved performance for complex queries, direct access to database-specific features, and the ability to execute advanced database operations.
5. Are there any limitations to using SAP ABAP Native SQL?
Ans. Yes, there are some limitations to using SAP ABAP Native SQL, such as reduced portability across different database systems and the need for developers to have a good understanding of SQL syntax and database-specific features.
73 videos|68 docs
Download as PDF
Explore Courses for Software Development exam

Top Courses for Software Development

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

practice quizzes

,

SAP ABAP - Native SQL Overview | Learn and Master SAP ABAP - Software Development

,

SAP ABAP - Native SQL Overview | Learn and Master SAP ABAP - Software Development

,

shortcuts and tricks

,

Summary

,

Previous Year Questions with Solutions

,

Objective type Questions

,

MCQs

,

SAP ABAP - Native SQL Overview | Learn and Master SAP ABAP - Software Development

,

Exam

,

Important questions

,

video lectures

,

study material

,

Extra Questions

,

pdf

,

Semester Notes

,

past year papers

,

ppt

,

Free

,

Viva Questions

,

mock tests for examination

,

Sample Paper

;