Professional Documents
Culture Documents
Abap News For 740 Sp08 Open SQL PDF
Abap News For 740 Sp08 Open SQL PDF
40,
SP08 - Open SQL
The most important news for Open SQL in ABAP 7.40, SP08 are as follows:
FROM scarr
INTO @DATA(result).
cl_demo_output=>display( result ).
Or for a table
FROM scarr
INTO TABLE @DATA(result).
cl_demo_output=>display( result ).
Either an elementary data object, a structure, or an internal table is declared depending on the results set
defined in the SELECT list. See the documentation for details of the type construction.
SQL Expressions
The SQL expressions introduced with 7.40, SP05 into the SELECT list were enhanced with 7.40, SP08 as
follows:
Column Specification
In the SELECT list, you can specify all columns of a data source using the syntax data_source~* from 7.40,
SP08 on. This can be handy when working with joins.
Position of INTO
Did you realize the position of INTO in the above examples? I positioned it after the other clauses. This was not
possible before. From 7.40, SP08 on, the INTO clause can and should (haha) be used after the other clauses
of a SELECT statement. The additions UP TO n ROWS, BYPASSING BUFFER, and CONNECTION that are
not treated as clauses must then be placed after the INTO clause.
The rationale behind this change is, that the INTO clause is not part of standard SQL but defines the data
interface between SQL and ABAP. In order to enable future enhancements in the SQL part of Open SQL, e.g.
UNION, the INTO clause has to be removed from the SQL part.
Some restrictions have been removed. E.g. from 7.40, SP08 on you can place a minus sign in front of an
operator of an arithmetic expression in the SELECT list, you can carry out a simple CASE for aggregates, you
can use LIKE and IN (...) in join conditions after ON, you can specify a subquery after WHERE dynamically.
But if you use any of the new things listed here, as already for SP05, the syntax check for Open SQL is carried
out in a strict mode, where stricter syntax rules apply. E.g. you must use comma separated lists and the
escape symbol @ in front of host variables. By this, at least in Open SQL ABAP enforces a release dependent
deprecation concept in a downward compatible way. Now what do you think about that?
52622 Views
Marco Bohmbach
25 May, 2016 5:07 PM
Is there a chance to get a case insensitive open sql search? It would be useful in association with odata.
The expressions cannot contain any or ABAP literals as operands, with the exception of
statically identifiable constants or literals with the
data type i with any content, but not as an argument of the or of the function.
data type c with length 1 and the content "X" or a blank, but not as an argument of
the function.
Aasim Khan
20 Apr, 2016 12:27 PM
Hello Horst,
We're on 740/SP13 where the below SELECT statement with GROUP BY..CASE works perfectly fine.
However, when I use a string expression in GROUP BY..CASE, it gives me an error for the below SELECT
statement.
Does this mean, GROUP BY..CASE works only for numeric expressions and not for string?
Michael Calekta
that the resulting table is of the type STANDARD TABLE WITH EMPTY KEY, or does the table inherit the
primary keys of the database-table?
Stefan Schmcker
19 Dec, 2015 7:11 PM
Hello Horst,
I am finally able to use the SP08 features. But even though the new position of the INTO-Clause works fine for
the syntaxchecker, the editor doesn't really seem to like it and marks it as faulty.
This is a known bug that came in with 7.40, SP08 (kernel 7.42) and is solved with note 2127182.
Horst
Johann Fleitner
17 Nov, 2015 9:26 AM
Hello Horst,
we have Release 7.40 SP11. I wonder of the result of the following SQL Expression:
ELSE 'CC'
END AS group,
partner,
partner_guid
FROM but000
ORDER BY group.
The first column of lt_result is a CHAR, length 2! (I would expect 3 because of the 'BBB':
If I remove the "ELSE" of CASE, then the column has the correct length of 3.
Is that correct?
If the content of a host variable read in an operand position needs to be converted to the
target type, this is done using the rules for lossless assignments. If the assignment cannot
be lossless, an exception is raised.
Jacques Nomssi
13 Nov, 2015 1:00 PM
Hello Horst,
FORM test1.
CONSTANTS c_langu TYPE char10 VALUE 'ENGLISH'.
DATA ls_t100 TYPE t100.
FORM test2.
CONSTANTS c_langu TYPE char10 VALUE 'ENGLISH'.
best regards,
JNN
You will use the advanced view building capabilities of CDS in order to persist your model and Open SQL - well
as embedded SQL within ABAP programs.
As long as Open SQL does not offer the same functions and expressions as ABAP CDS, you can create a
CDS view that encapsulates your SELECT with a SUBSTRING function and select it with Open SQL as a
workaround.
Daniel Rothmund
2 Jan, 2015 12:10 PM
One question are there any plans for SUBSTR function or LEFT / RIGHT? I don't found any infos about it in
ABAP Keyword Documentation .
f.e.
In the past we must select the data from the database and then do a loop and drop out the lines which doesn't
mach the abap substr in the loop.
Regards
Uwe Fetzer
16 Oct, 2014 5:09 PM
Today I already wanted to use the new SQL syntax for a client report, but went into a problem.
The following two statements work (and no, this is not from the client report):
SELECT carrid,
connid,
fldate,
'X' AS test
INTO TABLE @DATA(lt_result)
FROM sflight
WHERE carrid = @carrid.
and
SELECT carrid,
connid,
fldate
INTO TABLE @DATA(lt_result)
FROM sflight
FOR ALL ENTRIES IN @carrids
WHERE carrid = @carrids-carrid.
SELECT carrid,
connid,
fldate
'X' AS test
INTO TABLE @DATA(lt_result)
FROM sflight
FOR ALL ENTRIES IN @carrids
WHERE carrid = @carrids-carrid.
(and maybe the "together" should be placed directly after "literals" to make the message clearer because it
seems only the combination of both is not valid -> "Host variables and literals together are not permitted in
expressions with the addition FOR ALL ENTRIES.")
Great blog...
Thanks...
Ok ,
'You might like this one. You can place inline declarations with the declaration operator DATA( ... ) that was
introduced with 7.40, SP02 behind INTO now.'
sorry
Daniel Rothmund
9 Oct, 2014 1:22 PM
Hi Horst ,
i tried the :
SELECT carrname AS name, carrid AS id
FROM scarr
INTO TABLE @DATA(result).
Does I need SP 8 ?
Don't be overmodest
And of course, many thanks to the guys from Open SQL team.
New ABAP. M-m-m, I'm loving it (c)
Nikolay Evstigneev
9 Oct, 2014 10:49 AM
Horst, it's a tremendous update!!!
One of my fellows used to work with a non-SAP system which supported such features. And he was looking
forward to getting the possibility of writing SQL queries as he had accustomed to.
Suhas Saha
8 Oct, 2014 4:02 PM
Now what do you think about that?