Skip to content

FAQ on Open SQL

Kabirul Islam edited this page Nov 16, 2021 · 2 revisions

Open SQL complete guide:

Read the blog for a basic understanding of how SQL works ( example given with snapshots):
[Complete SQL guide](https://blogs.sap.com/2014/05/21/a-complete-guide-to-opensql-statements-step-by-step-tutorial-with-screenshots/)

PN: The examples do not adhere to the latest syntax.

New SQL Syntaxes:
---------------------------------------------------------------------------------------------------------------------------------------
Inline declaration: With NW 740 onwards it is possible to declare the [variable/table/work area] within the SQL.
For example:
SELECT from <table>
       FIELDS <f1>,<f2>,...
       INTO TABLE @DATA(itab)
       UP TO n ROWS.
In the above example, you can replace <f1>,<f2> with actual field name and replace <table> with persistant table name.
The advantages are:
* No need to explicitly define the table structure.
* If your table consist (let's assume) of m number of columns but you want to have only n numbers of the column then inline declaration will take
care of this in runtime.

< You may be surprised with the sequence of KEYWORDS like SELECT FROM INTO etc. The guideline comes with OPEN SQL release 7.50>
Guideline: INTO clause will be the last one for any select query except system clause like "UP TO" "BYPASSING BUFFER" etc. Also with 7.50 release "FIELDS" keyword was introduced.

Clone this wiki locally