Application Development 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: 

use "AS" with && expressions IN SELECT AND FOR-ALL-ENTERIES

878

Hello everyone,

I get this error when I try to use "AS" with && expressions with for-all-enteries. I need union two fields.


error-as.png

Is there an alternative?

thanks.

6 REPLIES 6

matt
Active Contributor
436

You can't use FOR ALL ENTRIES with the new syntax. Try a union or contsruct your select so it's done all in one go.

Otherwise use the old syntax.

Mithun_Kumar
Active Participant
0 Kudos
436

Not entirely true. FOR ALL ENTRIES still works with the new syntax, to some extent. A few additional constructs would not work, like in this example.

Indeed, using an inner-join with the internal table is a better and cleaner solution.

matt
Active Contributor
0 Kudos
436

mithunkr_cbs "To some extent". What extent would that be?

But the error is pretty clear - at least in this case, you can't use for all entries!

tugay_birihan
Participant
436

Hi Alon,

Use "inner join" instead of for all entries. You can join database table and internal table with new syntax.


  DATA lt_carrids TYPE TABLE OF sflight_light.

  APPEND VALUE sflight_light( carrid = 'AA' ) to lt_carrids.

  SELECT s~carrid, ( s~carrname && s~currcode ) AS inco
    FROM scarr AS s
    inner JOIN @lt_carrids as i on i~carrid =  s~carrid
    INTO TABLE @DATA(scarr_s).

former_member703998
Participant
0 Kudos
436

Hi Alon,

You can use the below code. Usually, with the new syntax, we have few limitations and there is a reasons for that. I will expalin them in one of my blogs

SELECT k~kunnr AS cnt_kunnr,
       k~telf1 AS cnt_telf1,
       concat( k~namev , k~name1 ) AS cnt_name
  FROM knvk AS k
  INNER JOIN @lt_tbl_alv AS a ON a~kunnr = k~kunnr
  INTO TABLE @DATA(lt_cotract).

or

SELECT k~kunnr AS cnt_kunnr,
       k~telf1 AS cnt_telf1,
       ( k~namev && k~name1 ) AS cnt_name
  FROM knvk AS k
  INNER JOIN @lt_tbl_alv AS a ON a~kunnr = k~kunnr
  INTO TABLE @DATA(lt_cotract).

Reward if helpful

Sandra_Rossi
Active Contributor
0 Kudos
436

Please post code as text. Please post syntax error as text too.

If you had non-text images, you could post it as image instead of hyperlink, like that: