‎2014 Jun 17 5:23 PM
Hi experts,
I want to use dynamic WHERE here, but I got a problem when using EXISTS + subuery.
Here is my code snippet:
And the actual SQL sentence should be like this:
When I execute this program, an exception CX_SY_DYNAMIC_OSQL_SEMANTICS is raised and the program dumps.
Dump Information:
Short text
A dynamically specified column name is unknown.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
not caught in
procedure "FRM_GET_ALL_PROD_ORDERS" "(FORM)", nor was it propagated by a
RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
An Open SQL clause was specified dynamically. The contained field name
"EXISTS" does not exist in any of the database tables from the FROM clause.
I'm confused because the plain text of my WHERE condition looks good. Could you tell me why I encountered this problem?
Many thanks,
Shelwin
‎2014 Jun 17 9:49 PM
Hi Shelwin !
Testing your code i dont have dump, using this:
REPORT z_test MESSAGE-ID z_test_msgs.
DATA: lt_where_tab1 TYPE STANDARD TABLE OF edpline WITH HEADER LINE,
lt_where_tab2 TYPE STANDARD TABLE OF edpline WITH HEADER LINE,
gt_detail TYPE STANDARD TABLE OF caufv WITH HEADER LINE.
CONCATENATE 'EXISTS (SELECT J_1~STAT FROM JEST AS J_1 INNER JOIN TJ02T AS T_1'
'ON J_1~STAT EQ T_1~ISTAT'
'WHERE J_1~OBJNR EQ CAUFV~OBJNR'
'AND J_1~INACT EQ '' '''
'AND T_1~SPRAS EQ ''E'''
'AND T_1~TXT04 EQ ''CRTD'')'
INTO lt_where_tab1.
CONCATENATE 'NOT EXISTS (SELECT J_2~STAT FROM JEST AS J_2 INNER JOIN TJ02T AS T_2'
'ON J_2~STAT EQ T_2~ISTAT'
'WHERE J_2~OBJNR EQ CAUFV~OBJNR'
'AND J_2~INACT EQ '' '''
'AND T_2~SPRAS EQ ''E'''
'AND T_1~TXT04 IN (''TECO'' , ''DLFL'', ''DLV'', ''CLSD''))'
INTO lt_where_tab2.
SELECT aufnr ftrms gltrs
FROM caufv
INTO CORRESPONDING FIELDS OF TABLE gt_detail
WHERE (lt_where_tab1)
AND (lt_where_tab2).
BREAK-POINT.
Regards,
Edited for error on image.
‎2014 Jun 20 3:49 AM
Hi Shelwin !
Have you found the solution to your problem? If yes, please close this post as "Assumed Answered" (if you solve the problem alone) or "Answered" by selecting the correct answer among all posted here.
Please read this blog: How to close a discussion and why it shows good practices as foreclosure postings.
Thanks.