2021 Mar 23 7:15 AM
Hi Experts,
Is it possible to get the result in select statement without using the loop. As hana db is more powerful now, wondering if these kind of statements can be achieved at DB level rather than application server.
SELECT ebeln
FROM ekko
INTO TABLE @lt_ebeln
WHERE ebeln = '<demo_value>'.
LOOP AT lt_ebeln INTO ls_ebeln.
CLEAR ls_range.
ls_range-sign = 'I'.
ls_range-option = 'EQ'.
ls_range-low = ls_ebeln-ebeln.
APPEND ls_range TO gt_ebeln.
CLEAR ls_ebeln.
ENDLOOP.
2021 Mar 23 7:24 AM
Hi april.
Based on your example it might look like the following:
DATA lr_ebeln TYPE RANGE OF ekko-ebeln.
SELECT 'I', 'EQ', ebeln
FROM ekko
INTO TABLE @lr_ebeln[].Regards,
Bartosz
Hi april.
Based on your example it might look like the following:
DATA lr_ebeln TYPE RANGE OF ekko-ebeln.
SELECT 'I', 'EQ', ebeln
FROM ekko
INTO TABLE @lr_ebeln[].Regards,
Bartosz
2021 Mar 23 7:24 AM
Hi april.
Based on your example it might look like the following:
DATA lr_ebeln TYPE RANGE OF ekko-ebeln.
SELECT 'I', 'EQ', ebeln
FROM ekko
INTO TABLE @lr_ebeln[].Regards,
Bartosz
2021 Mar 23 7:38 AM
No need for the []. There's no ambiguity. Ranges do not have a header line.
You could also use:
SELECT 'I' AS sign, 'EQ' AS option, vbeln AS low, @space AS high
FROM vbak
INTO TABLE @DATA(range_of_document_numbers).
2021 Mar 23 8:12 AM
Thanks Bartosz and Matthew for the inputs. It is very helpful.
2021 Mar 23 10:24 AM
Also possible in non-HANA system. It just needs a high enough ABAP stack.
2021 Mar 23 7:50 AM
There are answers below already for how to do what you ask. But what will you be using your gt_ebeln for?
Both with and without HANA there is also the possibility to join tables in one select instead of making two (ore more) selects where the first one is only used to get the keys for the WHERE clause of the second one...
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |