cancel
Showing results for 
Search instead for 
Did you mean: 

error: dynamic SELECT command in abap Opensql

Former Member
0 Kudos

Hi!

When I try to run this program, the session terminates, the work process restarts:

DATA:

string1 TYPE STRING,

string2 TYPE STRING,

string3 TYPE STRING,

lt_trkorr TYPE TABLE OF E070-TRKORR.

string1 = 'TRKORR'.

string2 = 'E070'.

string3 = 'TRKORR IN ( SELECT TRKORR FROM e071 )'.

SELECT (string1)

INTO TABLE lt_trkorr

FROM (string2)

WHERE (string3).

However, if I use the static command, it runs fine:

select trkorr

from e070

into table lt_trkorr

where TRKORR IN ( SELECT TRKORR FROM e071 ).

I'm using WAS 6.10.

Thanks and Best Regards,

Tamas

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Can we use something like 'vbeln in r_vbeln' where r_vbeln is declared ranges.

I'm trying the below code:

data: lv_where type string.

I'm trying to use select *from table into itab where (lv_where).

I get this exception 'CX_SY_DYNAMIC_OSQL_SEMANTICS'. Can someone please guide me a solution for this..

Thank you

Sreesanth

Former Member
0 Kudos

sorry, forgot to put in this peice ..

concatenate 'vbeln' 'in' 'r_vbeln' into lv_where separated by space.

here is complete code..

data: lv_where type string.

concatenate 'vbeln' 'in' 'r_vbeln' into lv_where separated by space.

I'm trying to use select *from table into itab where (lv_where).

Former Member
0 Kudos

Hi Tamas,

the problem is, that a subselect is not supported in the WHERE - (cond_syntax) expression. If you read the online documentation carefully, you may be come the same conclusion, that you can only use simple logical conditions in this syntax path. The WHERE - subquery is an independent path in the documentation.

Also the error analysis gives you the same information:

<i>The part of the WHERE, ON, or HAVING condition specified at

runtime in the internal table itab contains an invalid

value "SELECT".</i>

Best regards

Ralph Ganszky

Former Member
0 Kudos

Have you debuged the program?

Check the values of the variables before the dynamic SELECT command.

If all the variables does have the required values in them then, try to use one variable at a time, just to check which variable is actually causing the problem.

Narrow in, into the problem.

Do let me know the results of your check.

Regards,

Ammey Kesarkar

Former Member
0 Kudos

Hi!

The where clause causes the problem. The query runs without it. Also, if put a simple where clause into the variable, the query is okay. The problem arises when I use a subquery.

Thanks and Best Regards,

Tamas

Former Member
0 Kudos

Hi, I'm having the same problem with a dynamic subquery. My query is this:

select PEBELN PEBELP into table i_resultado

from EKPO as P

where (v_wher).

v_wher has the value: EXISTS ( SELECT * FROM EKPO AS P2 WHERE PEBELN = P2EBELN AND P2~EBELP = 30 )

The same query works fine if it is static.

The dump I receive says the following:

"An exception occurred. This exception will be dealt with in more detail

below. The exception, assigned to the class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was

not caught, which

led to a runtime error. The reason for this exception is:

<b>The SELECT clause was specified in an internal table at runtime.

It contains the field name "EXISTS", but this does not occur in any of

the database tables listed in the FROM clause</b>."

It seems not to recognize the subquery.

Any idea?

former_member204746
Active Contributor
0 Kudos
Former Member
0 Kudos

I did, but I didn't find something related to this problem in particular.

I'm getting the error: "SAPSQL_INVALID_FIELDNAME" from class "CX_SY_DYNAMIC_OSQL_SEMANTICS" and it does not appear on that page.