‎2009 Oct 27 3:56 PM
Hi,
We have a custom program that is selecting data from a custom view. This custom database view is a join of tables MVEW and MEAN. Join condition is Matnr. Here is a portion of the custom code:
OPEN CURSOR g_cursor FOR SELECT matnr bwkey verpr ean11
FROM zv_sku_inv
WHERE bwkey in s_bwkey
ORDER BY ean11 bwkey.
DO.
FETCH NEXT CURSOR g_cursor INTO TABLE t_mbew
PACKAGE SIZE p_pkgsiz.
IF sy-subrc NE 0.
EXIT.
ELSE.
LOOP AT t_mbew ASSIGNING <fs_mbew>.
WRITE <fs_mbew>-verpr TO wa_verpr CURRENCY 'USD' LEFT-JUSTIFIED.
write current dataset to the output file
CONCATENATE <fs_mbew>-bwkey
<fs_mbew>-ean11
wa_verpr
INTO outputdata
SEPARATED BY p_delim.
TRANSFER outputdata TO fname.
ENDLOOP.
ENDIF.
ENDDO.
it turns out that the fetch is retrieving duplicates some times, and we know the view does not have duplicates in it. What could be causing this behaviour? Would the addtion "on hold" help to avoid duplicates? Unfortunately, we are unable to reproduce this production problem in our testing environment. Thanks in advance for any feedback you might have that would resolve this issue.
-Leticia Chee-Chung
‎2009 Oct 27 4:03 PM
Both tables have more fields than MATNR in their primary indexes, so it is well possible that your view produces duplicates when only a subset of the fields is being selected. How did you make sure that the view does not contain duplicates. Are you using any select options in the view? Which ones?
"package size" works reliably, as far as I know. "with hold" is only relevant when database commits occur.
Thomas
‎2009 Oct 27 4:34 PM
The selection condition makes them unique. It is MBEW-BWTAR EQ " " and MEAN-HPEAN = "X". Also, I did an se16 on the duplciates I am getting in the ouptut file, and in the view they only appear once.
‎2009 Oct 27 5:00 PM
So it is MBEW and not MVEW? Sorry, hard to tell from the distance without looking at your data.
Thomas
‎2009 Oct 27 5:35 PM