2008 May 26 2:06 AM
Hi
I am downloading data using GUI_DOWNLOAD Fm. I need to download the file type as XLS. If i put Xls in file tye, Sy-subrc = 4.
if i put DBF i can able to download data. Pls help me out
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_filename
filetype = 'XLS'
write_field_separator = 'X'
IMPORTING
filelength = lv_file_len
TABLES
data_tab = it_final
fieldnames = t_header
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
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2008 May 26 2:23 AM
Hi Kumar,
SY-SUBRC = 4 is the exception 'INVALID_TYPE'. If you look into the source code of FM 'GUI_DOWNLOAD' (I took it from 4.6c release), there is a check on 'FILETYPE' as below:
Filetype parameter valid ?
CASE filetype.
WHEN 'BIN' OR 'ASC'.
WHEN OTHERS.
RAISE INVALID_TYPE.
ENDCASE.
This is at the first check in the FM. You can check the source code in your SAP system and can not give anything other than mentioned there.
I my case (4.6c), I can give either 'BIN' or 'ASC'. I am wondering how you were able to use 'DBF' - may be SAP might have included 'DBF' in recent release.
But you can give filename with extensions in 'FILENAME' paramter. e.g. "C:\SAPDownload\myFile.xls", in which case the file will be saved as an excel workbook.
Regards
Suresh Radhakrishnan
2008 May 26 2:17 AM
Hi,
Dont give any filetype in the FM. It automatically fetches from the file extension.
For ex: if your file path is C:/desktop/test.xls
It will download in excel format.
If your file path is C:/desktop/test.txt
It will download in text format.
Just remove the file type paramter from your FM and try out.
Reward if found useful..
Thanks & regards,
Prakash Ghantasala
2008 May 26 2:23 AM
Hi Kumar,
SY-SUBRC = 4 is the exception 'INVALID_TYPE'. If you look into the source code of FM 'GUI_DOWNLOAD' (I took it from 4.6c release), there is a check on 'FILETYPE' as below:
Filetype parameter valid ?
CASE filetype.
WHEN 'BIN' OR 'ASC'.
WHEN OTHERS.
RAISE INVALID_TYPE.
ENDCASE.
This is at the first check in the FM. You can check the source code in your SAP system and can not give anything other than mentioned there.
I my case (4.6c), I can give either 'BIN' or 'ASC'. I am wondering how you were able to use 'DBF' - may be SAP might have included 'DBF' in recent release.
But you can give filename with extensions in 'FILENAME' paramter. e.g. "C:\SAPDownload\myFile.xls", in which case the file will be saved as an excel workbook.
Regards
Suresh Radhakrishnan
2008 May 26 2:40 AM
Hi
Even if i put DBF file is downloaded as XLS. But file type is DBF. User need the XLS file type only.
2008 May 26 3:33 AM
Hi Kumar,
Just remove file type and use code like below
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = <C:\text.xls>
write_field_separator = 'X'
TABLES
data_tab = itab
fieldnames = <itab_label>
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
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
2008 May 26 3:56 AM
Hi Kumar..
If yu want to upload Excel file use this FM
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = file_name
i_begin_col = 1
i_begin_row = 2
i_end_col = 255
i_end_row = 65000
tables
intern = it_excel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
MESSAGE E000 WITH TEXT-E01 PA_FILE.
endif.
After uploading we need to do some code...
First let me know if YOu need a worhtful help...
Regards,
Sg
2008 May 26 3:57 AM
2008 May 26 4:08 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |