2011 Aug 04 7:49 AM
Hello Experts,
I have created a report which has records more than 65000 as the excel sheet takes records only upto 65k .
Since iI need to save the file on apll server I need to create more than 1 file say 4 files from one report.
Can anyone help me out on this.
Thanks & Regards,
Nikhil.
2011 Aug 04 8:09 AM
Hi,
you can save the files in loop. Do you think you'll have some problems with saving? I save many files on application server from one report. It works good.
2011 Aug 04 8:12 AM
Hi Alexandar,
Thanks for your quick response.
Can you help me out on this, you said you are looping the files.
Can you give me a sample code of this.
I am trying to split internal tables but its not working in my case.
Thanks,
Nikhil.
2011 Aug 04 8:22 AM
Hi nikhil,
did you trying splitting the records in the internal table for a specified number of records and put them in the application server separately with different file names.
2011 Aug 04 8:30 AM
I've created FM for downloading on application server. This is simple version of FM. It have some messages in message class ZAM_TXT_FILES.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(I_FILENAME) TYPE STRING
*" TABLES
*" DATA_TAB
*" EXCEPTIONS
*" FILE_WRITE_ERROR
*" UNKNOWN_ERROR
*" ACCESS_DENIED
*" DISK_FULL
*" FILE_NOT_FOUND
*" WRONG_PARAMETER
*" CONVERSION_ERROR
*" ERROR_OPEN_FILE
*"----------------------------------------------------------------------
DATA:
ls_mess TYPE STRING.
TRY.
OPEN DATASET I_FILENAME FOR OUTPUT IN BINARY MODE MESSAGE ls_mess.
LOOP AT DATA_TAB.
TRANSFER DATA_TAB TO I_FILENAME.
ENDLOOP.
CATCH CX_SY_FILE_OPEN. " The file is already open
PERFORM close_dataset USING I_FILENAME.
MESSAGE ID 'ZAM_TXT_FILES' TYPE 'E' NUMBER '001' RAISING FILE_WRITE_ERROR.
CATCH CX_SY_CODEPAGE_CONVERTER_INIT. " The required conversion is not supported
PERFORM close_dataset USING I_FILENAME.
MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING CONVERSION_ERROR.
CATCH CX_SY_CONVERSION_CODEPAGE. " Internal conversion error
PERFORM close_dataset USING I_FILENAME.
MESSAGE ID 'FES' TYPE 'E' NUMBER '026' RAISING CONVERSION_ERROR.
CATCH CX_SY_FILE_AUTHORITY. " No authorization to access a file
PERFORM close_dataset USING I_FILENAME.
MESSAGE ID 'FES' TYPE 'E' NUMBER '012' RAISING ACCESS_DENIED.
CATCH CX_SY_FILE_IO. "An error occurred when writing to the file.
PERFORM close_dataset USING FILENAME.
MESSAGE ID 'FES' TYPE 'E' NUMBER '016' RAISING FILE_WRITE_ERROR.
CATCH CX_SY_PIPES_NOT_SUPPORTED. " OPEN DATASET with addition FILTER is not supported on the current operating system
PERFORM close_dataset USING I_FILENAME.
MESSAGE ID 'ZAM_TXT_FILES' TYPE 'E' NUMBER '002' RAISING UNKNOWN_ERROR.
CATCH CX_SY_TOO_MANY_FILES. " The maximum number of open files has been exceeded
PERFORM close_dataset USING I_FILENAME.
MESSAGE ID 'ZAM_TXT_FILES' TYPE 'E' NUMBER '003' RAISING UNKNOWN_ERROR.
CATCH CX_ROOT. " Unknown error
PERFORM close_dataset USING I_FILENAME.
MESSAGE ID 'FES' TYPE 'E' NUMBER '006' RAISING UNKNOWN_ERROR.
ENDTRY.
IF SY-SUBRC 0.
PERFORM close_dataset USING I_FILENAME.
MESSAGE ID 'ZAM_TXT_FILES' TYPE 'E' NUMBER '000' WITH ls_mess RAISING FILE_WRITE_ERROR.
ENDIF.
PERFORM close_dataset USING I_FILENAME.
FORM close_dataset USING U_FILENAME.
TRY.
CLOSE DATASET U_FILENAME.
CATCH CX_SY_FILE_CLOSE. " No memory space on storage medium
MESSAGE ID 'FES' TYPE 'E' NUMBER '014' RAISING DISK_FULL.
CATCH CX_ROOT. " Unknown error
MESSAGE ID 'FES' TYPE 'E' NUMBER '006' RAISING UNKNOWN_ERROR.
ENDTRY.
ENDFORM. " close_dataset
I have slightly more complex FM. But this also must work.
2011 Aug 04 8:35 AM
Hi,
You can create a counter variable, and increase the variable value by 1 within the loop. if the variable value = 65000, then close the data set and again open the new file on the server. Also set the variable value as 1. In this way you can split the records in the set of 65000.
Thanks.