‎2009 Feb 19 12:31 PM
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.
‎2009 Feb 19 1:13 PM
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.
‎2009 Feb 19 12:32 PM
‎2009 Feb 19 12:38 PM
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.
‎2009 Feb 19 12:34 PM
‎2009 Feb 19 12:37 PM
Hi,
Concatenate operator also in where-clause, like this
concatenate ddfields-fieldname ' = ' ' " "' into where_clause SEPARATED BY space.
thanks\
Mahesh
‎2009 Feb 19 12:42 PM
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.
‎2009 Feb 19 12:57 PM
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
‎2009 Feb 19 1:13 PM
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.