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

duplicates when using fetch cursor

leticia_chee
Explorer
0 Likes
945

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

4 REPLIES 4
Read only

ThomasZloch
Active Contributor
0 Likes
732

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

Read only

leticia_chee
Explorer
0 Likes
732

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.

Read only

0 Likes
732

So it is MBEW and not MVEW? Sorry, hard to tell from the distance without looking at your data.

Thomas

Read only

leticia_chee
Explorer
0 Likes
732

Sorry Thomas, it is MBEW.