‎2009 Mar 19 5:09 AM
Hi,
I want to make a BDC, in which it upload data from multi excel sheets... means from sheet1, sheet2, sheet3...at a time...
Any example please send .
plz let me know...
thanks..
‎2009 Mar 20 7:42 AM
Hi Deepak,
For ypur problem you have to take care about the number of record in your internal table.
Each Excel sheet contain 65,536.
1. First count the number of record in table using Descibe line <itab> into <counter>.
2. If the record is less than 65,536 then prepare file name and download the records in file upto 65,536 record.
3. If the record is more than 65,536 then prepare second file name and download next 65,536 records in second file.
4. similarly do it for further records.
For Programing referrence you can refer this code::
START-OF-SELECTION.
PERFORM select-data.
PERFORM move-itab_down.
END-OF-SELECTION.
data : p_filename type string.
p_filename = filename.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
FILENAME = p_filename
WRITE_FIELD_SEPARATOR = 'X'
CHANGING
DATA_TAB = itab_down[]
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
NOT_SUPPORTED_BY_GUI = 22
ERROR_NO_GUI = 23
others = 24.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
codepage = ' '
filename = p_filename
trunc_trailing_blanks = 'X'
WRITE_FIELD_SEPARATOR = space
COL_SELECT = ' '
COL_SELECTMASK = ' '
filetype = 'ASC'
TABLES
data_tab = itab_down
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
OTHERS = 7.
*
if sy-subrc = 0.
message s000(ZMSD) with 'Successfully downloaded'.
else.
case sy-subrc.
when 1. message s000(ZMSD) with 'Failed- File not found' .
when 2. message s000(ZMSD) with 'Failed- NO_BATCH'.
when 3. message s000(ZMSD) with 'Failed- GUI_REFUSE_FILETRANSF'.
when 4. message s000(ZMSD) with 'Failed- INVALID_TYPE '.
when 5. message s000(ZMSD) with 'Failed- NO_AUTHORITY '.
when 6. message s000(ZMSD) with 'Failed- UNKNOWN_ERROR'.
when 7. message s000(ZMSD) with 'Failed- HEADER_NOT_ALLOWED' .
when 8. message s000(ZMSD) with 'Failed- SEPARATOR_NOT_ALLOWED'.
when 9. message s000(ZMSD) with 'Failed- FILESIZE_NOT_ALLOWED'.
when 10. message s000(ZMSD) with 'Failed- HEADER_TOO_LONG'.
when 11. message s000(ZMSD) with 'Failed- DP_ERROR_CREATE'.
when 12. message s000(ZMSD) with 'Failed- DP_ERROR_SEND' .
when 13. message s000(ZMSD) with 'Failed- DP_ERROR_WRITE'.
when 14. message s000(ZMSD) with 'Failed- UNKNOWN_DP_ERROR' .
when 15. message s000(ZMSD) with 'Failed- ACCESS_DENIED'.
when 16. message s000(ZMSD) with 'Failed- DP_OUT_OF_MEMORY' .
when 17. message s000(ZMSD) with 'Failed- DISK_FULL' .
when 18. message s000(ZMSD) with 'Failed- DP_TIMEOUT' .
when 19. message s000(ZMSD) with 'Failed- File not found' .
when 20. message s000(ZMSD) with 'Failed-DATAPROVIDER_EXCEPTION '.
when 21. message s000(ZMSD) with 'Failed-CONTROL_FLUSH_ERROR'.
when 22. message s000(ZMSD) with 'Failed-NOT_SUPPORTED_BY_GUI'.
when 23. message s000(ZMSD) with 'Failed-ERROR_NO_GUI'.
when 24. message s000(ZMSD) with 'Failed-others '.
endcase.
endif.
‎2009 Mar 19 5:18 AM
Hi,
You cannot write the BDC for this...you can acheive this by OLE
Check this link..
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abap-UploaddatafromExceltoSapusing+OO
Edited by: Avinash Kodarapu on Mar 19, 2009 10:49 AM
‎2009 Mar 19 5:25 AM
Hllo Friend,
You can use function module 'ALSM_EXCEL_TO_INTERNAL_TABLE' or metod CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD for uploading different excel files.
But if each excel file has different format you have to write code separately with the exporting tables from function module / method.
You can use one subroutine for writing the code only for uploading and resue the code for different excel sheets. later write code for handling each excel sheet.
Regards
Krishnendu
‎2009 Mar 19 5:27 AM
Hi,
I think you can not write BDC for this.
better to use this method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD to upload data from multi excel sheets.
Regards,
Jyothi CH.
‎2009 Mar 19 5:31 AM
Hi,
Found a good wiki on forum :
This might help you out.
Pooja
‎2009 Mar 19 5:38 AM
‎2009 Mar 20 7:42 AM
Hi Deepak,
For ypur problem you have to take care about the number of record in your internal table.
Each Excel sheet contain 65,536.
1. First count the number of record in table using Descibe line <itab> into <counter>.
2. If the record is less than 65,536 then prepare file name and download the records in file upto 65,536 record.
3. If the record is more than 65,536 then prepare second file name and download next 65,536 records in second file.
4. similarly do it for further records.
For Programing referrence you can refer this code::
START-OF-SELECTION.
PERFORM select-data.
PERFORM move-itab_down.
END-OF-SELECTION.
data : p_filename type string.
p_filename = filename.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
FILENAME = p_filename
WRITE_FIELD_SEPARATOR = 'X'
CHANGING
DATA_TAB = itab_down[]
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
NOT_SUPPORTED_BY_GUI = 22
ERROR_NO_GUI = 23
others = 24.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
codepage = ' '
filename = p_filename
trunc_trailing_blanks = 'X'
WRITE_FIELD_SEPARATOR = space
COL_SELECT = ' '
COL_SELECTMASK = ' '
filetype = 'ASC'
TABLES
data_tab = itab_down
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
OTHERS = 7.
*
if sy-subrc = 0.
message s000(ZMSD) with 'Successfully downloaded'.
else.
case sy-subrc.
when 1. message s000(ZMSD) with 'Failed- File not found' .
when 2. message s000(ZMSD) with 'Failed- NO_BATCH'.
when 3. message s000(ZMSD) with 'Failed- GUI_REFUSE_FILETRANSF'.
when 4. message s000(ZMSD) with 'Failed- INVALID_TYPE '.
when 5. message s000(ZMSD) with 'Failed- NO_AUTHORITY '.
when 6. message s000(ZMSD) with 'Failed- UNKNOWN_ERROR'.
when 7. message s000(ZMSD) with 'Failed- HEADER_NOT_ALLOWED' .
when 8. message s000(ZMSD) with 'Failed- SEPARATOR_NOT_ALLOWED'.
when 9. message s000(ZMSD) with 'Failed- FILESIZE_NOT_ALLOWED'.
when 10. message s000(ZMSD) with 'Failed- HEADER_TOO_LONG'.
when 11. message s000(ZMSD) with 'Failed- DP_ERROR_CREATE'.
when 12. message s000(ZMSD) with 'Failed- DP_ERROR_SEND' .
when 13. message s000(ZMSD) with 'Failed- DP_ERROR_WRITE'.
when 14. message s000(ZMSD) with 'Failed- UNKNOWN_DP_ERROR' .
when 15. message s000(ZMSD) with 'Failed- ACCESS_DENIED'.
when 16. message s000(ZMSD) with 'Failed- DP_OUT_OF_MEMORY' .
when 17. message s000(ZMSD) with 'Failed- DISK_FULL' .
when 18. message s000(ZMSD) with 'Failed- DP_TIMEOUT' .
when 19. message s000(ZMSD) with 'Failed- File not found' .
when 20. message s000(ZMSD) with 'Failed-DATAPROVIDER_EXCEPTION '.
when 21. message s000(ZMSD) with 'Failed-CONTROL_FLUSH_ERROR'.
when 22. message s000(ZMSD) with 'Failed-NOT_SUPPORTED_BY_GUI'.
when 23. message s000(ZMSD) with 'Failed-ERROR_NO_GUI'.
when 24. message s000(ZMSD) with 'Failed-others '.
endcase.
endif.