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

Dynamic SQl results in DUMP

Former Member
0 Likes
1,502

Does someone see what is wrong in my dynamic SQL statement is reuslts in a dump!

DUMP and CODE below!

Runtime error SAPSQL_WHERE_MISSING_VALUE

Except. CX_SY_DYNAMIC_OSQL_SYNTAX

Datum en tijd 19.02.2009 13:30:13

Korte tekst

A comparison value is missing in a condition specified dynamically.

Wat is er gebeurd?

Error in the ABAP Application Program

The current ABAP program "!PR_RVVEEN_USED_FIELDS" had to be terminated because

it has

come across a statement that unfortunately cannot be executed.

Foutenanalyse

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SYNTAX', was not

caught and

therefore caused a runtime error.

The reason for the exception is:

The current ABAP program has tried to execute an Open SQL statement

in which a condition was (partially) specified dynamically. In the

part specified at runtime, the program expects to find a literal as

the comparison value.

===============================================

itable = 'pa0001'

CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'

EXPORTING

tabname = iname

TABLES

ddfields = ddfields.

LOOP AT ddfields.

data: where_tab(30) occurs 1 with header line,

where_clause(30) type c.

concatenate ddfields-fieldname '<> " "' into where_clause SEPARATED BY space.

append where_clause to where_tab.

select pernr from (itable) into table lt_pernr where (where_tab).

if sy-subrc = 0.

write 'FIELD COTAINS A VALUE'.

endif.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Sm1tje
Active Contributor
0 Likes
1,166

Sorry, forget about the IS INITIAL.

I got it working for me, but your requirement is not all to clear to me, since you are looking for a selection, where a certain field is NOT filled?

It is probably only a test program, so it's not that important.

7 REPLIES 7
Read only

Former Member
0 Likes
1,166

The dump is because of a error in the where clause!

Read only

0 Likes
1,166

When I look at the coding. I'm missing the rest of the WHERE clause

In the where_tab I can't find any operator like 'EQ' or 'NE'.

1. try to catch the exception using TRY -- ENDTRY and retrieve the error message.

2. In debugging, before SELECT, check the contents of the where_tab. It should look like a 'normal select' , something like this WHERE fielda = 10.

Read only

Former Member
0 Likes
1,166

while debugging check the values in where_tab and itable

Read only

former_member222860
Active Contributor
0 Likes
1,166

Hi,

Concatenate operator also in where-clause, like this

concatenate ddfields-fieldname ' = ' ' " "' into where_clause SEPARATED BY space.

thanks\

Mahesh

Read only

Former Member
0 Likes
1,166

Already tried this

concatenate ddfields-fieldname 'NE space' into where_clause SEPARATED BY space.

append where_clause to where_tab.

select pernr from (itable) into table lt_pernr where (where_tab).

this work for Characterfields but not for no character fields.

Read only

0 Likes
1,166

I'm also missing a dot ('.') at the end of the line. Command should always end with a point.

For numeric characters you can use '0000' (depending on number of characters).

BTW. you are creating the dynamic where clause within the loop, without clearing (initializing ) anything. This will lead to the next problem.

Edited by: Micky Oestreich on Feb 19, 2009 2:13 PM

Read only

Sm1tje
Active Contributor
0 Likes
1,167

Sorry, forget about the IS INITIAL.

I got it working for me, but your requirement is not all to clear to me, since you are looking for a selection, where a certain field is NOT filled?

It is probably only a test program, so it's not that important.