Code: Alles auswählen.
FUNCTION Z_BC_DOWNLOAD_ITAB_ALV .
*"----------------------------------------------------------------------
*"*"Global Interface:
*" IMPORTING
*" REFERENCE(I_ITFILTER) TYPE SLIS_T_FILTER_ALV OPTIONAL
*" REFERENCE(I_ITFDCAT) TYPE SLIS_T_FIELDCAT_ALV
*" REFERENCE(I_LAYOUT) TYPE SLIS_LAYOUT_ALV
*" CHANGING
*" REFERENCE(C_ITDATA) TYPE TABLE
*"----------------------------------------------------------------------
" local data
data: l_itfdcat type kkblo_t_fieldcat.
data: l_layout type kkblo_layout.
data: l_filename type rlgrap-filename.
" transform ALV-Data to KKB-Data
CALL FUNCTION 'REUSE_ALV_TRANSFER_DATA'
EXPORTING
IT_FIELDCAT = i_itfdcat
IS_LAYOUT = i_layout
* IT_SORT =
* IT_FILTER =
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IS_KEYINFO =
* IT_EVENT_EXIT =
* IS_LIST_SCROLL =
* IS_PRINT =
* IS_LINEINFO =
IMPORTING
ET_FIELDCAT = l_itfdcat
ES_LAYOUT = l_layout
* ET_SORT =
* ET_FILTER =
* ET_EXCLUDING =
* ET_SPECIAL_GROUPS =
* ES_KEYINFO =
* ET_EVENT_EXIT =
* ES_LIST_SCROLL =
* ES_LINEINFO =
.
"select filetype
data: ls_xml_choice type if_salv_bs_xml=>s_type_xml_choice.
data: lt_xml_choice type if_salv_bs_xml=>t_type_xml_choice.
call method cl_salv_export_xml_dialog=>execute
* exporting
* gui_type = 1
* display_mode = display_mode
receiving
value = lt_xml_choice.
read table lt_xml_choice into ls_xml_choice index 1.
if sy-subrc ne 0.
return.
endif.
"filetype xxl
if ls_xml_choice-xml_type eq if_salv_bs_xml=>c_type_xxl.
call function 'K_KKB_SUBTOTALS_CHECK'
exporting
it_fieldcat = l_itfdcat
is_layout = l_layout
* I_LISTTYPE =
* I_INCL_INVISIBLE_FIELDS =
exceptions
no_subtotals_by_layout = 1
no_subchoice_by_layout = 2
no_do_sum_by_fieldcat = 3
others = 4.
if sy-subrc eq 0.
message i064(0k).
endif.
call function 'ALV_XXL_CALL'
exporting
i_tabname = 'ITDATA'
is_layout = l_layout
it_fieldcat = l_itfdcat
* i_callback_top_of_page =
i_title = sy-title
tables
it_outtab = c_itdata
exceptions
others = 1.
if sy-subrc ne 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
return.
endif.
"not xxl
data: lr_controller type ref to cl_salv_export_c8r.
data: lr_table type ref to cl_salv_table.
data: lr_columns type ref to cl_salv_columns_table.
data: l_column type lvc_fname.
data: ls_hype type if_salv_export=>s_type_hlink.
data: xml type xstring.
data: r_result_data type ref to cl_salv_ex_result_data_table.
data: ls_param_lvc type if_salv_export=>s_type_param_lvc.
data: lr_data type ref to data.
data: l_flavour type string.
data: l_version type string.
ls_hype-hlink_colname = space.
create object lr_controller
exporting
t_choice = lt_xml_choice.
call function 'LVC_TRANSFER_FROM_KKBLO'
exporting
* I_TECH_COMPLETE =
* I_STRUCTURE_NAME =
it_fieldcat_kkblo = l_itfdcat
* it_sort_kkblo = gt_stack-it_sort
* it_filter_kkblo = l_itfilter
is_layout_kkblo = l_layout
importing
et_fieldcat_lvc = ls_param_lvc-t_fcat
et_sort_lvc = ls_param_lvc-t_sort
* et_filter_lvc = ls_param_lvc-t_filt
es_layout_lvc = ls_param_lvc-s_layo
tables
it_data = c_itdata
exceptions
it_data_missing = 0
others = 0.
get reference of c_itdata[] into lr_data.
if cl_salv_bs_a_xml_base=>get_version( )
eq if_salv_bs_xml=>version_25
or cl_salv_bs_a_xml_base=>get_version( )
eq if_salv_bs_xml=>version_26.
call method cl_salv_ex_util=>factory_result_data_table
exporting
* t_selected_rows = t_selected_rows
* t_selected_columns = t_selected_columns
* t_selected_cells = t_selected_cells
r_data = lr_data
s_layout = ls_param_lvc-s_layo
t_fieldcatalog = ls_param_lvc-t_fcat
t_sort = ls_param_lvc-t_sort
t_filter = ls_param_lvc-t_filt
* t_hyperlinks = t_hyperlinks
* s_current_cell = s_current_cell
* hyperlink_entry_column = hyperlink_entry_column
* dropdown_entry_column = dropdown_entry_column
* t_dropdown_values = t_dropdown_values
* r_top_of_list = r_top_of_list
* r_end_of_list = r_end_of_list
receiving
r_result_data_table = r_result_data.
case cl_salv_bs_a_xml_base=>get_version( ).
when if_salv_bs_xml=>version_25.
l_version = if_salv_bs_xml=>version_25.
when if_salv_bs_xml=>version_26.
l_version = if_salv_bs_xml=>version_26.
endcase.
l_flavour = if_salv_bs_c_tt=>c_tt_xml_flavour_export.
call method cl_salv_bs_tt_util=>if_salv_bs_tt_util~transform
exporting
xml_type = ls_xml_choice-xml_type
xml_version = l_version
r_result_data = r_result_data
xml_flavour = l_flavour
gui_type = if_salv_bs_xml=>c_gui_type_gui
importing
xml = xml.
else.
call method lr_controller->execute
exporting
t_fcat = ls_param_lvc-t_fcat
t_sort = ls_param_lvc-t_sort
t_filt = ls_param_lvc-t_filt
s_layo = ls_param_lvc-s_layo
* s_hype = s_hype
* r_form_tol = r_form_tol
* r_form_eol = r_form_eol
importing
e_xml = xml
* e_mimetype = e_mimetype
* e_filename = e_filename
changing
r_data = lr_data.
endif.
"file download
call method cl_salv_export_xml_dialog=>download
exporting
s_xml_choice = ls_xml_choice
xml = xml.
ENDFUNCTION.
Code: Alles auswählen.
DATA lo_salv_table TYPE REF TO cl_salv_table.
DATA lv_file TYPE string.
cl_salv_table=>factory( IMPORTING r_salv_table = lo_salv_table
CHANGING t_table = lt_tabelle ).
data(lv_xstring) = lo_salv_table->to_xml( xml_type = if_salv_bs_xml=>c_type_xlsx ).
CONCATENATE 'DATEI_' sy-datum '.xlsx' INTO lv_file.
OPEN DATASET lv_file FOR OUTPUT IN BINARY MODE.
TRANSFER lv_xstring TO lv_file.
CLOSE DATASET lv_file.
Code: Alles auswählen.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\DOWNLOADED.txt'
FILETYPE = 'ASC'
* APPEND = 'X'
WRITE_FIELD_SEPARATOR = 'X'
IMPORTING
* FILELENGTH = V_FILELEN
TABLES
DATA_TAB = ITAB
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.
ELSE.
MESSAGE I000(Z00) WITH V_FILELEN 'Bytes transferred'.
ENDIF.
hier müsste ich ja z.B. die interne Tabelle übergeben, aber ich möchte doch lv_file downloaden, oder?