Reputation: 1319
I'm trying to display table in alv from an internal table where rows are added form a table stored in the database. Without a where condition I see rows displayed in alv but with a where condition in the select statement no rows are returned.
Here is the code:
REPORT ZSAM.
DATA: IT_1 TYPE STANDARD TABLE OF VBAK.
select vbeln audat netwr waerk vkorg vtweg
from VBAK
into corresponding fields of Table IT_1
where vbeln > 4500
and vbeln < 6000.
Any idea why using where condition makes it not return any rows and how to fix?
Upvotes: 2
Views: 919
Reputation: 11
You can try to use range;
First usage;
DATA: r_vbeln TYPE RANGE OF vbeln.
DATA: s_vbeln LIKE LINE OF r_vbeln.
s_vbeln-option = 'BT'.
s_vbeln-sign = 'I'.
s_vbeln-low = '0000004501'.
s_vbeln-high = '0000005999'.
APPEND s_vbeln TO r_vbeln.
SELECT condition; WHERE vbeln IN r_vbeln.
Second usage;
DATA: r_vbeln TYPE RANGE OF vbeln.
DATA: s_vbeln LIKE LINE OF r_vbeln.
s_vbeln-option = 'GT'.
s_vbeln-sign = 'I'.
s_vbeln-low = '0000004500'.
APPEND s_vbeln TO r_vbeln.
s_vbeln-option = 'LT'.
s_vbeln-sign = 'I'.
s_vbeln-low = '0000006000'.
APPEND s_vbeln TO r_vbeln.
SELECT condition; WHERE vbeln IN r_vbeln.
Upvotes: -2
Reputation: 5071
vbeln is a field with ten positions and uses ALPHA
conversion routine (see the domain behind the data element). This means the value is filled with leading zeros (as long as it does contain numbers only). As this is a character type field, you also have to use apostrophes for the comparison. So, the WHERE
condition has to be like this:
WHERE vbeln GT '0000004500'
AND vbeln LT '0000006000'
Upvotes: 5