Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Hanatize Ranges

0 Likes
1,983

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.
1 ACCEPTED SOLUTION
Read only

ziolkowskib
Active Contributor
1,921

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

5 REPLIES 5
Read only

ziolkowskib
Active Contributor
1,922

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

Read only

matt
Active Contributor
1,921

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).
Read only

0 Likes
1,921

Thanks Bartosz and Matthew for the inputs. It is very helpful.

Read only

matt
Active Contributor
0 Likes
1,921

Also possible in non-HANA system. It just needs a high enough ABAP stack.

Read only

joltdx
Active Contributor
1,921

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