Download Internal table data into excel sheet
**Download File which is received
lwa_dwnld-unit_code = 'Unit'.
lwa_dwnld-scheme_code = 'Scheme Code'.
lwa_dwnld-div_code = 'Division Code'.
lwa_dwnld-gl_code = 'GL Code'.
lwa_dwnld-dr_amt = 'Debit Amount'.
lwa_dwnld-cr_amt = 'Credit Amount'.
lwa_dwnld-jv_no = 'JV Number'.
lwa_dwnld-ch_jv_type = 'JV Type'.
APPEND lwa_dwnld TO lt_dwnld.
LOOP AT lt_olimms INTO lwa_olimms.
MOVE-CORRESPONDING lwa_olimms TO lwa_dwnld.
APPEND lwa_dwnld TO lt_dwnld.
ENDLOOP.
**First Download
IF sy-mandt+0(1) = '2'.
CONCATENATE 'C:\OLIMMS\DEV\LEGACYDATA' sy-mandt sy-datum '.XLS' INTO lv_path.
ELSEIF sy-mandt+0(1) = '3'.
CONCATENATE 'C:\OLIMMS\QTY\LEGACYDATA' sy-mandt sy-datum '.XLS' INTO lv_path.
ELSEIF sy-mandt+0(1) = '4'.
CONCATENATE 'C:\OLIMMS\PRD\LEGACYDATA' sy-mandt sy-datum '.XLS' INTO lv_path.
ENDIF.
* lv_path = 'E:\OLIMMS.XLS'.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = lv_path
filetype = 'ASC'
write_field_separator = 'X'
CHANGING
data_tab = lt_dwnld
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.
* Implement suitable error handling here
ENDIF.
No comments:
Post a Comment