mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 13:46:17 +08:00
Merge bb91e6be26
into 08c794f3ca
This commit is contained in:
commit
1ffd6f472f
|
@ -1061,12 +1061,10 @@ CLASS zcl_excel_common IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD recursive_class_to_struct.
|
METHOD recursive_class_to_struct.
|
||||||
" # issue 139
|
" # issue 139
|
||||||
* is working for me - but after looking through this coding I guess
|
|
||||||
* I'll rewrite this to a version w/o recursion
|
|
||||||
* 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,
|
||||||
|
type_kind TYPE abap_typekind,
|
||||||
flag_class TYPE abap_bool.
|
flag_class TYPE abap_bool.
|
||||||
|
|
||||||
FIELD-SYMBOLS: <field> TYPE any,
|
FIELD-SYMBOLS: <field> TYPE any,
|
||||||
|
@ -1074,6 +1072,12 @@ CLASS zcl_excel_common IMPLEMENTATION.
|
||||||
<attribute> TYPE any.
|
<attribute> TYPE any.
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIBE FIELD i_source TYPE type_kind.
|
||||||
|
flag_class = boolc( type_kind = cl_abap_typedescr=>typekind_oref ).
|
||||||
|
|
||||||
|
* Only borders will be passed as unbound references.
|
||||||
|
CHECK flag_class = abap_false OR i_source IS NOT INITIAL. " Exit if unbound reference
|
||||||
|
|
||||||
descr ?= cl_abap_structdescr=>describe_by_data( e_target ).
|
descr ?= cl_abap_structdescr=>describe_by_data( e_target ).
|
||||||
|
|
||||||
LOOP AT descr->components INTO wa_component.
|
LOOP AT descr->components INTO wa_component.
|
||||||
|
@ -1081,22 +1085,19 @@ CLASS zcl_excel_common IMPLEMENTATION.
|
||||||
* Assign structure and X-structure
|
* Assign structure and X-structure
|
||||||
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
|
|
||||||
CLEAR flag_class.
|
IF flag_class = abap_false.
|
||||||
* maybe source is just a structure - try assign component...
|
* source is a structure - use 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.
|
ELSE.
|
||||||
* not - then it is an attribute of the class - use different assign then
|
* then it is an attribute of the class - use different assign then
|
||||||
CONCATENATE 'i_source->' wa_component-name INTO attribute_name.
|
CONCATENATE 'i_source->' 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
|
|
||||||
flag_class = abap_true.
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
IF sy-subrc <> 0.EXIT.ENDIF. " Should not happen if structure is built properly - otherwise just exit to avoid dumps
|
||||||
|
|
||||||
CASE wa_component-type_kind.
|
CASE wa_component-type_kind.
|
||||||
WHEN cl_abap_structdescr=>typekind_struct1 OR cl_abap_structdescr=>typekind_struct2. " Structure --> use recursio
|
WHEN cl_abap_structdescr=>typekind_struct1 OR cl_abap_structdescr=>typekind_struct2. " Structure --> use recursion
|
||||||
zcl_excel_common=>recursive_class_to_struct( EXPORTING i_source = <attribute>
|
zcl_excel_common=>recursive_class_to_struct( EXPORTING i_source = <attribute>
|
||||||
CHANGING e_target = <field>
|
CHANGING e_target = <field>
|
||||||
e_targetx = <fieldx> ).
|
e_targetx = <fieldx> ).
|
||||||
|
@ -1112,20 +1113,32 @@ CLASS zcl_excel_common IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD recursive_struct_to_class.
|
METHOD recursive_struct_to_class.
|
||||||
" # issue 139
|
" # issue 139
|
||||||
* is working for me - but after looking through this coding I guess
|
|
||||||
* I'll rewrite this to a version w/o recursion
|
|
||||||
* 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,
|
||||||
|
type_kind TYPE abap_typekind,
|
||||||
flag_class TYPE abap_bool,
|
flag_class TYPE abap_bool,
|
||||||
o_border TYPE REF TO zcl_excel_style_border.
|
o_border TYPE REF TO zcl_excel_style_border.
|
||||||
|
* lo_refdescr TYPE REF TO cl_abap_refdescr,
|
||||||
|
* lv_clsname TYPE seoclsname.
|
||||||
|
|
||||||
FIELD-SYMBOLS: <field> TYPE any,
|
FIELD-SYMBOLS: <field> TYPE any,
|
||||||
<fieldx> TYPE any,
|
<fieldx> TYPE any,
|
||||||
<attribute> TYPE any.
|
<attribute> TYPE any.
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIBE FIELD e_target TYPE type_kind.
|
||||||
|
flag_class = boolc( type_kind = cl_abap_typedescr=>typekind_oref ).
|
||||||
|
|
||||||
|
IF flag_class = abap_true AND e_target 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.
|
||||||
|
e_target = o_border.
|
||||||
|
* lo_refdescr ?= cl_abap_typedescr=>describe_by_data( e_target ).
|
||||||
|
* lv_clsname = lo_refdescr->get_referenced_type( )->get_relative_name( ).
|
||||||
|
* CREATE OBJECT e_target TYPE (lv_clsname).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
descr ?= cl_abap_structdescr=>describe_by_data( i_source ).
|
descr ?= cl_abap_structdescr=>describe_by_data( i_source ).
|
||||||
|
|
||||||
LOOP AT descr->components INTO wa_component.
|
LOOP AT descr->components INTO wa_component.
|
||||||
|
@ -1135,31 +1148,19 @@ 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.
|
|
||||||
* maybe target is just a structure - try assign component...
|
IF flag_class = abap_false.
|
||||||
ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO <attribute>.
|
* target is a structure - use assign component
|
||||||
IF sy-subrc <> 0.
|
ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO <attribute>.
|
||||||
* not - then it is an attribute of the class - use different assign then
|
ELSE.
|
||||||
|
* then it is an attribute of the class - use different assign then
|
||||||
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
|
|
||||||
flag_class = abap_true.
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
IF sy-subrc <> 0.EXIT.ENDIF. " Should not happen if structure is built properly - otherwise just exit to avoid dumps
|
||||||
|
|
||||||
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
|
|
||||||
" 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 <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
|
|
||||||
CREATE OBJECT o_border.
|
|
||||||
<attribute> = o_border.
|
|
||||||
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>
|
||||||
CHANGING e_target = <attribute> ).
|
CHANGING e_target = <attribute> ).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user