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

Abap Table Expression in SQL

Former Member
0 Likes
921

Hey everyone,

I would love to do something like the following, but i get a syntax error:

SELECT * FROM MARA
WHERE MATNR EQ @( GT[ 1 ]-MATNR ).

Is something like this possible?

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
841

I could make it work successfully in my 7.52 version:

DATA gt TYPE TABLE OF scarr.
gt = VALUE #( ( carrid = 'LH' ) ).
SELECT * FROM scarr
    WHERE carrid = @( gt[ 1 ]-carrid )
    INTO TABLE @DATA(scarr_table).

I guess it does a syntax error in your system because you're using an old ABAP version where so-called Host Expressions (@( ... )) are not permitted yet (available since 7.50).

NB: you may also use CONV, VALUE, etc. in host expressions - The right documentation link for host expressions is this one: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenopen_sql_host_exp... (jorgen_lindqvist41 fyi)

NB: Kevin, thanks for reopening the question to let me add this answer.

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
842

I could make it work successfully in my 7.52 version:

DATA gt TYPE TABLE OF scarr.
gt = VALUE #( ( carrid = 'LH' ) ).
SELECT * FROM scarr
    WHERE carrid = @( gt[ 1 ]-carrid )
    INTO TABLE @DATA(scarr_table).

I guess it does a syntax error in your system because you're using an old ABAP version where so-called Host Expressions (@( ... )) are not permitted yet (available since 7.50).

NB: you may also use CONV, VALUE, etc. in host expressions - The right documentation link for host expressions is this one: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenopen_sql_host_exp... (jorgen_lindqvist41 fyi)

NB: Kevin, thanks for reopening the question to let me add this answer.

Read only

joltdx
Active Contributor
841

Thank you Sandra! Yes there it is in plain sight! And also, when I write my own test example correctly, even I get it to work 🙂

Also, the ABAP Documentation DOES also link to them from the link i provided.

Former Member I'm really sorry I gave you an incorrect answer. It was to the best of my knowledge, but I was performing below my own personal standards here. I recommend you change the correct answer to this one from Sandra, and I can remove mine to not confuse others finding your question later on.