DATA: gt_fieldcatalog TYPE lvc_t_fcat, gs_fieldcatalog TYPE lvc_s_fcat, lr_data TYPE REF TO data, r_result_data TYPE REF TO cl_salv_ex_result_data_table, lv_file_name TYPE string, l_version TYPE string, l_mimetype TYPE char128, l_mimet TYPE string, ev_excel TYPE xstring. FIELD-SYMBOLS: <fs_01> TYPE any . * *??字段信息 DEFINE add_cata. GS_FIELDCATALOG-FIELDNAME = &1. GS_FIELDCATALOG-SELTEXT = &2. APPEND GS_FIELDCATALOG TO GT_FIELDCATALOG. END-OF-DEFINITION. add_cata 'SALES_ORG' 'Sales Org. ID'. add_cata 'ZZCATEGORY' 'Category'. add_cata 'ZZCON_TYPE' 'Consulting Type'. add_cata 'ZZCON_TYPET' 'Consulting Type Description'. add_cata 'QTY_PHONE' 'Qty By Phone'. add_cata 'QTY_MAIL' 'Qty By Email'. add_cata 'QTY_OFFSITE' 'Qty By Official Site'. add_cata 'QTY_MEDIA' 'Qty By Social Media'. add_cata 'QTY_OTHER' 'Qty By Other'. add_cata 'QTY_TOTAL' 'Total'. add_cata 'QTY_ZSV1' 'HSI Standard SRO'. add_cata 'RAT' 'Technical resolution rate'. DATA lo_nd_total TYPE REF TO if_wd_context_node. DATA lt_total TYPE wd_this->elements_total. * navigate from <CONTEXT> to <TOTAL> via lead selection lo_nd_total = wd_context->get_child_node( name = wd_this->wdctx_total ). * @TODO handle non existant child * IF lo_nd_total IS INITIAL. * ENDIF. lo_nd_total->get_static_attributes_table( IMPORTING table = lt_total ). GET REFERENCE OF lt_total INTO lr_data. lv_file_name = 'export.xls'. *//导出excel r_result_data = cl_salv_ex_util=>factory_result_data_table( r_data = lr_data t_fieldcatalog = gt_fieldcatalog ). 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. DATA: gs_choice TYPE if_salv_bs_xml=>s_type_xml_choice. gs_choice-version = if_salv_bs_xml=>version_25. gs_choice-xml_type = if_salv_bs_xml=>c_type_excel_xml. CALL METHOD cl_salv_bs_tt_util=>if_salv_bs_tt_util~transform EXPORTING xml_type = gs_choice-xml_type xml_version = l_version r_result_data = r_result_data xml_flavour = if_salv_bs_c_tt=>c_tt_xml_flavour_export IMPORTING xml = ev_excel. CALL FUNCTION 'SDOK_MIMETYPE_GET' EXPORTING extension = 'xls' IMPORTING mimetype = l_mimetype. IF ev_excel IS NOT INITIAL."下载excel l_mimet = l_mimetype. CALL METHOD cl_wd_runtime_services=>attach_file_to_response EXPORTING i_filename = lv_file_name i_content = ev_excel i_in_new_window = abap_false i_mime_type = l_mimet. ENDIF.