Professional Documents
Culture Documents
public section.
type-pools ABAP .
class-methods IS_TIME_STAMP_DOMAIN
importing
!IV_DOMAIN_NAME type REFNAME
returning
value(RV_IS_TIME_STAMP) type ABAP_BOOL .
class-methods GET_INSTANCE
returning
value(RO_INSTANCE) type ref to ZCL_EHFND_EXP_UTILITIES .
methods CONVERT_TO_STRING
importing
!IV_VALUE type ANY
!IS_META_DATA type EHFNDS_EXP_FIELD_DESCRIPTOR
returning
value(RV_STRING) type STRING .
methods COULD_BE_NEGATIVE
importing
!IS_META_DATA type EHFNDS_EXP_FIELD_DESCRIPTOR
returning
value(RV_COULD_BE_NEGATIVE) type ABAP_BOOL .
methods CREATE_META_DATA
importing
!IS_NODE_DESCR type EHFNDS_EXP_NODE_DESCRIPTOR
exporting
!ET_META_DATA type EHFNDT_EXP_TAB_META_DATA .
methods CREATE_TABULAR_STRUCTURE
importing
!IS_NODE_DESCR type EHFNDS_EXP_NODE_DESCRIPTOR
!IT_HIERARCHICAL_DATA type ANY TABLE optional
exporting
!ET_TABULAR_DATA type EHFNDT_EXP_TAB_DATA .
methods CREATE_UNIQUE_DESCRIPTIONS
changing
!CT_META_DATA type EHFNDT_EXP_TAB_META_DATA .
methods IS_TIMESTAMP
importing
!IS_META_DATA type EHFNDS_EXP_FIELD_DESCRIPTOR
returning
value(RV_IS_TIMESTAMP) type ABAP_BOOL .
methods IS_TIMESTAMP_BY_ABAP_DATA_DESC
importing
!IO_DATA_DESC type ref to CL_ABAP_DATADESCR
returning
value(RV_IS_TIMESTAMP) type ABAP_BOOL .
private section.
types:
*"* private components of class ZCL_EHFND_EXP_UTILITIES
*"* do not include other source files here!!!
BEGIN OF gty_s_descr,
string TYPE string,
serial_number TYPE i,
first_index TYPE i,
END OF gty_s_descr .
types:
gty_th_descr TYPE HASHED TABLE OF gty_s_descr WITH UNIQUE KEY string .
methods CREATE_META_DATA_FOR_NODE
importing
!IS_NODE_DESCR type EHFNDS_EXP_NODE_DESCRIPTOR
changing
!CT_META_DATA type EHFNDT_EXP_TAB_META_DATA .
methods DENORMALIZE_HIERARCHY
importing
!IS_NODE_DESCR type EHFNDS_EXP_NODE_DESCRIPTOR
!IT_HIERARCHICAL_DATA type ANY TABLE optional
!IV_FLG_ON_LEADING_PATH type ABAP_BOOL
changing
!CT_ROWS type EHFNDT_EXP_TAB_DATA .
methods DENORMALIZE_SINGLE_RECORD
importing
!IS_NODE_DESCR type EHFNDS_EXP_NODE_DESCRIPTOR
!IS_DATA type ANY optional
!IV_FLG_ON_LEADING_PATH type ABAP_BOOL
changing
!CT_ROWS type EHFNDT_EXP_TAB_DATA .
ENDCLASS.
ENDMETHOD.
METHOD convert_to_string.
ENDMETHOD.
METHOD could_be_negative.
ENDMETHOD.
METHOD create_meta_data.
CLEAR et_meta_data.
CLEAR et_tabular_data.
ENDMETHOD.
METHOD create_unique_descriptions.
ENDMETHOD.
METHOD is_timestamp.
rv_is_timestamp = abap_false.
ENDMETHOD.
METHOD is_timestamp_by_abap_data_desc.
ls_ddic_header = io_data_desc->get_ddic_header( ).
" In order to identify timestamp fields we check if the field's domain
" is one of the unual timestamp domains.
rv_is_timestamp = is_time_stamp_domain( ls_ddic_header-refname ).
ENDMETHOD.
*--
* PRIVATE
METHOD CREATE_META_DATA_FOR_NODE.
" We want to get the fields of the leading path on the right-hand side of the
table.
" Thus we process the fields that are not on the leading path first and append
their
" respective meta-data to the result table. After that we process the fields on
the
" leading path and append their respective meta-data to the result. This way the
fields
" on the leading path are at the end of the result table.
" NOTE: This logic corresponds to the logic in method DENORMALIZE_SINGLE_RECORD
which
" inserts the non-leading path-fields before the leading path-fields into the de-
normalized
" table (see end of method).
" First process all fields that are not on the leading path
LOOP AT is_node_descr-field_descr_tab REFERENCE INTO lr_s_field_descr.
IF ( sy-tabix = is_node_descr-field_on_leading_path ).
" Save the field descriptor of the leading path for later
lr_s_field_descr_on_lead_path = lr_s_field_descr.
ELSE.
" Consistency check: here we can have only these kinds of fields
ASSERT lr_s_field_descr->field_kind = cl_abap_typedescr=>kind_elem OR
lr_s_field_descr->field_kind = cl_abap_typedescr=>kind_table.
" Append the meta data of elementary fields directly to the result
" In case the current field is actually an internal table
" recursively append the meta data of its fields to the result
IF ( lr_s_field_descr->field_kind = cl_abap_typedescr=>kind_elem ).
ENDLOOP.
ENDMETHOD.
METHOD denormalize_hierarchy.
IF ( lines( it_hierarchical_data ) = 0 ).
" Make sure we have at least one record even if it is initial
CREATE DATA lr_s_data LIKE LINE OF it_hierarchical_data.
ASSERT sy-subrc = 0.
" If we are currently not processing the leading path we have to process
" just the first record of the hierarchy table. Thus we exit the loop here.
IF ( iv_flg_on_leading_path = abap_false ).
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDMETHOD.
METHOD denormalize_single_record.
" Save the field name for later use (see loop below)
lv_field_name_on_leading_path = lr_s_field_descr->field_name.
ASSIGN COMPONENT lr_s_field_descr->field_name OF STRUCTURE is_data TO
<lg_t_leading_path>.
ASSERT sy-subrc = 0.
" Now process all fields that do not belong to the leading path
LOOP AT is_node_descr-field_descr_tab REFERENCE INTO lr_s_field_descr
WHERE field_name <> lv_field_name_on_leading_path.
lv_field_index = sy-tabix.
" Here we are not on the leading path. Thus for each nested table just one
record
" is being processed. So DENORMALIZE_HIERARCHY can return just one row in
ct_rows.
" In order to get this one row we read the first (and only) record from
lt_rows.
READ TABLE lt_rows REFERENCE INTO lr_t_row INDEX 1.
IF ( sy-subrc = 0 ).
APPEND LINES OF lr_t_row->* TO lt_row.
ENDIF.
" Merge the data of the leading path with the remaining fields of the current
record.
" Here we duplicate the values that do not belong to the leading path
" We want to get the fields of the leading path on the right-hand side of the
table.
" Thus we insert the fields that are not on the leading path before those on the
leading path.
" This way the fields on the leading path are at the end of the rows.
" NOTE: This logic corresponds to the logic in method CREATE_META_DATA which
processes the
" non-leading path-fields first and appends the meta-data for the leading path-
fields at the
" end.
IF ( lines( ct_rows ) = 0 ).
APPEND lt_row TO ct_rows.
ELSE.
LOOP AT ct_rows REFERENCE INTO lr_t_row.
INSERT LINES OF lt_row INTO lr_t_row->* INDEX 1.
ENDLOOP.
ENDIF.
ENDMETHOD.
ENDCLASS.