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

Select-join from (TABNAME) problem

Former Member
0 Likes
586

I wonder, if anybody can answer, why this code cann't be compiled:

SELECT DISTINCT (ls_dynqr-fields)

INTO TABLE lt_doclist

FROM (ls_dynqr-tablename) AS a

INNER JOIN /abat/mcrm_mycus AS b

ON akunnr = bkunnrx AND

b~bname = sy-uname

UP TO lv_pmax ROWS

WHERE (ls_where-where_tab).

Tablename, list of fields and where-clauses are specified at runtime. Without JOIN it works fine, but with it it can not be compiled because of incorrect FROM condition, I meen unexpected 'JOIN' after 'FROM'.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
540

Not sure that you can do a dynamic inner join. You might try splitting it up and using FOR ALL ENTRIES in your second select statement.

Regards,

Rich Heilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
541

Not sure that you can do a dynamic inner join. You might try splitting it up and using FOR ALL ENTRIES in your second select statement.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
540

Joins are not possible in dynamic SELECT statements as it cannot validate the same during you compilation.

Read only

Former Member
0 Likes
540

HI Aleksandr,

I am trying to use Table in from clause dynamically. But unable.

Can you please let me know what ls_dynqr-tablename is declared as?

Thanks

Shashi

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
540

Hi,

The problem is in JOIN ON, you have given b~bname = sy-uname, this should have been given in the WHERE clause not in the JOIN ON remove it from JOIN ON and put it in Where clause.

Regards,

Sesh