Application Development 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: 

Dynamic where condition - Problem

Former Member
0 Kudos

Hi All,

I have a problem in a select statement where I use a dynamic condition.It gives me a dump

SAPSQL_WHERE_PARENTHESES

CX_SY_DYNAMIC_OSQL_SYNTAX.

Please find the below code which I implemented.

*SELECT * FROM ZXR5*

WHERE (SOURCE).

The value of SOURCE is 'MATNR EQ '000000000000200066'.

When I checked the help, it is advised to use a CATCH exception which I did as below:

TRY.

*SELECT * FROM ZXR5*

WHERE (SOURCE).

CATCH cx_sy_dynamic_osql_error.

MESSAGE `Wrong WHERE condition!` TYPE 'I'.

ENDTRY.

Now, the select statement gives an exception and is not executing to fetch the values.

I need some input on the above issue. Any help on this would be greatly appreciated.

Regards,

Rajmohamed.M

12 REPLIES 12

Former Member
0 Kudos

try changing it to MATNR = '000000000000200066'

Thanks,

SKJ

0 Kudos

Hi,

The problem is with the Dynamic Condition and the SOURCE is a table not a structure. So sometimes the values will be like this

source-line[1] : MATNR = '000000000000200066' AND

source-line[2] : OBJKEY = '12345'.

For the above conditions also, it gives me a dump.

Regards,

Raj

0 Kudos

Populate ur table in this way and check

source-line[1] : MATNR = '000000000000200066'

source-line[2] : AND

source-line[3] : OBJKEY = '12345'

Regards,

Joy.

0 Kudos

source can define as string.

EPORT  YDYN_C.

data: source type string.

data: it_flight type sflight_tab1.

data: p_carrid type sflight-carrid.
p_carrid = 'AA'.  <=== in your case define a variable and assign the material value to it
source = 'CARRID EQ P_CARRID' .
select * from
sflight
into table it_flight
where (source).

if sy-subrc eq 0.

endif.

Regards

Vijay Babu Dudla

0 Kudos

Hi all,

Thanks for the reply.I found out the answer for the issue.

When you pass the dynamic condition, it is better to put in Paranthesis i.e instead of MATNR EQ 000000000200066 , you can put (MATNR EQ 000000000200066 ) which solved my problem.

Regards,

Raj

0 Kudos

Please close your thread as being answered if you have solved the problem. Thanks.

0 Kudos

Hi Mike,

I made the posting answered But how Can I close the post.

Regards,

Raj.

0 Kudos

Marking it as answered closes it.

Rob

0 Kudos

I see the thread is marked as Answered now. Thanks.

former_member188685
Active Contributor
0 Kudos
TRY.

 SELECT * FROM ZXR5
 INTO  table <FS_TAB>
WHERE (SOURCE).
CATCH cx_sy_dynamic_osql_error.
"when there is error then it will give a message 

MESSAGE `Wrong WHERE condition!` TYPE 'I'.

ENDTRY.

if the dynamic select fails then we need to catch the exception otherwise run time error will occur

0 Kudos

Hi Vijay,

I tried the same and all the time, the select statement gives me an exception and wont proceed.

TRY.

SELECT * FROM ZXR5

INTO TABLE <L_ZXR5>

WHERE (SOURCE).

CATCH cx_sy_dynamic_osql_error.

MESSAGE `Wrong WHERE condition!` TYPE 'I'.

ENDTRY.

Regards,

Raj

Former Member
0 Kudos

Populate source table in this way:

concatenate 'MATNR EQ' ''000000000000200066'' into SOURCE

separated by space in character mode.

Regards,

Joy.