From f917661bb58165f4345246dcb03adeacf1133015 Mon Sep 17 00:00:00 2001 From: Rene Turnheim Date: Sat, 11 Aug 2012 20:42:16 +0000 Subject: [PATCH] ISSUE #143; Resolved open issues with WD and several other open points. Issue #143 closed. git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@327 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL_CONVERTER.slnk | 412 +++++++++--------- ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV.slnk | 90 ++-- ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV_GRID.slnk | 18 +- ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT.slnk | 16 +- ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT_EX.slnk | 6 +- ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT_WD.slnk | 249 ++++++++++- ZA2X/CLAS/ZCL_EXCEL_CONVERTER_SALV_TABLE.slnk | 13 +- ZA2X/INTF/ZIF_EXCEL_CONVERTER.slnk | 28 +- 8 files changed, 541 insertions(+), 291 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER.slnk index 1c5a211..5044f31 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER.slnk @@ -1,12 +1,12 @@ - - - + + - - - - @@ -52,6 +52,9 @@ public section. !CO_EXCEL type ref to ZCL_EXCEL optional raising ZCX_EXCEL . + methods CREATE_PATH + returning + value(R_PATH) type STRING . methods GET_FILE exporting !E_BYTECOUNT type I @@ -122,41 +125,6 @@ private section. constants C_TYPE_TOT type CHAR1 value 'T'. "#EC NOTEXT data WT_COLOR_STYLES type TT_COLOR_STYLES . - methods GET_COLOR_STYLE - importing - !I_ROW type ZEXCEL_CELL_ROW - !I_FIELDNAME type FIELDNAME - !I_STYLE type ZEXCEL_CELL_STYLE - returning - value(R_STYLE) type ZEXCEL_CELL_STYLE . - methods CLEAN_FIELDCATALOG . - methods SET_CELL_FORMAT - importing - !I_INTTYPE type INTTYPE - !I_DECIMALS type INT1 - returning - value(R_FORMAT) type ZEXCEL_NUMBER_FORMAT . - methods GET_FUNCTION_NUMBER - importing - !I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION - returning - value(R_FUNCTION_NUMBER) type INT1 . - methods LOOP_NORMAL - importing - !I_ROW_INT type ZEXCEL_CELL_ROW - !I_COL_INT type ZEXCEL_CELL_COLUMN - returning - value(R_FREEZE_COL) type INT1 - raising - ZCX_EXCEL . - methods LOOP_SUBTOTAL - importing - !I_ROW_INT type ZEXCEL_CELL_ROW - !I_COL_INT type ZEXCEL_CELL_COLUMN - returning - value(R_FREEZE_COL) type INT1 - raising - ZCX_EXCEL . methods BIND_TABLE importing !I_STYLE_TABLE type ZEXCEL_TABLE_STYLE @@ -169,7 +137,7 @@ private section. value(R_FREEZE_COL) type INT1 raising ZCX_EXCEL . - methods SET_AUTOFILTER_AREA . + methods CLEAN_FIELDCATALOG . methods CREATE_COLOR_STYLE importing !I_STYLE type ZEXCEL_CELL_STYLE @@ -191,9 +159,6 @@ private section. !I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION returning value(R_FORMULA) type STRING . - methods CREATE_PATH - returning - value(R_PATH) type STRING . methods CREATE_STYLE_HDR importing !I_ALIGNMENT type ZEXCEL_ALIGNMENT optional @@ -246,7 +211,18 @@ private section. !IT_TABLE type STANDARD TABLE raising ZCX_EXCEL . - methods SET_FIELDCATALOG . + methods GET_COLOR_STYLE + importing + !I_ROW type ZEXCEL_CELL_ROW + !I_FIELDNAME type FIELDNAME + !I_STYLE type ZEXCEL_CELL_STYLE + returning + value(R_STYLE) type ZEXCEL_CELL_STYLE . + methods GET_FUNCTION_NUMBER + importing + !I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION + returning + value(R_FUNCTION_NUMBER) type INT1 . methods GET_STYLE importing !I_TYPE type CHAR1 @@ -254,7 +230,31 @@ private section. !I_INTTYPE type INTTYPE default SPACE !I_DECIMALS type INT1 default 0 returning - value(R_STYLE) type ZEXCEL_CELL_STYLE . + value(R_STYLE) type ZEXCEL_CELL_STYLE . + methods LOOP_NORMAL + importing + !I_ROW_INT type ZEXCEL_CELL_ROW + !I_COL_INT type ZEXCEL_CELL_COLUMN + returning + value(R_FREEZE_COL) type INT1 + raising + ZCX_EXCEL . + methods LOOP_SUBTOTAL + importing + !I_ROW_INT type ZEXCEL_CELL_ROW + !I_COL_INT type ZEXCEL_CELL_COLUMN + returning + value(R_FREEZE_COL) type INT1 + raising + ZCX_EXCEL . + methods SET_AUTOFILTER_AREA . + methods SET_CELL_FORMAT + importing + !I_INTTYPE type INTTYPE + !I_DECIMALS type INT1 + returning + value(R_FORMAT) type ZEXCEL_NUMBER_FORMAT . + methods SET_FIELDCATALOG . *"* local class implementation for public class *"* use this source file for the implementation part of *"* local helper classes @@ -307,37 +307,57 @@ TYPES: BEGIN OF ts_color_styles, tt_color_styles TYPE HASHED TABLE OF ts_color_styles WITH UNIQUE KEY guid_old fontcolor fillcolor. *"* use this source file for any macro definitions you need *"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + ABAP SLIS SOI - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + method BIND_CELLS. * Do we need subtotals with grouping @@ -352,10 +372,10 @@ TYPES: BEGIN OF ts_color_styles, endmethod. - - - - + + + + method BIND_TABLE. data: lt_field_catalog type zexcel_t_fieldcatalog, ls_field_catalog type zexcel_s_fieldcatalog, @@ -418,7 +438,7 @@ endmethod. endmethod. - + method CLASS_CONSTRUCTOR. DATA: ls_objects TYPE ts_alv_types. @@ -443,7 +463,7 @@ endmethod. endmethod. - + method CLEAN_FIELDCATALOG. DATA: l_position TYPE int1. @@ -480,16 +500,16 @@ endmethod. endmethod. - - - - - - - - - - + + + + + + + + + + method CONVERT. try. @@ -533,10 +553,10 @@ endmethod. endmethod. - - - - + + + + method CREATE_COLOR_STYLE. DATA: ls_styles TYPE ts_styles. DATA: lo_style TYPE REF TO zcl_excel_style. @@ -558,12 +578,12 @@ endmethod. ENDIF. endmethod. - - - - - - + + + + + + method CREATE_FORMULAR_SUBTOTAL. data: l_row_alpha_start type string, l_row_alpha_end type string, @@ -576,11 +596,11 @@ endmethod. concatenate 'SUBTOTAL(' l_func_num ',' i_column l_row_alpha_start ':' i_column l_row_alpha_end ')' into r_formula. endmethod. - - - - - + + + + + method CREATE_FORMULAR_TOTAL. data: l_row_alpha type string, l_row_e_alpha type string. @@ -591,8 +611,8 @@ endmethod. concatenate i_totals_function '(' i_column l_row_alpha ':' i_column l_row_e_alpha ')' into r_formula. endmethod. - - + + method CREATE_PATH. DATA: l_sep TYPE c , l_path TYPE string, @@ -648,9 +668,9 @@ endmethod. endmethod. - - - + + + method CREATE_STYLE_HDR. data: lo_style type ref to zcl_excel_style. @@ -665,11 +685,11 @@ endmethod. ro_style = lo_style . endmethod. - - - - - + + + + + method CREATE_STYLE_NORMAL. DATA: lo_style TYPE REF TO zcl_excel_style, l_format TYPE zexcel_number_format. @@ -696,11 +716,11 @@ endmethod. ENDIF. endmethod. - - - - - + + + + + method CREATE_STYLE_STRIPPED. data: lo_style type ref to zcl_excel_style. data: l_format type zexcel_number_format. @@ -722,11 +742,11 @@ endmethod. endmethod. - - - - - + + + + + method CREATE_STYLE_SUBTOTAL. data: lo_style type ref to zcl_excel_style. data: l_format type zexcel_number_format. @@ -749,11 +769,11 @@ endmethod. endmethod. - - - - - + + + + + method CREATE_STYLE_TOTAL. DATA: lo_style TYPE REF TO zcl_excel_style. DATA: l_format TYPE zexcel_number_format. @@ -792,7 +812,7 @@ endmethod. endmethod. - + method CREATE_TABLE. TYPES: BEGIN OF ts_output, fieldname TYPE fieldname, @@ -836,7 +856,12 @@ endmethod. ENDLOOP. IF lt_components_tab IS NOT INITIAL. "create new line type - lo_struc = cl_abap_structdescr=>create( lt_components_tab ). + TRY. + lo_struc = cl_abap_structdescr=>create( P_COMPONENTS = lt_components_tab + P_STRICT = abap_false ). + CATCH cx_sy_struct_creation. + RETURN. " We can not do anything in this case. + ENDTRY. lo_table = cl_abap_tabledescr=>create( lo_struc ). @@ -855,10 +880,10 @@ endmethod. endmethod. - - - - + + + + method CREATE_TEXT_SUBTOTAL. data: l_string type string, l_func type string. @@ -883,18 +908,18 @@ endmethod. endmethod. - - - - + + + + method CREATE_WORKSHEET. DATA: l_freeze_col TYPE i. DATA: l_guid TYPE oltpguid16. - wo_worksheet->zif_excel_sheet_properties~summarybelow = zif_excel_sheet_properties=>c_below_on. " By default is on - IF wo_data IS BOUND AND wo_worksheet IS BOUND. + wo_worksheet->zif_excel_sheet_properties~summarybelow = zif_excel_sheet_properties=>c_below_on. " By default is on + IF wt_fieldcatalog IS INITIAL. set_fieldcatalog( ) . ELSE. @@ -914,23 +939,23 @@ endmethod. ENDIF. ENDIF. - ENDIF. * Check for freeze panes - IF ws_layout-is_fixed = abap_true. - IF l_freeze_col = 0. - l_freeze_col = w_col_int. + IF ws_layout-is_fixed = abap_true. + IF l_freeze_col = 0. + l_freeze_col = w_col_int. + ENDIF. + wo_worksheet->freeze_panes( EXPORTING ip_num_columns = l_freeze_col + ip_num_rows = w_row_int ) . ENDIF. - wo_worksheet->freeze_panes( EXPORTING ip_num_columns = l_freeze_col - ip_num_rows = w_row_int ) . ENDIF. endmethod. - - - - + + + + method EXECUTE_CONVERTER. DATA: lt_fieldcatalog TYPE zexcel_t_fieldcatalog, ls_fieldcatalog TYPE zexcel_s_converter_fcat, @@ -976,11 +1001,11 @@ endmethod. endmethod. - - - - - + + + + + method GET_COLOR_STYLE. DATA: ls_colors TYPE zexcel_s_converter_col, ls_color_styles TYPE ts_color_styles, @@ -1038,10 +1063,10 @@ endmethod. endmethod. - - - - + + + + method GET_FILE. data: lo_excel_writer type ref to zif_excel_writer, lo_excel type ref to zcl_excel. @@ -1078,9 +1103,9 @@ endmethod. endmethod. - - - + + + method GET_FUNCTION_NUMBER. *Number Function *1 AVERAGE @@ -1111,12 +1136,12 @@ endmethod. endcase. endmethod. - - - - - - + + + + + + method GET_STYLE. DATA: ls_styles TYPE ts_styles, lo_style TYPE REF TO zcl_excel_style. @@ -1163,14 +1188,13 @@ endmethod. ENDIF. endmethod. - - - - - + + + + + method LOOP_NORMAL. - DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, - lo_data TYPE REF TO data, + DATA: lo_data TYPE REF TO data, l_row_header TYPE zexcel_cell_row VALUE '2', l_col_header TYPE zexcel_cell_column_alpha VALUE 'B', l_row_int_start TYPE zexcel_cell_row, @@ -1281,15 +1305,14 @@ endmethod. ENDLOOP. endmethod. - - - - - + + + + + method LOOP_SUBTOTAL. - DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, - lo_data TYPE REF TO data, + DATA: lo_data TYPE REF TO data, l_row_header TYPE zexcel_cell_row VALUE '2', l_col_header TYPE zexcel_cell_column_alpha VALUE 'B', l_row_int_start TYPE zexcel_cell_row, @@ -1631,7 +1654,7 @@ endmethod. endmethod. - + method OPEN_FILE. data: l_bytecount type i, lt_file type solix_tab, @@ -1685,7 +1708,7 @@ endmethod. endmethod. - + method SET_AUTOFILTER_AREA. DATA: ls_area TYPE zexcel_s_autofilter_area, l_lines TYPE i, @@ -1711,19 +1734,19 @@ endmethod. endmethod. - - - - + + + + method SET_CELL_FORMAT. DATA: l_format TYPE zexcel_number_format. CLEAR r_format. CASE i_inttype. WHEN cl_abap_typedescr=>typekind_date. - r_format = zcl_excel_style_number_format=>c_format_date_std. + r_format = wo_worksheet->get_default_excel_date_format( ). WHEN cl_abap_typedescr=>typekind_time. - r_format = zcl_excel_style_number_format=>c_format_date_time6. + r_format = wo_worksheet->get_default_excel_time_format( ). WHEN cl_abap_typedescr=>typekind_float OR cl_abap_typedescr=>typekind_packed. IF i_decimals > 0 . l_format = '#,##0.'. @@ -1735,9 +1758,10 @@ endmethod. WHEN cl_abap_typedescr=>typekind_int OR cl_abap_typedescr=>typekind_int1 OR cl_abap_typedescr=>typekind_int2. r_format = '#,##0'. ENDCASE. + endmethod. - + method SET_FIELDCATALOG. DATA: lr_data TYPE REF TO data, lo_structdescr TYPE REF TO cl_abap_structdescr, @@ -1795,8 +1819,8 @@ endmethod. endmethod. - - + + method WRITE_FILE. data: l_bytecount type i, lt_file type solix_tab, diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV.slnk index edc61d9..e4bd5de 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV.slnk @@ -1,6 +1,6 @@ - - - + + + class ZCL_EXCEL_CONVERTER_ALV definition public abstract @@ -70,15 +70,15 @@ TYPES: BEGIN OF ts_col_converter, ABAP KKBLO - - - - - - - - - METHOD apply_sort. + + + + + + + + + method APPLY_SORT. DATA: lt_otab TYPE abap_sortorder_tab, ls_otab TYPE abap_sortorder. @@ -108,10 +108,10 @@ TYPES: BEGIN OF ts_col_converter, IF lt_otab IS NOT INITIAL. SORT <fs_table> BY (lt_otab). ENDIF. -ENDMETHOD. +endmethod. - - METHOD class_constructor. + + method CLASS_CONSTRUCTOR. * let's fill the color conversion routines. DATA: ls_color TYPE ts_col_converter. * 0 all combination the same @@ -317,20 +317,22 @@ ENDMETHOD. ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White INSERT ls_color INTO TABLE wt_colors. -ENDMETHOD. +endmethod. - - - + + + METHOD get_color. DATA: ls_con_col TYPE zexcel_s_converter_col, ls_color TYPE ts_col_converter, - l_line TYPE i. + l_line TYPE i, + l_color(4) TYPE c. FIELD-SYMBOLS: <fs_tab> TYPE STANDARD TABLE, <fs_stab> TYPE ANY, <fs> TYPE ANY, <fs_tcol> TYPE lvc_t_scol, <fs_scol> TYPE lvc_s_scol. + * Loop trough the table to set the color properties of each line. The color properties field is * Char 4 and the characters is set as follows: * Char 1 = C = This is a color property @@ -348,15 +350,18 @@ ENDMETHOD. ASSIGN COMPONENT ws_layo-info_fname OF STRUCTURE <fs_stab> TO <fs>. IF sy-subrc = 0. IF <fs> IS NOT INITIAL. - READ TABLE wt_colors INTO ls_color WITH TABLE KEY col = <fs>+1(1) - int = <fs>+2(1) - inv = <fs>+3(1). - IF sy-subrc = 0. - ls_con_col-rownumber = l_line. - ls_con_col-columnname = space. - ls_con_col-fontcolor = ls_color-fontcolor. - ls_con_col-fillcolor = ls_color-fillcolor. - INSERT ls_con_col INTO TABLE et_colors. + l_color = <fs>. + IF l_color(1) = 'C'. + READ TABLE wt_colors INTO ls_color WITH TABLE KEY col = l_color+1(1) + int = l_color+2(1) + inv = l_color+3(1). + IF sy-subrc = 0. + ls_con_col-rownumber = l_line. + ls_con_col-columnname = space. + ls_con_col-fontcolor = ls_color-fontcolor. + ls_con_col-fillcolor = ls_color-fillcolor. + INSERT ls_con_col INTO TABLE et_colors. + ENDIF. ENDIF. ENDIF. ENDIF. @@ -383,9 +388,9 @@ ENDMETHOD. ENDIF. ENDMETHOD. - - - + + + METHOD get_filter. DATA: ls_filt TYPE lvc_s_filt, l_line TYPE i, @@ -431,7 +436,12 @@ ENDMETHOD. ls_components-type = lo_addit . INSERT ls_components INTO TABLE lt_components_tab. "create new line type - lo_struc = cl_abap_structdescr=>create( lt_components_tab ). + TRY. + lo_struc = cl_abap_structdescr=>create( p_components = lt_components_tab + p_strict = abap_false ). + CATCH cx_sy_struct_creation. + CONTINUE. + ENDTRY. lo_table = cl_abap_tabledescr=>create( lo_struc ). CREATE DATA lo_tdata TYPE HANDLE lo_table. @@ -461,9 +471,9 @@ ENDMETHOD. ENDMETHOD. - - - + + + METHOD update_catalog. DATA: ls_fieldcatalog TYPE zexcel_s_converter_fcat, ls_ref TYPE salv_s_ddic_reference, @@ -480,10 +490,11 @@ ENDMETHOD. ws_layo-no_keyfix = '0'. cs_layout-is_fixed = abap_true. ENDIF. + LOOP AT wt_fcat INTO ls_fcat. CLEAR: ls_fieldcatalog, l_decimals. - IF ls_fcat-tech = abap_false. + IF ls_fcat-tech = abap_false AND ls_fcat-no_out IS INITIAL. ls_fieldcatalog-tabname = ls_fcat-tabname. ls_fieldcatalog-fieldname = ls_fcat-fieldname . ls_fieldcatalog-columnname = ls_fcat-fieldname . @@ -539,7 +550,11 @@ ENDMETHOD. READ TABLE wt_sort INTO ls_sort WITH KEY fieldname = ls_fcat-fieldname. IF sy-subrc = 0. ls_fieldcatalog-sort_level = 0 . +* IF ls_fieldcatalog-totals_function IS INITIAL. " Not clear why not +* CLEAR ls_fieldcatalog-is_subtotalled. +* ELSE. ls_fieldcatalog-is_subtotalled = ls_sort-subtot. +* ENDIF. ls_fieldcatalog-is_collapsed = ls_sort-expa. IF ls_fieldcatalog-is_subtotalled = abap_true. ls_fieldcatalog-sort_level = ls_sort-spos. @@ -549,6 +564,7 @@ ENDMETHOD. APPEND ls_fieldcatalog TO ct_fieldcatalog. ENDIF. ENDLOOP. + SORT ct_fieldcatalog BY sort_level ASCENDING. cs_layout-max_subtotal_level = 0. LOOP AT ct_fieldcatalog ASSIGNING <fs_scat> WHERE sort_level > 0. diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV_GRID.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV_GRID.slnk index b85d1a4..d569ce3 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV_GRID.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV_GRID.slnk @@ -1,22 +1,22 @@ - - + + class ZCL_EXCEL_CONVERTER_ALV_GRID definition public inheriting from ZCL_EXCEL_CONVERTER_ALV final create public . +public section. *"* public components of class ZCL_EXCEL_CONVERTER_ALV_GRID *"* do not include other source files here!!! -public section. - methods ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT - redefinition . methods ZIF_EXCEL_CONVERTER~CREATE_FIELDCATALOG + redefinition . + methods ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT redefinition . - *"* protected components of class ZCL_EXCEL_CONVERTER_ALV_GRID -*"* do not include other source files here!!! -protected section. + protected section. +*"* protected components of class ZCL_EXCEL_CONVERTER_ALV_GRID +*"* do not include other source files here!!! *"* private components of class ZCL_EXCEL_CONVERTER_ALV_GRID *"* do not include other source files here!!! private section. @@ -28,7 +28,7 @@ private section. *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class - + diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT.slnk index 0d3c5a2..9a7a27c 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT.slnk @@ -1,5 +1,5 @@ - - + + class ZCL_EXCEL_CONVERTER_RESULT definition public inheriting from ZCL_EXCEL_CONVERTER_ALV @@ -29,11 +29,11 @@ private section. *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class - - - - - METHOD get_table. + + + + + method GET_TABLE. DATA: lo_object TYPE REF TO object, ls_seoclass TYPE seoclass, l_method TYPE string. @@ -56,6 +56,6 @@ private section. value = ro_data. ENDIF. -ENDMETHOD. +endmethod. diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT_EX.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT_EX.slnk index 2855d2c..39b991a 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT_EX.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT_EX.slnk @@ -1,5 +1,5 @@ - - + + class ZCL_EXCEL_CONVERTER_RESULT_EX definition public inheriting from ZCL_EXCEL_CONVERTER_RESULT @@ -28,7 +28,7 @@ private section. *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class - + diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT_WD.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT_WD.slnk index c3d4eae..baa95a9 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT_WD.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_RESULT_WD.slnk @@ -1,5 +1,5 @@ - - + + class ZCL_EXCEL_CONVERTER_RESULT_WD definition public inheriting from ZCL_EXCEL_CONVERTER_RESULT @@ -17,9 +17,25 @@ public section. *"* protected components of class ZCL_EXCEL_CONVERTER_RESULT_WD *"* do not include other source files here!!! protected section. - *"* private components of class ZCL_EXCEL_CONVERTER_EX_RESULT + *"* private components of class ZCL_EXCEL_CONVERTER_RESULT_WD *"* do not include other source files here!!! -private section. +private section. + + data WO_CONFIG type ref to CL_SALV_WD_CONFIG_TABLE . + data WT_FIELDS type SALV_WD_T_FIELD_REF . + data WT_COLUMNS type SALV_WD_T_COLUMN_REF . + + methods GET_COLUMNS_INFO + changing + !XS_FCAT type LVC_S_FCAT . + methods GET_FIELDS_INFO + changing + !XS_FCAT type LVC_S_FCAT . + methods CREATE_WT_SORT . + methods CREATE_WT_FILT . + methods CREATE_WT_FCAT + importing + !IO_TABLE type ref to DATA . *"* local class implementation for public class *"* use this source file for the implementation part of *"* local helper classes @@ -28,7 +44,10 @@ private section. *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class - + + + + @@ -48,7 +67,6 @@ ENDMETHOD. METHOD zif_excel_converter~create_fieldcatalog. DATA: lo_result TYPE REF TO cl_salv_wd_result_data_table, - lo_ex_cm TYPE REF TO cl_salv_ex_cm, lo_data TYPE REF TO data. FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE. @@ -62,27 +80,29 @@ ENDMETHOD. CLEAR: es_layout, et_fieldcatalog. + break rturnheim. + IF lo_result IS BOUND. lo_data = get_table( io_object = lo_result->r_model->r_data ). IF lo_data IS BOUND. ASSIGN lo_data->* TO <fs_table> . -* CL_SALV_WD_C_TABLE_V_TABLE " If we want to do it we need this -* if_salv_wd_comp_table_events~on_export_excel( ). -* lo_ex_cm ?= lo_result->r_model->r_model. -* ws_layo = lo_ex_cm->s_layo. -* T_DRDN Instance Attribute Public Type LVC_T_DROP -* wt_fcat = lo_ex_cm->t_fcat. -* wt_filt = lo_ex_cm->t_filt. -* T_HYPE Instance Attribute Public Type LVC_T_HYPE -* T_SELECTED_CELLS Instance Attribute Public Type LVC_T_CELL -* T_SELECTED_COLUMNS Instance Attribute Public Type LVC_T_COL -* wt_sort = lo_ex_cm->t_sort. + + wo_config ?= lo_result->r_model->r_model. + + IF wo_config IS BOUND. + wt_fields = wo_config->if_salv_wd_field_settings~get_fields( ) . + wt_columns = wo_config->if_salv_wd_column_settings~get_columns( ) . + ENDIF. + + create_wt_fcat( io_table = lo_data ). + create_wt_sort( ). + create_wt_filt( ). apply_sort( EXPORTING it_table = <fs_table> IMPORTING eo_table = eo_table ) . - get_color( EXPORTING io_table = eo_table - IMPORTING et_colors = et_colors ) . +* get_color( EXPORTING io_table = eo_table +* IMPORTING et_colors = et_colors ) . get_filter( EXPORTING io_table = eo_table IMPORTING et_filter = et_filter ) . @@ -95,4 +115,195 @@ ENDMETHOD. ENDIF. ENDMETHOD. + + + METHOD create_wt_fcat. + DATA: lr_data TYPE REF TO data, + lo_structdescr TYPE REF TO cl_abap_structdescr, + lo_elemdescr TYPE REF TO cl_abap_elemdescr, + lt_dfies TYPE ddfields, + ls_dfies TYPE dfies, + lv_sytabix TYPE sytabix, + lt_components TYPE abap_component_tab, + ls_component LIKE LINE OF lt_components. + + DATA: ls_fcat TYPE lvc_s_fcat. + DATA: lt_filters TYPE salv_wd_t_filter_rule_ref, + ls_filt TYPE lvc_s_filt. + + FIELD-SYMBOLS: <fs_filter> TYPE salv_wd_s_filter_rule_ref. + + FIELD-SYMBOLS: <fs_tab> TYPE ANY TABLE. + + ASSIGN io_table->* TO <fs_tab> . + + CREATE DATA lr_data LIKE LINE OF <fs_tab>. + + lo_structdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + + "for DDIC structure get the info directly + IF lo_structdescr->is_ddic_type( ) = abap_true. + lt_dfies = lo_structdescr->get_ddic_field_list( ). + + LOOP AT lt_dfies INTO ls_dfies. + MOVE-CORRESPONDING ls_dfies TO ls_fcat. +* ls_fcat-columnname = ls_dfies-fieldname. + ls_fcat-col_pos = ls_dfies-position. + ls_fcat-key = ls_dfies-keyflag. + get_fields_info( CHANGING xs_fcat = ls_fcat ) . + + ls_fcat-col_opt = abap_true. + + get_columns_info( CHANGING xs_fcat = ls_fcat ) . + + INSERT ls_fcat INTO TABLE wt_fcat. + ENDLOOP. + ELSE. + "if structure is not DDIC check components + lt_components = lo_structdescr->get_components( ). + LOOP AT lt_components INTO ls_component. + lv_sytabix = sy-tabix. + CLEAR ls_fcat. + lo_elemdescr ?= ls_component-type. + "component is DDIC + IF lo_elemdescr->is_ddic_type( ) = abap_true. + ls_dfies = lo_elemdescr->get_ddic_field( ). + MOVE-CORRESPONDING ls_dfies TO ls_fcat. +* ls_fcat-columnname = ls_component-name. + ELSE. + "component is not DDIC -> return minimum information required + ls_fcat-fieldname = ls_component-name. +* ls_fcat-columnname = ls_component-name. + ls_fcat-scrtext_m = ls_component-name. + ENDIF. + ls_fcat-col_opt = abap_true. + ls_fcat-col_pos = lv_sytabix. + get_fields_info( CHANGING xs_fcat = ls_fcat ) . + + INSERT ls_fcat INTO TABLE wt_fcat. + ENDLOOP. + ENDIF. + +ENDMETHOD. + + + METHOD create_wt_filt. +* No neeed for superclass. +* Only for WD + DATA: lt_otab TYPE abap_sortorder_tab, + ls_otab TYPE abap_sortorder. + DATA: lt_filters TYPE salv_wd_t_filter_rule_ref, + ls_filt TYPE lvc_s_filt. + + FIELD-SYMBOLS: <fs_fields> TYPE salv_wd_s_field_ref, + <fs_filter> TYPE salv_wd_s_filter_rule_ref. + + LOOP AT wt_fields ASSIGNING <fs_fields>. + REFRESH lt_filters. + lt_filters = <fs_fields>-r_field->if_salv_wd_filter~get_filter_rules( ) . + LOOP AT lt_filters ASSIGNING <fs_filter>. + ls_filt-fieldname = <fs_fields>-fieldname. + IF <fs_filter>-r_filter_rule->get_included( ) = abap_true. + ls_filt-sign = 'I'. + ELSE. + ls_filt-sign = 'E'. + ENDIF. + ls_filt-option = <fs_filter>-r_filter_rule->get_operator( ). + ls_filt-high = <fs_filter>-r_filter_rule->get_high_value( ) . + ls_filt-low = <fs_filter>-r_filter_rule->get_low_value( ) . + INSERT ls_filt INTO TABLE wt_filt. + ENDLOOP. + ENDLOOP. + +ENDMETHOD. + + + METHOD create_wt_sort. + DATA: lo_sort TYPE REF TO cl_salv_wd_sort_rule, + l_sort_order TYPE salv_wd_constant, + ls_sort TYPE lvc_s_sort. + + FIELD-SYMBOLS: <fs_fields> TYPE salv_wd_s_field_ref. + + LOOP AT wt_fields ASSIGNING <fs_fields>. + lo_sort = <fs_fields>-r_field->if_salv_wd_sort~get_sort_rule( ) . + IF lo_sort IS BOUND. + l_sort_order = lo_sort->get_sort_order( ). + IF l_sort_order <> if_salv_wd_c_sort=>sort_order. + CLEAR ls_sort. + ls_sort-spos = lo_sort->get_sort_position( ). + ls_sort-fieldname = <fs_fields>-fieldname. +* ls_sort-GROUP + ls_sort-subtot = lo_sort->get_group_aggregation( ). +* ls_sort-COMP +* ls_sort-EXPA +* ls_sort-SELTEXT +* ls_sort-OBLIGATORY +* ls_sort-LEVEL +* ls_sort-NO_OUT + IF l_sort_order = if_salv_wd_c_sort=>sort_order_ascending. + ls_sort-up = abap_true. + ELSE. + ls_sort-down = abap_true. + ENDIF. + INSERT ls_sort INTO TABLE wt_sort. + ENDIF. + ENDIF. + ENDLOOP. + +ENDMETHOD. + + + + METHOD get_columns_info. + DATA: l_numc2 TYPE salv_wd_constant. + + + FIELD-SYMBOLS: <fs_column> TYPE salv_wd_s_column_ref. + + READ TABLE wt_columns ASSIGNING <fs_column> WITH KEY id = xs_fcat-fieldname . + IF sy-subrc = 0. + xs_fcat-col_pos = <fs_column>-r_column->get_position( ) . + l_numc2 = <fs_column>-r_column->get_fixed_position( ). + IF l_numc2 = '02'. + xs_fcat-fix_column = abap_true . + ENDIF. + l_numc2 = <fs_column>-r_column->get_visible( ). + IF l_numc2 = '01'. + xs_fcat-no_out = abap_true . + ENDIF. + ENDIF. + +ENDMETHOD. + + + + METHOD get_fields_info. + DATA: lo_aggr TYPE REF TO cl_salv_wd_aggr_rule, + l_aggrtype TYPE salv_wd_constant. + + FIELD-SYMBOLS: <fs_fields> TYPE salv_wd_s_field_ref. + + READ TABLE wt_fields ASSIGNING <fs_fields> WITH KEY fieldname = xs_fcat-fieldname. + IF sy-subrc = 0. + lo_aggr = <fs_fields>-r_field->if_salv_wd_aggr~get_aggr_rule( ) . + IF lo_aggr IS BOUND. + l_aggrtype = lo_aggr->get_aggregation_type( ) . + CASE l_aggrtype. + WHEN if_salv_wd_c_aggregation=>aggrtype_total. + xs_fcat-do_sum = abap_true. + WHEN if_salv_wd_c_aggregation=>aggrtype_minimum. + xs_fcat-do_sum = 'A'. + WHEN if_salv_wd_c_aggregation=>aggrtype_maximum . + xs_fcat-do_sum = 'B'. + WHEN if_salv_wd_c_aggregation=>aggrtype_average . + xs_fcat-do_sum = 'C'. + WHEN OTHERS. + CLEAR xs_fcat-do_sum . + ENDCASE. + ENDIF. + ENDIF. + +ENDMETHOD. + diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_SALV_TABLE.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_SALV_TABLE.slnk index a68e430..4173e94 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_SALV_TABLE.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_SALV_TABLE.slnk @@ -1,5 +1,5 @@ - - + + class ZCL_EXCEL_CONVERTER_SALV_TABLE definition public inheriting from ZCL_EXCEL_CONVERTER_ALV @@ -33,7 +33,7 @@ private section. *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class - + @@ -81,9 +81,9 @@ ENDMETHOD. ENDIF. ENDMETHOD. - - - + + + METHOD load_data. DATA: lo_columns TYPE REF TO cl_salv_columns_table, lo_aggregations TYPE REF TO cl_salv_aggregations, @@ -158,7 +158,6 @@ ENDMETHOD. CHANGING ct_fieldcat = wt_fcat. - IF ls_vari IS NOT INITIAL AND io_salv->is_offline( ) = abap_true. CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO' EXPORTING diff --git a/ZA2X/INTF/ZIF_EXCEL_CONVERTER.slnk b/ZA2X/INTF/ZIF_EXCEL_CONVERTER.slnk index 3402b21..52d12e8 100644 --- a/ZA2X/INTF/ZIF_EXCEL_CONVERTER.slnk +++ b/ZA2X/INTF/ZIF_EXCEL_CONVERTER.slnk @@ -1,17 +1,17 @@ - - - - - + + + + + - - - - - - - - - + + + + + + + + +