diff --git a/src/zcl_excel_common.clas.abap b/src/zcl_excel_common.clas.abap index 9d9300a..07271ae 100644 --- a/src/zcl_excel_common.clas.abap +++ b/src/zcl_excel_common.clas.abap @@ -1042,8 +1042,7 @@ CLASS zcl_excel_common IMPLEMENTATION. * This is private an no one using it so far except me, so no need to hurry DATA: descr TYPE REF TO cl_abap_structdescr, wa_component LIKE LINE OF descr->components, - attribute_name LIKE wa_component-name, - flag_class TYPE abap_bool. + attribute_name LIKE wa_component-name. FIELD-SYMBOLS: TYPE any, TYPE any, @@ -1058,7 +1057,6 @@ CLASS zcl_excel_common IMPLEMENTATION. ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO . ASSIGN COMPONENT wa_component-name OF STRUCTURE e_targetx TO . * At least one field in the structure should be marked - otherwise continue with next field - CLEAR flag_class. * maybe source is just a structure - try assign component... ASSIGN COMPONENT wa_component-name OF STRUCTURE i_source TO . IF sy-subrc <> 0. @@ -1068,7 +1066,6 @@ CLASS zcl_excel_common IMPLEMENTATION. IF sy-subrc <> 0. EXIT. ENDIF. " Should not happen if structure is built properly - otherwise just exit to create no dumps - flag_class = abap_true. ENDIF. CASE wa_component-type_kind. @@ -1094,7 +1091,9 @@ CLASS zcl_excel_common IMPLEMENTATION. DATA: descr TYPE REF TO cl_abap_structdescr, wa_component LIKE LINE OF descr->components, attribute_name LIKE wa_component-name, - flag_class TYPE abap_bool, + check_class TYPE abap_bool, + lo_refdescr TYPE REF TO cl_abap_refdescr, + lo_classdescr TYPE REF TO cl_abap_classdescr, o_border TYPE REF TO zcl_excel_style_border. FIELD-SYMBOLS: TYPE any, @@ -1111,7 +1110,7 @@ CLASS zcl_excel_common IMPLEMENTATION. ASSIGN COMPONENT wa_component-name OF STRUCTURE i_sourcex TO . * At least one field in the structure should be marked - otherwise continue with next field CHECK CA abap_true. - CLEAR flag_class. + CLEAR check_class. * maybe target is just a structure - try assign component... ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO . IF sy-subrc <> 0. @@ -1119,22 +1118,25 @@ CLASS zcl_excel_common IMPLEMENTATION. CONCATENATE 'E_TARGET->' wa_component-name INTO attribute_name. ASSIGN (attribute_name) TO . IF sy-subrc <> 0.EXIT.ENDIF. " Should not happen if structure is built properly - otherwise just exit to create no dumps - flag_class = abap_true. + IF IS INITIAL. + check_class = abap_true. + ENDIF. ENDIF. CASE wa_component-type_kind. WHEN cl_abap_structdescr=>typekind_struct1 OR cl_abap_structdescr=>typekind_struct2. " Structure --> use recursion - " To avoid dump with attribute GRADTYPE of class ZCL_EXCEL_STYLE_FILL - " quick and really dirty fix -> check the attribute name - " Border has to be initialized somewhere else - IF wa_component-name EQ 'GRADTYPE'. - flag_class = abap_false. - ENDIF. - - IF flag_class = abap_true AND IS INITIAL. -* Only borders will be passed as unbound references. But since we want to set a value we have to create an instance - CREATE OBJECT o_border. - = o_border. + IF check_class = abap_true. + TRY. + lo_refdescr ?= cl_abap_typedescr=>describe_by_data( ). + lo_classdescr ?= lo_refdescr->get_referenced_type( ). + CASE lo_classdescr->get_relative_name( ). + WHEN 'ZCL_EXCEL_STYLE_BORDER'. +* Only borders will be passed as unbound references. But since we want to set a value we have to create an instance + CREATE OBJECT o_border. + = o_border. + ENDCASE. + CATCH cx_sy_move_cast_error. + ENDTRY. ENDIF. zcl_excel_common=>recursive_struct_to_class( EXPORTING i_source = i_sourcex =