2006 Sep 26 5:41 AM
hiii ,
iam doing BDC . i want to download data into an excel sheet . IS THERE ANY FUNCTION MODULE , WITH WHICH I CAN PROVIDE A DYNAMIC FILE NAME LIKE WE DO IN WINDOWS . IT SHOULD PROVIDE AN OPTION TO BROWSE THE DRIVES AND THEN IT SHOULD TAKE THE FILENAME .
regards ,
varma
hiii ,
iam doing BDC . i want to download data into an excel sheet . IS THERE ANY FUNCTION MODULE , WITH WHICH I CAN PROVIDE A DYNAMIC FILE NAME LIKE WE DO IN WINDOWS . IT SHOULD PROVIDE AN OPTION TO BROWSE THE DRIVES AND THEN IT SHOULD TAKE THE FILENAME .
regards ,
varma
2006 Sep 26 5:44 AM
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = ''
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ','
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ';'
COL_SELECT_MASK = ','
DAT_MODE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = it_final
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.
2006 Sep 26 5:47 AM
while recording , record that F4 help for file also so that it becomes part of ur BDC
2006 Sep 26 5:52 AM
hi,
u can get the filename from the selection-screen on which file name is a parameter.
1. the file location may be local PC or application server.
2. if local PC u can use FM <b>/SAPDMC/LSM_F4_FRONTEND_FILE</b>
3. if u want to have file on application server u can use FM /SAPDMC/LSM_F4_SERVER_FILE
reward if useful....
2006 Sep 26 6:09 AM
Hi Varma,
Please try 'TEST_FRONTEND_SERVICES' program which demonstrates how to use a class 'CL_GUI_FRONTEND_SERVICES'
If you can not get this class or report then write to me on [email protected]
The reason for not getting report or class is use of old SAP version. In this case you can use function module download which has option of opening a dialog to download the file.
Best Regards,
Chintamani
2006 Sep 26 6:39 AM
Hi Ravi
Try the method FILE_SAVE_DIALOG from CL_GUI_FRONTEND_SERVICES class.
Thanks
Kathirvel
2006 Sep 26 6:47 AM
Hi Ravi
Try this code and let me know if it did not solve your problem.
REPORT zkb_file_download .
DATA: i_t000 TYPE STANDARD TABLE OF t000.
DATA: v_filename TYPE string,
v_path TYPE string,
v_fullpath TYPE string.
SELECT * FROM t000 INTO TABLE i_t000.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
CHANGING
filename = v_filename
path = v_path
fullpath = v_fullpath
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = v_fullpath
filetype = 'ASC'
CHANGING
data_tab = i_t000
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Thanks
Kathirvel
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |