‎2010 Jan 20 3:13 PM
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
‎2010 Jan 20 3:25 PM
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).
‎2010 Jan 20 3:22 PM
It is possible. Are you sure that you are not missing any leading zeros for EBELN?
‎2010 Jan 20 3:25 PM
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).