mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 16:36:12 +08:00
Update zcl_excel_common.clas.abap
This commit is contained in:
parent
1956ec3591
commit
fba955bc5c
|
@ -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
|
* 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,
|
DATA: descr TYPE REF TO cl_abap_structdescr,
|
||||||
wa_component LIKE LINE OF descr->components,
|
wa_component LIKE LINE OF descr->components,
|
||||||
attribute_name LIKE wa_component-name,
|
attribute_name LIKE wa_component-name.
|
||||||
flag_class TYPE abap_bool.
|
|
||||||
|
|
||||||
FIELD-SYMBOLS: <field> TYPE any,
|
FIELD-SYMBOLS: <field> TYPE any,
|
||||||
<fieldx> TYPE any,
|
<fieldx> TYPE any,
|
||||||
|
@ -1058,7 +1057,6 @@ CLASS zcl_excel_common IMPLEMENTATION.
|
||||||
ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO <field>.
|
ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO <field>.
|
||||||
ASSIGN COMPONENT wa_component-name OF STRUCTURE e_targetx TO <fieldx>.
|
ASSIGN COMPONENT wa_component-name OF STRUCTURE e_targetx TO <fieldx>.
|
||||||
* At least one field in the structure should be marked - otherwise continue with next field
|
* 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...
|
* maybe source is just a structure - try assign component...
|
||||||
ASSIGN COMPONENT wa_component-name OF STRUCTURE i_source TO <attribute>.
|
ASSIGN COMPONENT wa_component-name OF STRUCTURE i_source TO <attribute>.
|
||||||
IF sy-subrc <> 0.
|
IF sy-subrc <> 0.
|
||||||
|
@ -1068,7 +1066,6 @@ CLASS zcl_excel_common IMPLEMENTATION.
|
||||||
IF sy-subrc <> 0.
|
IF sy-subrc <> 0.
|
||||||
EXIT.
|
EXIT.
|
||||||
ENDIF. " Should not happen if structure is built properly - otherwise just exit to create no dumps
|
ENDIF. " Should not happen if structure is built properly - otherwise just exit to create no dumps
|
||||||
flag_class = abap_true.
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
CASE wa_component-type_kind.
|
CASE wa_component-type_kind.
|
||||||
|
@ -1094,7 +1091,9 @@ CLASS zcl_excel_common IMPLEMENTATION.
|
||||||
DATA: descr TYPE REF TO cl_abap_structdescr,
|
DATA: descr TYPE REF TO cl_abap_structdescr,
|
||||||
wa_component LIKE LINE OF descr->components,
|
wa_component LIKE LINE OF descr->components,
|
||||||
attribute_name LIKE wa_component-name,
|
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.
|
o_border TYPE REF TO zcl_excel_style_border.
|
||||||
|
|
||||||
FIELD-SYMBOLS: <field> TYPE any,
|
FIELD-SYMBOLS: <field> TYPE any,
|
||||||
|
@ -1111,7 +1110,7 @@ CLASS zcl_excel_common IMPLEMENTATION.
|
||||||
ASSIGN COMPONENT wa_component-name OF STRUCTURE i_sourcex TO <fieldx>.
|
ASSIGN COMPONENT wa_component-name OF STRUCTURE i_sourcex TO <fieldx>.
|
||||||
* At least one field in the structure should be marked - otherwise continue with next field
|
* At least one field in the structure should be marked - otherwise continue with next field
|
||||||
CHECK <fieldx> CA abap_true.
|
CHECK <fieldx> CA abap_true.
|
||||||
CLEAR flag_class.
|
CLEAR check_class.
|
||||||
* maybe target is just a structure - try assign component...
|
* maybe target is just a structure - try assign component...
|
||||||
ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO <attribute>.
|
ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO <attribute>.
|
||||||
IF sy-subrc <> 0.
|
IF sy-subrc <> 0.
|
||||||
|
@ -1119,22 +1118,25 @@ CLASS zcl_excel_common IMPLEMENTATION.
|
||||||
CONCATENATE 'E_TARGET->' wa_component-name INTO attribute_name.
|
CONCATENATE 'E_TARGET->' wa_component-name INTO attribute_name.
|
||||||
ASSIGN (attribute_name) TO <attribute>.
|
ASSIGN (attribute_name) TO <attribute>.
|
||||||
IF sy-subrc <> 0.EXIT.ENDIF. " Should not happen if structure is built properly - otherwise just exit to create no dumps
|
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 <attribute> IS INITIAL.
|
||||||
|
check_class = abap_true.
|
||||||
|
ENDIF.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
CASE wa_component-type_kind.
|
CASE wa_component-type_kind.
|
||||||
WHEN cl_abap_structdescr=>typekind_struct1 OR cl_abap_structdescr=>typekind_struct2. " Structure --> use recursion
|
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
|
IF check_class = abap_true.
|
||||||
" quick and really dirty fix -> check the attribute name
|
TRY.
|
||||||
" Border has to be initialized somewhere else
|
lo_refdescr ?= cl_abap_typedescr=>describe_by_data( <attribute> ).
|
||||||
IF wa_component-name EQ 'GRADTYPE'.
|
lo_classdescr ?= lo_refdescr->get_referenced_type( ).
|
||||||
flag_class = abap_false.
|
CASE lo_classdescr->get_relative_name( ).
|
||||||
ENDIF.
|
WHEN 'ZCL_EXCEL_STYLE_BORDER'.
|
||||||
|
|
||||||
IF flag_class = abap_true AND <attribute> IS INITIAL.
|
|
||||||
* Only borders will be passed as unbound references. But since we want to set a value we have to create an instance
|
* 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.
|
CREATE OBJECT o_border.
|
||||||
<attribute> = o_border.
|
<attribute> = o_border.
|
||||||
|
ENDCASE.
|
||||||
|
CATCH cx_sy_move_cast_error.
|
||||||
|
ENDTRY.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
zcl_excel_common=>recursive_struct_to_class( EXPORTING i_source = <field>
|
zcl_excel_common=>recursive_struct_to_class( EXPORTING i_source = <field>
|
||||||
i_sourcex = <fieldx>
|
i_sourcex = <fieldx>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user