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: 

Using 'Greater than/less than' in dynamic where condition

Former Member
0 Kudos

Hi Guys,

I am trying to use a logical expression with GT/LT condition in dynamic where, butits giving dump "expression worngly parenthesised' . My query runs perfectly fine when the logical expression does not have 'GT/LT' . Is there a different way of using GT/LT in dynamic where or is it not posiible at all?? Please find my query below -

IF vendor IS NOT INITIAL.

i_where_clause = 'a~lifnr = vendor'.

APPEND i_where_clause.

CLEAR i_where_clause.

ENDIF.

IF to_date IS NOT INITIAL.

i_where_clause = 'a~zzearliestdep LT to_date'.

APPEND i_where_clause.

CLEAR i_where_clause.

ENDIF.

IF from_date IS NOT INITIAL.

i_where_clause = 'a~zzlatestdep GT from_date'.

APPEND i_where_clause.

CLEAR i_where_clause.

ENDIF.

SELECT aebeln alifnr azzearliestdep azzlatestdep

bebelp belikz b~kzabs

INTO CORRESPONDING FIELDS OF TABLE i_podetails

UP TO max_hits ROWS

FROM ( ekko AS a INNER JOIN ekpo AS b

ON aebeln = bebeln )

WHERE a~ebeln = ebeln AND

(i_where_clause).

9 REPLIES 9

matt
Active Contributor
0 Kudos

This has NOTHING to do with GT, or LT. Your where clause is invalid.

You forgot the AND. As things stand, your WHERE clause reads

WHERE ... alifnr = vendor azzlatestdep GT from_date

etc.

matt

Former Member
0 Kudos

Hi,

if u noticed I am not using concatenate...so AND is not required i believe.I am appending the condition in internal table.

matt
Active Contributor
0 Kudos

.

Answered later

matt
Active Contributor
0 Kudos

>

> Hi,

> if u noticed I am not using concatenate...so AND is not required i believe.I am appending the condition in internal table.

Yes, and you STILL need the AND.

matt

IF vendor IS NOT INITIAL.
i_where_clause = 'a~lifnr = vendor'.
APPEND i_where_clause.
CLEAR i_where_clause.
ENDIF.
IF to_date IS NOT INITIAL.
if i_where_clause[] is not initial.
  i_where_clause = 'AND'.
  append i_where_clause.
ENDIF.
i_where_clause = 'a~zzearliestdep LT to_date'.
APPEND i_where_clause.

etc.

Former Member
0 Kudos

Many thanks guys...Its working with the AND .

Former Member
0 Kudos

Try > for GT and < for LT.

Former Member
0 Kudos

Hi,

Use symbol < and > instead of LT and GT.

Cheers.

\[removed by moderator\]

Edited by: Jan Stallkamp on Jun 26, 2008 1:08 PM

0 Kudos

Hi Wong and Vishal,

I initially used the symbols..but the result is same.

Former Member
0 Kudos

Hi,

Try this -

IF vendor IS NOT INITIAL.

i_where_clause = 'a~lifnr = vendor'.

APPEND i_where_clause.

ENDIF.

IF to_date IS NOT INITIAL.

if i_where_cause[] is not initial.

i_where_clause = 'AND'

append i_where_cause.

endif.

i_where_clause = 'a~zzearliestdep LT to_date'.

APPEND i_where_clause.

ENDIF.

IF from_date IS NOT INITIAL.

if i_where_cause[] is not initial.

i_where_clause = 'AND'

append i_where_cause.

endif.

i_where_clause = 'a~zzlatestdep GT from_date'.

APPEND i_where_clause.

CLEAR i_where_clause.

ENDIF.

Cheers.

\[removed by moderator\]

Edited by: Jan Stallkamp on Jun 26, 2008 1:08 PM