class zcl_vprov definition
public
create public .public section.
*“* public components of class ZCL_VPROV
*“* do not include other source files here!!! class-methods get_info_from_chanm
importing
!i_chanm type rsdri_s_sfc–chanm
exporting
!e_typenm type string
!e_zalias type string
exceptions
er_zalias .
class-methods get_info_from_kyfnm
importing
!i_kyfnm type rsdri_s_sfk–kyfnm
exporting
!e_typenm type string
!e_zalias type string
exceptions
er_zalias .
class-methods get_alias_from_chanm
importing
!i_chanm type rsdri_s_sfc–chanm
returning
value (r_zalias) type string
exceptions
er_zalias .
class-methods get_alias_from_kyfnm
importing
!i_kyfnm type rsdri_s_sfk–kyfnm
returning
value (e_zalias) type string
exceptions
er_zalias .
methods get_norm_struct
returning
value (e_alias_struct) type ref to cl_abap_structdescr .
methods define
importing
!i_infoprov type rsinfoprov
!i_th_sfc type rsdri_th_sfc
!i_th_sfk type rsdri_th_sfk
!i_t_range type rsdri_t_range
!i_tx_rangetab type rsdri_tx_rangetab
value (i_keydate) type rrsrdate default sy–datum
value (i_maxrows) type i
value (i_use_aggregation) type rs_bool default rs_c_true
!i_th_sfc_add type rsdri_th_sfc optional .
methods read
importing
value (i_packagesize) type i default 100000
value (i_show_statement) type rs_bool default rs_c_false
exporting
!e_t_data type standard table
!e_end_of_data type rs_bool
!e_t_msg type rs_t_msg
exceptions
error .
*“* protected components of class ZCL_VPROV
*“* do not include other source files here!!!
protected section. data infoprov type rsinfoprov .
data th_sfc type rsdri_th_sfc .
data th_sfk type rsdri_th_sfk .
data t_range type rsdri_t_range .
data keydate type rrsrdate .
data maxrows type i .
data use_aggregation type rs_bool .
data infoprov_th_sfc type rsdri_th_sfc .
data infoprov_th_sfk type rsdri_th_sfk .
data infoprov_t_range type rsdri_t_range .
data t_alias_mapping type zwht_alias_mapping .
data t_command_list type zt_command_list . methods modify_range_tables .
*“* private components of class ZCL_VPROV
*“* do not include other source files here!!!
private section. data t_data type t_cube_struct .
methods set_new_cha
changing
!itab type ref to data .
endclass.class zcl_vprov implementation. * <SIGNATURE>—————————————————————————————+
* | Instance Public Method ZCL_VPROV->DEFINE
* +————————————————————————————————-+
* | [—>] I_INFOPROV TYPE RSINFOPROV
* | [—>] I_TH_SFC TYPE RSDRI_TH_SFC
* | [—>] I_TH_SFK TYPE RSDRI_TH_SFK
* | [—>] I_T_RANGE TYPE RSDRI_T_RANGE
* | [—>] I_TX_RANGETAB TYPE RSDRI_TX_RANGETAB
* | [—>] I_KEYDATE TYPE RRSRDATE (default =SY-DATUM)
* | [—>] I_MAXROWS TYPE I
* | [—>] I_USE_AGGREGATION TYPE RS_BOOL (default =RS_C_TRUE)
* | [—>] I_TH_SFC_ADD TYPE RSDRI_TH_SFC(optional)
* +————————————————————————————–</SIGNATURE>
method define.
*——————————————————————–*
“ set Attributes
infoprov = i_infoprov .
keydate = i_keydate .
maxrows = i_maxrows .
th_sfc = i_th_sfc .
th_sfk = i_th_sfk .
t_range = i_t_range .
use_aggregation = i_use_aggregation .
*——————————————————————–*
call method zcl_virtual_command_factory=> get_list
exporting
i_t_range = i_t_range
importing
e_command_list = me->t_command_list
changing
c_th_sfc = th_sfc
c_th_sfk = th_sfk.
*——————————————————————–*
modify_range_tables( ) .
*——————————————————————–*
endmethod.
* <SIGNATURE>—————————————————————————————+
* | Static Public Method ZCL_VPROV=>GET_ALIAS_FROM_CHANM
* +————————————————————————————————-+
* | [—>] I_CHANM TYPE RSDRI_S_SFC-CHANM
* | [<-()] R_ZALIAS TYPE STRING
* | [EXC!] ER_ZALIAS
* +————————————————————————————–</SIGNATURE>
method get_alias_from_chanm.
* just a returning wrapper!
call method zcl_vprov=> get_info_from_chanm
exporting
i_chanm = i_chanm
importing
* e_typenm =
e_zalias = r_zalias
exceptions
er_zalias = 1
others = 2
.
if sy– subrc <> 0.
raise er_zalias.
endif.endmethod.
* <SIGNATURE>—————————————————————————————+
* | Static Public Method ZCL_VPROV=>GET_ALIAS_FROM_KYFNM
* +————————————————————————————————-+
* | [—>] I_KYFNM TYPE RSDRI_S_SFK-KYFNM
* | [<-()] E_ZALIAS TYPE STRING
* | [EXC!] ER_ZALIAS
* +————————————————————————————–</SIGNATURE>
method get_alias_from_kyfnm.
* * just a wraopper for returning
call method zcl_vprov=> get_info_from_kyfnm
exporting
i_kyfnm = i_kyfnm
importing
* e_typenm =
e_zalias = e_zalias
exceptions
er_zalias = 1
others = 2
.
if sy– subrc <> 0.
raise er_zalias.
endif.endmethod.* <SIGNATURE>—————————————————————————————+
* | Static Public Method ZCL_VPROV=>GET_INFO_FROM_CHANM
* +————————————————————————————————-+
* | [—>] I_CHANM TYPE RSDRI_S_SFC-CHANM
* | [<—] E_TYPENM TYPE STRING
* | [<—] E_ZALIAS TYPE STRING
* | [EXC!] ER_ZALIAS
* +————————————————————————————–</SIGNATURE>
method get_info_from_chanm.
data: l_moff type i ,
l_len type i ,
l_typenm type string,
l_zalias type string ,
l_chanm type string ,
l_nav type c length 2 .
*——————————————————————–*
“ Import
l_chanm = i_chanm .
*——————————————————————–*
“ Calculaction
find ‚__‘ in l_chanm “ navi-attribute ?
match offset l_moff .
if sy– subrc = 0 . “ take navi-attribute infoobject-name
l_moff = l_moff + 2 .
l_len = strlen( l_chanm ) – l_moff .
l_chanm = l_chanm+l_moff(l_len ) .
l_nav = ‚__‘ .
endif .
if strlen( l_chanm ) <= 17 .
concatenate ‚Y‘ l_nav l_chanm into l_zalias . „zalias
else .
raise er_zalias .
endif .
if l_chanm( 1) = ‚0‘ . “ 0CALMONTH ? type is /BI0/OICALMONTH
l_len = strlen( l_chanm ) – 1 .
concatenate ‚/BI0/OI‘ l_chanm+1( l_len) into l_typenm .
else.
concatenate ‚/BIC/OI‘ l_chanm into l_typenm .
endif .*——————————————————————–*
“ Export
e_typenm = l_typenm .
e_zalias = l_zalias .
endmethod.
* <SIGNATURE>—————————————————————————————+
* | Static Public Method ZCL_VPROV=>GET_INFO_FROM_KYFNM
* +————————————————————————————————-+
* | [—>] I_KYFNM TYPE RSDRI_S_SFK-KYFNM
* | [<—] E_TYPENM TYPE STRING
* | [<—] E_ZALIAS TYPE STRING
* | [EXC!] ER_ZALIAS
* +————————————————————————————–</SIGNATURE>
method get_info_from_kyfnm.
data: l_moff type i ,
l_len type i ,
l_typenm type string,
l_zalias type string ,
l_kyfnm type string .
*——————————————————————–*
“ Import
l_kyfnm = i_kyfnm .
*——————————————————————–*
“ Berechnung
if l_kyfnm( 1) = ‚0‘ . “ für 0* usw. type ist /BI0/OI*
l_len = strlen( l_kyfnm ) – 1 .
concatenate ‚/BI0/OI‘ l_kyfnm+1( l_len) into l_typenm .
else.
concatenate ‚/BIC/OI‘ l_kyfnm into l_typenm .
endif .
if strlen( l_kyfnm ) <= 17 .
concatenate ‚Y‘ l_kyfnm into l_zalias .
else .
raise er_zalias .
endif .
*——————————————————————–*
“ Export
e_typenm = l_typenm .
e_zalias = l_zalias .
endmethod.
* <SIGNATURE>—————————————————————————————+
* | Instance Public Method ZCL_VPROV->GET_NORM_STRUCT
* +————————————————————————————————-+
* | [<-()] E_ALIAS_STRUCT TYPE REF TO CL_ABAP_STRUCTDESCR
* +————————————————————————————–</SIGNATURE>
method get_norm_struct.
field-symbols: <sfc> type rsdri_s_sfc ,
<sfk> type rsdri_s_sfk .
data: l_typenm type string ,
l_zalias type string ,
l_comp_tab type abap_component_tab ,
wa_comp_tab type line of abap_component_tab ,
wa_sfc type rsdri_s_sfc ,
wa_sfk type rsdri_s_sfk ,
wa_alias_mapping type line of zwht_alias_mapping .
data: l_nm type string .
data: l_len type i .
data: l_moff type i .
loop at th_sfc assigning <sfc>.
get_info_from_chanm(
exporting
i_chanm = <sfc>–chanm
importing
e_typenm = l_typenm
e_zalias = l_zalias )
.
wa_comp_tab– name = l_zalias .
wa_comp_tab– type ?= cl_abap_typedescr=> describe_by_name( l_typenm ) .
append wa_comp_tab to l_comp_tab .
clear wa_sfc .
wa_sfc– chaalias = l_zalias .
modify infoprov_th_sfc from wa_sfc transporting chaalias
where chanm = <sfc> –chanm .
if sy– subrc <> 0. “ weiter
endif .
if <sfc>– chaalias is not initial .
clear wa_alias_mapping .
wa_alias_mapping– name = <sfc> –chanm .
wa_alias_mapping– alias = <sfc> –chaalias .
wa_alias_mapping– zalias = l_zalias .
append wa_alias_mapping to t_alias_mapping .
endif .
endloop .
loop at th_sfk assigning <sfk>.
get_info_from_kyfnm(
exporting
i_kyfnm = <sfk>–kyfnm
importing
e_typenm = l_typenm
e_zalias = l_zalias )
.
wa_comp_tab– name = l_zalias .
wa_comp_tab– type ?= cl_abap_typedescr=> describe_by_name( l_typenm ) .
append wa_comp_tab to l_comp_tab .
clear wa_sfk .
wa_sfk– kyfalias = l_zalias .
modify infoprov_th_sfk from wa_sfk transporting kyfalias
where kyfnm = <sfk> –kyfnm .
if sy– subrc <> 0. “ weiter
endif .
if <sfk>– kyfalias is not initial .
clear wa_alias_mapping .
wa_alias_mapping– name = <sfk> –kyfnm .
wa_alias_mapping– alias = <sfk> –kyfalias .
wa_alias_mapping– zalias = l_zalias .
append wa_alias_mapping to t_alias_mapping .
endif .
endloop . e_alias_struct
= cl_abap_structdescr=>create ( p_components = l_comp_tab ) .endmethod.
* <SIGNATURE>—————————————————————————————+
* | Instance Protected Method ZCL_VPROV->MODIFY_RANGE_TABLES
* +————————————————————————————————-+
* +————————————————————————————–</SIGNATURE>
method modify_range_tables.
data: wa_sfc type rsdri_s_sfc ,
wa_sfk type rsdri_s_sfk ,
l_infoprov_struct_name type string ,
ddic type dd_x031l_table, „Datadictonary for later use
wa_ddic type line of dd_x031l_table ,
descr_ref type ref to cl_abap_structdescr .
field-symbols:
<sfc_zeile> type rsdri_s_sfc,
<sfk_zeile> type rsdri_s_sfk,
<range_zeile> type rsdri_s_range .
concatenate ‚/BIC/V‘ infoprov ‚J‘ into l_infoprov_struct_name .
descr_ref ?= cl_abap_structdescr=> describe_by_name( l_infoprov_struct_name ).
„Struktur-Objekt der zu lesenden Objekte lesen
ddic = descr_ref-> get_ddic_object( ) . “ DDic Beschreibung auslesen
*——————————————————————–*
“ Merkmale, die nicht in INFOPROV sind, aus INFOPROV_th_sfc löschen
infoprov_th_sfc = th_sfc .
loop at infoprov_th_sfc assigning <sfc_zeile> .
read table ddic with key fieldname = <sfc_zeile>– chanm
into wa_ddic transporting fieldname .
if sy– subrc <> 0 .
find ‚__‘ in <sfc_zeile> –chanm .
if sy–subrc <> 0 .
delete infoprov_th_sfc where chanm = <sfc_zeile>– chanm .
endif .
endif .
endloop .
*——————————————————————–*
“ Kennzahlen, die nicht in INFOPROV sind, aus INFOPROV_th_sfk löschen
infoprov_th_sfk = th_sfk .
delete infoprov_th_sfk where kyfnm = ‚1ROWCOUNT‘.
delete th_sfk where kyfnm = ‚1ROWCOUNT‘.
loop at infoprov_th_sfk assigning <sfk_zeile> .
read table ddic with key fieldname = <sfk_zeile>– kyfnm
into wa_ddic transporting fieldname .
if sy– subrc <> 0 .
find ‚__‘ in <sfk_zeile> –kyfnm .
if sy–subrc <> 0 .
delete infoprov_th_sfk where kyfnm = <sfk_zeile>– kyfnm .
endif .
endif .
endloop .*——————————————————————–*
“
infoprov_t_range = t_range .
loop at infoprov_t_range assigning <range_zeile> .
read table ddic with key fieldname = <range_zeile>– chanm
into wa_ddic transporting fieldname .
if sy– subrc <> 0 .
find ‚__‘ in <range_zeile> –chanm .
if sy–subrc <> 0 .
delete infoprov_t_range where chanm = <range_zeile>– chanm .
endif .
endif .
endloop .endmethod.
* <SIGNATURE>—————————————————————————————+
* | Instance Public Method ZCL_VPROV->READ
* +————————————————————————————————-+
* | [—>] I_PACKAGESIZE TYPE I (default =100000)
* | [—>] I_SHOW_STATEMENT TYPE RS_BOOL (default =RS_C_FALSE)
* | [<—] E_T_DATA TYPE STANDARD TABLE
* | [<—] E_END_OF_DATA TYPE RS_BOOL
* | [<—] E_T_MSG TYPE RS_T_MSG
* | [EXC!] ERROR
* +————————————————————————————–</SIGNATURE>
method read.
type-pools: rsdrc, abap .
data: c_first_call type rs_bool ,
r_new_tabd type ref to cl_abap_tabledescr,
r_itab type ref to data ,
r_f_itab type ref to data ,
r_new_str type ref to cl_abap_structdescr .
field-symbols: <itab> type standard table ,
<f_itab> type standard table . r_new_str
= get_norm_struct( ) .
r_new_tabd = cl_abap_tabledescr=> create( p_line_type = r_new_str ) .
create data r_itab type handle r_new_tabd .
assign r_itab-> * to <itab> .
create data r_f_itab type handle r_new_tabd .
assign r_f_itab-> * to <f_itab> .
while e_end_of_data = “ .
call function ‚RSDRI_INFOPROV_READ‘
exporting
i_infoprov = infoprov
i_th_sfc = infoprov_th_sfc
i_th_sfk = infoprov_th_sfk
i_reference_date = keydate
i_t_range = infoprov_t_range
i_packagesize = i_packagesize
importing
e_t_data = <itab>
e_end_of_data = e_end_of_data
changing
c_first_call = c_first_call.
if sy– subrc ne 0.
e_end_of_data = ‚X‘.
raise error.
else .
insert lines of <itab> into table <f_itab> .
endif.
endwhile .
*——————————————————————–*
set_new_cha( changing itab = r_f_itab ) .
*——————————————————————–*
field-symbols: <f_itab_zeile> type any ,
<sfc_zeile> type rsdri_s_sfc ,
<c_t_data> like e_t_data,
<sfk_zeile> type rsdri_s_sfk ,
<alias_mapping_zeile> type line of zwht_alias_mapping ,
<new_line> type any ,
<q> type any , „quelle
<z> type any . „ziel
data: new_line type ref to data ,
c_t_data type ref to data,
wa_sfc type rsdri_s_sfc,
wa_sfk type rsdri_s_sfk
.
create data c_t_data like e_t_data.
assign c_t_data-> * to <c_t_data>.
loop at <f_itab> assigning <f_itab_zeile> .
create data new_line like line of e_t_data .
assign new_line->* to <new_line> .
append <new_line> to <c_t_data> assigning <new_line> .
loop at t_alias_mapping assigning <alias_mapping_zeile> .
assign component <alias_mapping_zeile>–alias of structure <new_line> to <z> .
assign component <alias_mapping_zeile>–zalias of structure <f_itab_zeile> to <q> .
<z> = <q> .
endloop .
endloop .
e_t_data[] = <c_t_data>[].
endmethod.
* <SIGNATURE>—————————————————————————————+
* | Instance Private Method ZCL_VPROV->SET_NEW_CHA
* +————————————————————————————————-+
* | [<–>] ITAB TYPE REF TO DATA
* +————————————————————————————–</SIGNATURE>
method set_new_cha.
“ generierte Kommandos für virtuelle Merkmale und Kennzahlen durchlaufen
data: c_command type ref to zci_virtual_object_command.
loop at me-> t_command_list into c_command.
call method c_command->execute
changing
c_t_data = itab .
endloop.endmethod.
endclass.