class ZCL_EXCEL_CONVERTER_SALV_TABLE definition public final create public . public section. *"* public components of class ZCL_EXCEL_CONVERTER_SALV_TABLE *"* do not include other source files here!!! interfaces ZIF_EXCEL_CONVERTER . *"* protected components of class ZCL_EXCEL_CONVERTER_SALV_TABLE *"* do not include other source files here!!! protected section. *"* private components of class ZCL_EXCEL_CONVERTER_SALV_TABLE *"* do not include other source files here!!! private section. *"* local class implementation for public class *"* use this source file for the implementation part of *"* local helper classes *"* use this source file for any type declarations (class *"* definitions, interfaces or data types) you need for method *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class method ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT. data: lo_salv type ref to cl_salv_table. try. lo_salv ?= io_object. catch cx_sy_move_cast_error . raise exception type zcx_excel. endtry. endmethod. METHOD zif_excel_converter~create_fieldcatalog. DATA: lo_salv TYPE REF TO cl_salv_table. DATA: lo_columns TYPE REF TO cl_salv_columns_table, lo_column TYPE REF TO cl_salv_column_table, lo_aggregations TYPE REF TO cl_salv_aggregations, lo_aggregation TYPE REF TO cl_salv_aggregation, lo_sorts TYPE REF TO cl_salv_sorts, lo_sort TYPE REF TO cl_salv_sort, lo_display TYPE REF TO cl_salv_display_settings, l_agre TYPE salv_de_aggregation, lt_column TYPE salv_t_column_ref, ls_column TYPE salv_s_column_ref, ls_fieldcatalog TYPE zexcel_s_converter_fcat, ls_ref TYPE salv_s_ddic_reference, l_alignment TYPE salv_de_alignment, l_fix TYPE sap_bool, l_optimized TYPE sap_bool. FIELD-SYMBOLS: <fs_stable> TYPE any. TRY. zif_excel_converter~can_convert_object( io_object = io_object ). ENDTRY. lo_salv ?= io_object. CLEAR: es_layout, et_fieldcatalog. IF lo_salv IS BOUND. lo_columns = lo_salv->get_columns( ). lt_column = lo_columns->get( ) . lo_aggregations = lo_salv->get_aggregations( ) . lo_display = lo_salv->get_display_settings( ) . es_layout-is_stripped = lo_display->is_striped_pattern( ) . l_optimized = lo_columns->is_optimized( ). LOOP AT lt_column INTO ls_column. CLEAR ls_fieldcatalog. IF ls_column-r_column->is_technical( ) = abap_false. TRY. lo_column ?= lo_columns->get_column( columnname = ls_column-columnname ). CATCH cx_salv_not_found. RAISE EXCEPTION TYPE zcx_excel. ENDTRY. ls_ref = ls_column-r_column->get_ddic_reference( ). ls_fieldcatalog-tabname = ls_ref-table. ls_fieldcatalog-fieldname = ls_ref-field. ls_fieldcatalog-columnname = ls_column-columnname. TRY. ls_fieldcatalog-position = lo_columns->get_column_position( columnname = ls_column-columnname ). CATCH cx_salv_not_found. RAISE EXCEPTION TYPE zcx_excel. ENDTRY. ls_fieldcatalog-inttype = ls_column-r_column->get_ddic_inttype( ). ls_fieldcatalog-scrtext_s = ls_column-r_column->get_short_text( ) . ls_fieldcatalog-scrtext_m = ls_column-r_column->get_medium_text( ) . ls_fieldcatalog-scrtext_l = ls_column-r_column->get_long_text( ). TRY. lo_aggregation = lo_aggregations->get_aggregation( columnname = ls_column-columnname ) . CATCH cx_salv_not_found. CLEAR lo_aggregation. ENDTRY. IF lo_aggregation IS BOUND. l_agre = lo_aggregation->get( ). CASE l_agre. WHEN if_salv_c_aggregation=>total. " Total ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_sum. WHEN if_salv_c_aggregation=>minimum. " Minimum ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_min. WHEN if_salv_c_aggregation=>maximum. " Maximum ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_max. WHEN if_salv_c_aggregation=>average. " Mean Value ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_average. WHEN OTHERS. CLEAR ls_fieldcatalog-totals_function. ENDCASE. ENDIF. ls_fieldcatalog-is_visible = ls_column-r_column->is_visible( ). ls_fieldcatalog-fix_column = lo_column->is_key( ). l_fix = lo_column->is_key_presence_required( ). IF l_optimized = '1' OR l_optimized = abap_true. ls_fieldcatalog-is_optimized = abap_true. ELSE. l_optimized = ls_column-r_column->is_optimized( ). IF l_optimized = '1' OR l_optimized = abap_true. ls_fieldcatalog-is_optimized = abap_true. ENDIF. ENDIF. l_alignment = ls_column-r_column->get_alignment( ) . CASE l_alignment. WHEN if_salv_c_alignment=>left. " Align left ls_fieldcatalog-alignment = zcl_excel_style_alignment=>c_horizontal_left. WHEN if_salv_c_alignment=>right. " Align right ls_fieldcatalog-alignment = zcl_excel_style_alignment=>c_horizontal_right. WHEN if_salv_c_alignment=>centered. " Centered ls_fieldcatalog-alignment = zcl_excel_style_alignment=>c_horizontal_center. WHEN OTHERS. CLEAR ls_fieldcatalog-alignment. ENDCASE. APPEND ls_fieldcatalog TO et_fieldcatalog. ENDIF. ENDLOOP. IF l_fix IS NOT INITIAL. es_layout-is_fixed = abap_true. ENDIF. ENDIF. ENDMETHOD.