It seems that as result the program is getting all sales orders (from VBAK
table) only with AUART = 'YI01', and indeed I am getting 1.699.698 sales orders. So it is ignoring the other parameters in select VTWEG = 'Z1'
, SPART = 'Z1'
, KUNNR = '0230001039'
, ERDAT = GT '01.09.2017'
for which I should get only 77 results.
TYPES: BEGIN OF lw_odv_vbak,
vbeln TYPE vbak-vbeln,
vkorg TYPE vbak-vkorg,
vtweg TYPE vbak-vtweg,
spart TYPE vbak-spart,
netwr TYPE vbak-netwr,
kunnr TYPE vbak-kunnr,
erdat type vbak-erdat,
END OF lw_odv_vbak.
DATA: it_odv_vbak TYPE STANDARD TABLE OF lw_odv_vbak INITIAL SIZE 0.
SELECT vbeln
FROM vbak
INTO TABLE it_odv_vbak
WHERE vkorg = 'Z326'
AND vtweg = 'Z1'
AND spart = 'Z1'
AND kunnr = '0230001039'
AND auart = 'YC01' OR
auart = 'YI01'
AND erdat GT '01.09.2017'.
Thanks a lot for your help
You can do two things: 1) Use parentheses around OR 2) Change date format to '20170901'. In db, dates are stored like YYYYMMDD.