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 where clause using between statement

Former Member
0 Likes
440

hi,

I am trying to build a dynamic where clause using between statement. I am getting zero records, there are some entries in these range.

whats's wrong in my code.

Is it possible to use Range in dynamic where condition for the same ?

TABLES: EKKO.

DATA: P_TABLE(6) VALUE 'EKKO',

V_COUNT TYPE I,

V_QUERY TYPE STRING.

DATA: V_INT1 type string,

V_INT2 type string,

v_qut(1) type c value ''''.

V_INT1 = '1000000'.

V_INT2 = '1000050'.

concatenate v_qut v_int1 v_qut into v_int1.

concatenate v_qut v_int2 v_qut into v_int2.

CONCATENATE '(' 'ebeln' 'between' V_INT1 'and' V_INT2 ')' INTO V_QUERY SEPARATED BY SPACE.

SELECT COUNT( * ) FROM (P_TABLE) INTO V_COUNT

WHERE (V_QUERY).

WRITE: / V_COUNT.

Edited by: fract_get on Jan 20, 2010 4:18 PM

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
414

check this


data:begin of it_where occurs 0,
     line type char100,
     end of it_where.

DATA: V_INT1 type char10,
V_INT2 type char10,
v_qut(1) type c value ''''.

V_INT1 = '0001000000'.
V_INT2 = '0001000050'.

concatenate `'` v_int1 `'` into v_int1.
concatenate `'` v_int2 `'` into v_int2.

CONCATENATE 'EBELN' 'BETWEEN' V_INT1 'AND' V_INT2 INTO it_where-line seperated by space.
append it_where.

SELECT COUNT( * ) FROM (P_TABLE) INTO V_COUNT
WHERE (it_where).

2 REPLIES 2
Read only

Sm1tje
Active Contributor
0 Likes
414

It is possible. Are you sure that you are not missing any leading zeros for EBELN?

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
415

check this


data:begin of it_where occurs 0,
     line type char100,
     end of it_where.

DATA: V_INT1 type char10,
V_INT2 type char10,
v_qut(1) type c value ''''.

V_INT1 = '0001000000'.
V_INT2 = '0001000050'.

concatenate `'` v_int1 `'` into v_int1.
concatenate `'` v_int2 `'` into v_int2.

CONCATENATE 'EBELN' 'BETWEEN' V_INT1 'AND' V_INT2 INTO it_where-line seperated by space.
append it_where.

SELECT COUNT( * ) FROM (P_TABLE) INTO V_COUNT
WHERE (it_where).