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

Fetch Cursor : Data retrieve issue

Former Member
0 Likes
1,383

Hi All,

I am having a custom table with 55 Lac entries.

I am querying this table from my custom program using the Open/Fetch curso statement.

The "Fetch next Cursor" statement is not retreiveing any data. Provided the where clause is valid and entries does exists in table for the speicifed condition.

Please advice, how to solve the issue.

Thanks & Regards,

Navneeth K.

10 REPLIES 10
Read only

Former Member
0 Likes
1,295

Hi,

Can you please post the portion of that code?

Read only

0 Likes
1,295

Pls find the sample code below:-

OPEN CURSOR WITH HOLD gv_cursor

FOR SELECT article site proc_indi

FROM zcustom

FOR ALL ENTRIES IN gt_t001w

WHERE article IN gt_matnr

AND site = gt_t001w-werks.

DO.

FETCH NEXT CURSOR gv_cursor APPENDING TABLE lt_copy

PACKAGE SIZE gv_pack.

IF sy-subrc <> 0.

EXIT.

ENDIF.

ENDDO.

CLOSE CURSOR gv_cursor.

here gv_pack = 10000.

Read only

0 Likes
1,295

Hi,

Try like below sample code.

OPEN CURSOR gv_cursor FOR

SELECT article site proc_indi

FROM zcustom

FOR ALL ENTRIES IN gt_t001w

WHERE article IN gt_matnr

AND site = gt_t001w-werks.

DO.

FETCH NEXT CURSOR gv_cursor INTO TABLE lt_copy_temp

PACKAGE SIZE gv_pack.

IF sy-subrc NE 0.

EXIT.

ENDIF.

Append lines of lt_copy_temp to lt_copy

REFRESH lt_copy_temp.

ENDDO.

CLOSE CURSOR gv_cursor.

Read only

0 Likes
1,295

The Fetch statement is not executing properly.

On debugging noticed the program stops at Fetch statement and doesnt move further (and then times out)

Read only

0 Likes
1,295

Try reducing the package size and see.

Read only

0 Likes
1,295

I did reduce the package size to 1000, still its not fetching any data.

Read only

0 Likes
1,295

Then most probably because of non-availability of data. In the itab GT_MATNR, check the format of the data is same as in the table including the preceding zeroes. For eg: if table has 5 preceding zeroes for MATNR and program has 10 preceding zeroes it will not read.

Here in cursor part, I am not able to see anything wrong. I have also used similarly in my code.

Just for reference to find if the select is returning any value, comment the cursor part and try using normal select to fetch data from the table with the same conditions.

Read only

0 Likes
1,295

Try something like the below code.....

DATA: v_cursor TYPE cursor,

CLEAR : v_cursor.

OPEN CURSOR WITH HOLD v_cursor FOR

SELECT vbeln_bd fkart fktyp waerk vkorg vtweg spart fkdat netwr kunag

kunnr augru auart knumv ktgrd land1_sldto name1_sldto ort01_sldto

pstlz_sldto regio_sldto stras_sldto land1_shpto name1_shpto ort01_shpto

pstlz_shpto regio_shpto stras_shpto name3_shpto name4_shpto zprz1

zuonr zterm bzirk_shpto

FROM zinvexthdr

WHERE vbeln_bd IN s_vbeln

AND fkart IN s_fkart

AND vkorg IN s_vkorg

AND fkdat IN s_fkdat

and augru <> '28'

and augru <> '957'

and augru <> '942'

and augru <> '940'.

DO.

FETCH NEXT CURSOR v_cursor

APPENDING TABLE it_zinvexthdr

PACKAGE SIZE 10000. "Process 10000 records at a time

"to avoid memory allocation dump

IF sy-subrc NE 0.

CLOSE CURSOR v_cursor.

EXIT.

ENDIF.

ENDDO.

Ashok Yellenki.

Read only

0 Likes
1,295

This message was moderated.

Read only

Former Member
0 Likes
1,295

Hi,

Try this link,

http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=87818744

It helps to you.

Regards,

Sekhar