‎2011 Apr 06 9:55 AM
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.
‎2011 Apr 06 10:45 AM
‎2011 Apr 06 11:00 AM
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.
‎2011 Apr 06 11:10 AM
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.
‎2011 Apr 06 11:25 AM
The Fetch statement is not executing properly.
On debugging noticed the program stops at Fetch statement and doesnt move further (and then times out)
‎2011 Apr 06 11:41 AM
‎2011 Apr 06 11:57 AM
I did reduce the package size to 1000, still its not fetching any data.
‎2011 Apr 06 12:10 PM
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.
‎2011 Apr 06 5:10 PM
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.
‎2013 May 02 1:44 AM
‎2011 Apr 12 3:40 PM
Hi,
Try this link,
http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=87818744
It helps to you.
Regards,
Sekhar