2010 Feb 01 7:12 PM
I am trying download the table data into a file. It is writing first file successfully, when it comes to second set of data to fetch from table it is giving short dump. maybe Database connection lost ?
Runtime Errors DBIF_RSQL_INVALID_CURSOR
Exception CX_SY_OPEN_SQL_DB
Anybody knows about this
OPEN CURSOR WITH HOLD C_CURSOR FOR
SELECT * FROM (p_table).
DO.
FETCH NEXT CURSOR C_CURSOR INTO TABLE <F_FS> PACKAGE SIZE 50.
IF sy-subrc <> 0.
CLOSE CURSOR C_CURSOR.
EXIT.
ENDIF.
LOOP AT <F_FS> ASSIGNING <F_FS2>.
append itab.
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = L_FILE
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = '|'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_WRITE_ERROR = 1
OTHERS = 22.
IF SY-SUBRC = 0.
FREE ITAB.
REFRESH ITAB.
ENDIF.
ENDDO.Edited by: fract_get on Feb 1, 2010 8:20 PM
2010 Feb 01 7:38 PM
Hi
Probably the fm GUI_DOWNLOAD raises a COMIT and this can interrupt the connection.
U should place the call of that fm out from the selection:
OPEN CURSOR WITH HOLD C_CURSOR FOR
SELECT * FROM (p_table).
DO.
FETCH NEXT CURSOR C_CURSOR INTO TABLE <F_FS> PACKAGE SIZE 50.
IF sy-subrc NE 0.
CLOSE CURSOR C_CURSOR.
EXIT.
ENDIF.
LOOP AT <F_FS> ASSIGNING <F_FS2>.
append itab.
ENDLOOP.
ENDDO.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = L_FILE
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = '|'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_WRITE_ERROR = 1
OTHERS = 22.
IF SY-SUBRC = 0.
FREE ITAB.
REFRESH ITAB.
ENDIF.Max
I am trying download the table data into a file. It is writing first file successfully, when it comes to second set of data to fetch from table it is giving short dump. maybe Database connection lost ?
Runtime Errors DBIF_RSQL_INVALID_CURSOR
Exception CX_SY_OPEN_SQL_DB
Anybody knows about this
OPEN CURSOR WITH HOLD C_CURSOR FOR
SELECT * FROM (p_table).
DO.
FETCH NEXT CURSOR C_CURSOR INTO TABLE <F_FS> PACKAGE SIZE 50.
IF sy-subrc <> 0.
CLOSE CURSOR C_CURSOR.
EXIT.
ENDIF.
LOOP AT <F_FS> ASSIGNING <F_FS2>.
append itab.
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = L_FILE
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = '|'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_WRITE_ERROR = 1
OTHERS = 22.
IF SY-SUBRC = 0.
FREE ITAB.
REFRESH ITAB.
ENDIF.
ENDDO.Edited by: fract_get on Feb 1, 2010 8:20 PM
2010 Feb 01 7:38 PM
Hi
Probably the fm GUI_DOWNLOAD raises a COMIT and this can interrupt the connection.
U should place the call of that fm out from the selection:
OPEN CURSOR WITH HOLD C_CURSOR FOR
SELECT * FROM (p_table).
DO.
FETCH NEXT CURSOR C_CURSOR INTO TABLE <F_FS> PACKAGE SIZE 50.
IF sy-subrc NE 0.
CLOSE CURSOR C_CURSOR.
EXIT.
ENDIF.
LOOP AT <F_FS> ASSIGNING <F_FS2>.
append itab.
ENDLOOP.
ENDDO.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = L_FILE
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = '|'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_WRITE_ERROR = 1
OTHERS = 22.
IF SY-SUBRC = 0.
FREE ITAB.
REFRESH ITAB.
ENDIF.Max
2010 Feb 01 8:38 PM
Probably you are correct, but i want to download next set of data into another file. I am writing a program to download the table data in multiple files based on package size.
How can i get the next set of data...
2010 Feb 01 8:45 PM
Get all of your data into different internal tables using PACKAGE SIZE and then do the download.
As Max said, anything that causes a COMMIT will cause the CURSOR to lose it's place. I don't think you can do a PERFORM.
Rob
2010 Feb 01 11:27 PM
Table input is dynamic. How can i create different internal tables during the program execution....
2010 Feb 02 1:37 PM
Hi
U can try to something like this:
TYPES: TY_FILE TYPE STRING.
TYPES: TY_T_FILES TYPE TABLE OF TY_FILE.
DATA: BEGIN OF T_FILES OCCURS 0,
L_FILE TYPE STRING,
T_DATA TYPE TY_T_FILES,
END OF T_FILES.
OPEN CURSOR WITH HOLD C_CURSOR FOR
SELECT * FROM (P_TABLE).
DO.
FETCH NEXT CURSOR C_CURSOR INTO TABLE <F_FS> PACKAGE SIZE 50.
IF SY-SUBRC NE 0.
CLOSE CURSOR C_CURSOR.
EXIT.
ENDIF.
T_FILES-L_FILE = 'C:\FILE.........'.
REFRESH T_FILES-T_DATA.
LOOP AT <F_FS> ASSIGNING <F_FS2>.
APPEND <F_FS2> TO T_FILES-T_DATA.
* APPEND ITAB.
ENDLOOP.
APPEND T_FILES.
ENDDO.
*
LOOP AT T_FILES.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = T_FILES-L_FILE
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = '|'
TABLES
DATA_TAB = T_FILES-T_DATA
EXCEPTIONS
FILE_WRITE_ERROR = 1
OTHERS = 22.
ENDLOOP.Max
2010 Feb 02 7:15 AM
Hi,
It seems you want to download the content into different files of 50 lines each. If this is the requirement, why dont you build some sort of logic as shown below to avoid losing database connection for the cursor.
OPEN CURSOR WITH HOLD C_CURSOR FOR
SELECT * FROM (p_table).
DO.
FETCH NEXT CURSOR C_CURSOR INTO TABLE <F_FS> PACKAGE SIZE 50.
IF sy-subrc 0.
CLOSE CURSOR C_CURSOR.
EXIT.
ENDIF.
LOOP AT <F_FS> ASSIGNING <F_FS2>.
append itab.
ENDLOOP.
ENDDO.
Var2 = 1.
Describe Table itab Lines var1. "Count number of tables
no0ftab = var1 Mod 50.
nooftab = nooftab + 1.
Do nooftab Times.
Loop at itab from Var2 to 50.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = L_FILE
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = '|'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_WRITE_ERROR = 1
OTHERS = 22.
IF SY-SUBRC = 0.
ENDIF.
EndLoop.
Var2 = Var2 + 50.
EndDo.
Thanks,
Vinny