- It hasn’t any value-help for cubes – I spent times to find an error, blamed to find out I entered the wrong technical name-
- It doesn’t allow to copy all aggregates from source to the target cube
- Texts of the copied aggregate are different from the original
- It terminates very hard and not user friendly if target infocube doesn’t exist
The coding for the new report is now:
*&ReportZAGGR_COPY*&
*&---------------------------------------------------------------------*
*&copiesaggregatesfromonecubetoanother
*&worksforreal-timecubestoo
*&
*&---------------------------------------------------------------------*
REPORTZAGGR_COPY.
TYPE-POOLS:rs,rsddk,rshi,rrsm,rrsi.
DATA:
l_r_aggr_collectionTYPEREFTOcl_rsddk_aggregate_collection,
l_t_aggrdirliketableofrsddaggrdir,
l_s_aggrdirlikersddaggrdir,
l_aggruidTYPErsddaggruid,
l_infocube_oldTYPErsd_infocube,
l_cubetypeTYPErscubetype,
l_no_authorityTYPErs_bool,
l_expert_modeTYPErs_bool,
l_txtshTYPErstxtsh,
l_txtlgTYPErstxtlg,
l_t_aggrtTYPErsddk_t_aggrt_db,
l_s_aggrtTYPErsddaggrt,
l_s_aggrcompTYPErsddk_s_aggrcomp_db,
l_t_aggrcompTYPErsddk_t_aggrcomp_db,
l_t_aggrcomp_delTYPErsddk_t_aggrcomp_db,
l_t_aggrcomp_alltypersddk_t_aggrcomp_db,
l_t_cob_proTYPErsd_t_cob_pro.
FIELD-SYMBOLS:
<l_s_aggrcomp>TYPErsddk_s_aggrcomp_db.
*select-options:
*aggregatetobecopied
SELECTION-SCREEN:BEGINOF BLOCKb1
WITHFRAMETITLE text-101.
PARAMETERS:
i_scubeTYPErsdcube-infocube,
i_aggrTYPErsd_infocube,
i_auidTYPErsddaggruid.
SELECTION-SCREEN:ENDOF BLOCKb1,
*infocubetowhichaggregateshouldbecopied
SKIP1,
BEGINOFBLOCKb2
WITHFRAMETITLE text-102.
PARAMETERS:
i_cubeTYPErsdcube-infocube.
SELECTION-SCREEN:ENDOF BLOCKb2.
ATSELECTIOn-SCREENON VALUE-REQUESTFORi_cube.
PERFORMf_valuerequest_icube.
ATSELECTIOn-SCREENON VALUE-REQUESTFORi_scube.
PERFORMf_valuerequest_scube.
ATSELECTIOn-SCREENON VALUE-REQUESTFORi_aggr.
PERFORMf_valuerequest_aggr.
END-OF-SELECTION.
*checkiftargetinfocubeexists!
SELECTSINGLEcubetypeFROMrsdcube
INTOl_cubetype
WHEREinfocube=i_cube
ANDobjvers=rs_c_objvers-active.
IFsy-subrc<>0OR
l_cubetypeNE'B'.
*novalidinfocubeselection.
WRITE:/text-128 COLORCOL_NEGATIVE.
EXIT.
ENDIF.
*checkifsourceinfocubeexists!
SELECTSINGLEcubetypeFROMrsdcube
INTOl_cubetype
WHEREinfocube=i_scube
ANDobjvers=rs_c_objvers-active.
IFsy-subrc<>0OR
l_cubetypeNE'B'.
*novalidinfocubeselection.
WRITE:/text-120 COLORCOL_NEGATIVE.
EXIT.
ENDIF.
*authoritycheckfromRSDDV************************
CALLFUNCTION'RSSB_AUTHORITY_ADMWB_INFOCUBE'
EXPORTING
i_actvt='U'
i_infocube=i_cube
i_icubeobj=rssb_c_auth_icubeobj-aggregate
i_try_display=rs_c_true
IMPORTING
e_display_only=l_no_authority.
IFl_no_authority=rs_c_true.
WRITE:/text-124 COLORCOL_NEGATIVE.
EXIT.
ENDIF.
*checkforlockandsetlockforINFOPROV
CALLMETHODcl_rsd_dta=>enqueue
EXPORTING
i_infoprov=i_cube
i_scope='1'
EXCEPTIONS
foreign_lock=1
sys_failure=2
OTHERS=4.
IFsy-subrc<>0.
WRITE:/text-125 COLORCOL_NEGATIVE,sy-msgv2COLORCOL_NEGATIVE.
EXIT.
ENDIF.
*cob_proforinfocube
CALLFUNCTION'RSD_COB_PRO_ALL_GET'
EXPORTING
i_infocube=i_cube
i_with_atr_nav=rs_c_true
i_objvers=rs_c_objvers-active
i_bypass_buffer=rs_c_false
IMPORTING
e_t_cob_pro=l_t_cob_pro
EXCEPTIONS
infocube_not_found=1
error_reading_infocatalog=2
illegal_input=3
OTHERS=4.
IFsy-subrc<>0.
WRITE:/text-122 COLORCOL_NEGATIVE.
EXIT.
ENDIF.
*getaggregatedefinition
IFNOT(i_aGGRIS INITIAL).
refreshl_t_aggrdir.
SELECT*
FROMrsddaggrdir
INTOtablel_T_aggrdir
*SELECTSINGLEaggruidinfocubeexpertmode
*FROMrsddaggrdir
*INTO(l_aggruid,l_infocube_old,l_expert_mode)
WHEREaggrcube=i_aggr
ANDobjvers=rs_c_objvers-modified.
IFsy-subrc<>0.
*aggregatenotfound
WRITE:/text-121 COLORCOL_NEGATIVE.
EXIT.
ENDIF.
ELSEIFnot(i_SCUBEis initial).
SELECT*
FROMrsddaggrdir
INTOtablel_T_aggrdir
WHEREinfocube=i_scube
ANDobjvers=rs_c_objvers-modified.
ELSE.
l_aggruid=i_auid.
l_s_aggrdir-aggruid=i_auid.
appendl_s_aggrdirtol_t_aggrdir.
ENDIF.
Loopatl_t_aggrdirintol_s_aggrdir.
refreshl_t_aggrt.
l_aggruid=l_S_aggrdir-aggruid.
l_infocube_old=l_s_aggrdir-infocube.
l_expert_mode=l_s_aggrdir-expertmode.
SELECT*FROMrsddaggrcomp
INTOTABLEl_t_aggrcomp
WHEREaggruid=l_aggruid
ANDobjvers=rs_c_objvers-modified.
IFsy-subrc<>0.
*aggregatenotfound
WRITE:/text-121 COLORCOL_NEGATIVE.
EXIT.
ENDIF.
*compareaggregatedefinitionandcob_proofinfocube
LOOPATl_t_aggrcompINTOl_s_aggrcomp.
READTABLEl_t_cob_pro
TRANSPORTINGNOFIELDS
WITHKEYiobjnm=l_s_aggrcomp-iobjnm.
IFsy-subrc<>0.
DELETETABLEl_t_aggrcompFROMl_s_aggrcomp.
APPENDl_s_aggrcompTOl_t_aggrcomp_del.
ENDIF.
ENDLOOP.
IFl_t_aggrcompISINITIAL.
WRITE:/text-123 COLORCOL_NEGATIVE.
EXIT.
ENDIF.
*createnewtexts
SELECTSINGLE*FROMrsddaggrt
INTOl_s_aggrt
WHEREaggruid=l_aggruid
ANDobjvers=rs_c_objvers-modified
ANDlangu=sy-langu.
*getnewUID
CALLFUNCTION'RSS_SYSTEM_GET_UNIQUE_ID'
IMPORTING
e_uni_idc25=l_aggruid.
*andcreatenewaggregatedefinition
LOOPATl_t_aggrcompASSIGNING<l_s_aggrcomp>.
<l_s_aggrcomp>-aggruid=l_aggruid.
ENDLOOP.
l_s_aggrt-aggruid=l_aggruid.
APPENDl_s_aggrtTOl_t_aggrt.
*instantiateclass
CREATEOBJECTl_r_aggr_collection
EXPORTING
i_infoprov=i_cube
i_view_only=rs_c_false.
*setexpertmode
CALLMETHODl_r_aggr_collection->set_expert_mode
EXPORTING
i_expert_mode=l_expert_mode.
*createaggregate
CALLMETHODl_r_aggr_collection->aggregate_create
EXPORTING
i_t_aggrcomp=l_t_aggrcomp
i_t_aggrt=l_t_aggrt
i_aggruid=l_aggruid
i_expert_mode=l_expert_mode.
*savedefinition
CALLMETHODl_r_aggr_collection->save.
*OUTPUT
WRITE:/,text-110 COLORCOL_HEADING.
WRITE:/,text-117 COLORCOL_POSITIVE,l_s_aggrt-txtlg.
WRITE:/,text-111 COLORCOL_POSITIVE,l_aggruid.
WRITE:/.
*infoobjectsthatarecopied
WRITE:/,text-126 COLORCOL_POSITIVE.
WRITE:/,text-112, text-113,text-114, text-115,text-116.
LOOPATl_t_aggrcompINTOl_s_aggrcomp.
WRITE:/,l_s_aggrcomp-iobjnm,l_s_aggrcomp-aggrst,
l_s_aggrcomp-fixsid,l_s_aggrcomp-hiesid,
l_s_aggrcomp-tlevel.
ENDLOOP.
WRITE:/.
WRITE:/.
*infoobjectsthatareincludedbythechecks
WRITE:/,text-127 COLORCOL_POSITIVE.
WRITE:/,text-112, text-113,text-114, text-115,text-116.
SELECT*FROMrsddaggrcomp
INTOtablel_t_aggrcomp_all
WHEREaggruid=l_aggruid
ANDobjvers=rs_c_objvers-modified.
LOOPATl_t_aggrcomp_allINTOl_s_aggrcomp.
READTABLEl_t_aggrcomp
WITHKEYiobjnm=l_s_aggrcomp-iobjnm
TRANSPORTINGNOFIELDS.
IFsy-subrc<>0.
*infoobjectwasnotinoriginal,butincludedbycube-spec.checks
WRITE:/,l_s_aggrcomp-iobjnm,l_s_aggrcomp-aggrst,
l_s_aggrcomp-fixsid,l_s_aggrcomp-hiesid,
l_s_aggrcomp-tlevel.
ENDIF.
ENDLOOP.
WRITE:/.
WRITE:/.
*infoobjectsthatarenotcopied
WRITE:/,text-118 COLORCOL_POSITIVE.
WRITE:/,text-112, text-113,text-114, text-115,text-116.
LOOPATl_t_aggrcomp_delINTOl_s_aggrcomp.
WRITE:/,l_s_aggrcomp-iobjnm,l_s_aggrcomp-aggrst,
l_s_aggrcomp-fixsid,l_s_aggrcomp-hiesid,
l_s_aggrcomp-tlevel.
ENDLOOP.
endloop. "overallaggregatesofacube
*releaselockforINFOPROV
CALLMETHODcl_rsd_dta=>dequeue
EXPORTING
i_infoprov=i_cube
i_scope='1'.
*&---------------------------------------------------------------------
*&Formf_valuerequest_icube
*&---------------------------------------------------------------------
FORMf_valuerequest_icube.
DATA:BEGINOFt_data OCCURS1,
data(20),
ENDOFt_data.
DATA:lwa_dfiesTYPEdfies.
datah_field_waLIKedfies.
datah_field_tablikedfiesoccurs 0withheaderline.
datah_dselclikedselcoccurs 0withheaderline.
data:ret_tabliketable ofddshretval.
data:l_rsdcubelikersdcube.
refresh:t_data.
SELECTinfocubeFROMrsdcubeintol_rsdcube whereobjvers='A'.
t_data=l_rsdcube-infocube.APPENDt_data.
ENDSELECT.
PERFORMf_fieldinfo_getUSING'RSDCUBE'
'INFOCUBE'
CHANGINGh_field_wa.
APPENDh_field_waTOh_field_tab.
h_dselc-fldname='INFOCUBE'.
h_dselc-dyfldname='I_CUBE'.
APPENDh_dselc.
DATA:ld_repidLIKEsy-repid.
ld_repid=sy-repid.
CALLFUNCTION'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield='I_CUBE'
dynpprog=ld_repid
dynpnr='1000'
dynprofield='I_CUBE'
*multiple_choice=''
*value_org='S'
TABLES
value_tab=t_data
field_tab=h_field_tab
*return_tab=ret_tab
DYNPFLD_MAPPING=h_dselc
EXCEPTIONS
OTHERS=0.
ENDFORM. "f_valuerequest_vbeln
FORMf_valuerequest_scube.
DATA:BEGINOFt_data OCCURS1,
data(20),
ENDOFt_data.
DATA:lwa_dfiesTYPEdfies.
datah_field_waLIKedfies.
datah_field_tablikedfiesoccurs 0withheaderline.
datah_dselclikedselcoccurs 0withheaderline.
data:l_rsdcubelikersdcube.
SELECT*FROMrsdcubeintol_rsdcube whereobjvers='A'.
t_data=l_rsdcube-infocube.APPENDt_data.
ENDSELECT.
PERFORMf_fieldinfo_getUSING'RSDCUBE'
'INFOCUBE'
CHANGINGh_field_wa.
APPENDh_field_waTOh_field_tab.
h_dselc-fldname='INFOCUBE'.
h_dselc-dyfldname='I_SCUBE'.
APPENDh_dselc.
DATA:ld_repidLIKEsy-repid.
ld_repid=sy-repid.
CALLFUNCTION'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield='I_SCUBE'
dynpprog=ld_repid
dynpnr='1000'
dynprofield='I_SCUBE'
*multiple_choice=''
*value_org='S'
TABLES
value_tab=t_data
field_tab=h_field_tab
*return_tab=return_tab
DYNPFLD_MAPPING=h_dselc
EXCEPTIONS
OTHERS=0.
ENDFORM.
FORMf_valuerequest_aggr.
DATA:BEGINOFt_data OCCURS1,
data(20),
ENDOFt_data.
DATA:lwa_dfiesTYPEdfies.
datah_field_waLIKedfies.
datah_field_tablikedfiesoccurs 0withheaderline.
datah_dselclikedselcoccurs 0withheaderline.
data:l_rsdaggrlikersddaggrdir-aggrcube.
SELECTaggrcubeFROMrsddaggrdirintol_rsdaggr whereobjvers='A'.
t_data=l_rsdaggr.APPENDt_data.
ENDSELECT.
PERFORMf_fieldinfo_getUSING'RSDDAGGRDIR'
'AGGRCUBE'
CHANGINGh_field_wa.
APPENDh_field_waTOh_field_tab.
h_dselc-fldname='AGGRCUBE'.
h_dselc-dyfldname='I_AGGR'.
APPENDh_dselc.
DATA:ld_repidLIKEsy-repid.
ld_repid=sy-repid.
CALLFUNCTION'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield='I_AGGR'
dynpprog=ld_repid
dynpnr='1000'
dynprofield='I_AGGR'
*multiple_choice=''
*value_org='S'
TABLES
value_tab=t_data
field_tab=h_field_tab
*return_tab=return_tab
DYNPFLD_MAPPING=h_dselc
EXCEPTIONS
OTHERS=0.
ENDFORM.
*&---------------------------------------------------------------------
*&Formf_fieldinfo_get
*&---------------------------------------------------------------------
*text
*----------------------------------------------------------------------
*-->P_0079text
*-->P_0080text
*<--P_H_FIELD_WAtext
*----------------------------------------------------------------------
FORMf_fieldinfo_getUSINGfu_tabname
fu_fieldname
CHANGINGfwa_field_tab.
CALLFUNCTION'DDIF_FIELDINFO_GET'
EXPORTING
TABNAME=fu_tabname
FIELDNAME=fu_fieldname
LFIELDNAME=fu_fieldname
IMPORTING
DFIES_WA=fwa_field_tab
EXCEPTIONS
NOT_FOUND=1
INTERNAL_ERROR=2
OTHERS=3
.
IFSY-SUBRC<>0.
MESSAGEIDSY-MSGIDTYPESY-MSGTYNUMBERSY-MSGNO
WITHSY-MSGV1SY-MSGV2SY-MSGV3SY-MSGV4.
ENDIF.
ENDFORM."f_fieldinfo_get
To work properly you need this textelements:
101 Which Aggregate Definition Is To Be Copied?
102 For Which InfoCube Is This Aggregate To Be Created?103 (Copy)
104 Copy of Cube
110 New Aggregate Successfully Created
111 UID of New Aggregate:
112 InfoObject
113 Aggregation Level
114 Fixed Value
115 Hierarchy SID
116 Hierarchy Level
117 Name of New Aggregate:
118 Unused InfoObjects
120 SourceInfoCube Is Not A BasicCube. An Aggregate Cannot Be Created
121 The Specified Aggregate Does Not Exist
122 COB_PRO Does Not Exist For This InfoCube
123 New Aggregate Definition Would Be Empty. Aggregate Not Created
124 No Authorization To Create Aggregates
125 Aggregate Cannot Be Created As Transaction Is Locked By:
126 Transferred InfoObjects in Aggregate
127 InfoCube-Specific InfoObjects in Aggregate
128 TargetInfoCube Is Not A BasicCube. An Aggregate Cannot Be Created
source link: https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/8352
本文介绍了一个增强版的SAP Business Warehouse工具,用于从一个信息立方体到另一个信息立方体复制聚合定义。该工具改进了原始报告RSDDK_AGGRCOMP_COPY的功能,包括提供源和目标信息立方体的选择帮助,实现所有聚合的一键复制,并改进了错误处理。
1474

被折叠的 条评论
为什么被折叠?



