2
votes

I have the following SQL statement and was wondering if I could rewrite it using the VALUE operator to avoid the DATA statement at the beginning.

  DATA(lv_initial) = VALUE /scwm/guid_hu( ).
  SELECT * FROM /scwm/tu_dlv 
    WHERE lgnum     = @lv_lgnum
      AND top_hu    = @lv_initial
    INTO TABLE @DATA(lt).

I.e., I would like to have something like the following, which gives the error: "Field 'VALUE' unknown. [...]", unfortunately.

  SELECT * FROM /scwm/tu_dlv
    WHERE lgnum     = @lv_lgnum
      AND top_hu    = @VALUE #( )
   INTO TABLE @DATA(lt).

Is this possible? I want to get rid of the DATA statement because it can lead to bugs easily if the variable is reused.

I searched on Google and in the ABAP key word documentation, specifically for "SELECT", "VALUE, Operator" and "DATA, Operator", but to no avail.

Any suggestions are appreciated.

Kind regards, Stefan

1

1 Answers

2
votes

As far as I can see, it depends on the target release. For release 7.40, the right-hand side of the comparison needs to be (among other alternatives)

a host variable or a literal

Whereas in release 7.50, that has been replaced to allow for

a literal, a host variable, or a host expression

That extension to host expressions should allow you to do what you want to do, as shown in this example.