Professional Documents
Culture Documents
ABAPBadiUsageinBPC7.5|SCN
GettingStarted Newsletters
Hi,Guest
LogOn
JoinUs
Store
SearchtheCommunity
Products
Services&Support
AboutSCN
Downloads
Industries
Training&Education
Partnership
DeveloperCenter
Activity
LinesofBusiness
UniversityAlliances
Events&Webinars
Innovation
Browse
ABAPBadiUsageinBPC7.5
Communications
Actions
Version1
createdbyAmitKumarTrivedion21Aug201309:52,lastmodifiedbyAmitKumarTrivedion21Aug201310:47
Share
Tweet
Like
Appliesto:
SAPBPC7.5/SAPBW7.3x
Summary:
ThisdocumentexplainsBadiusageinBPCcontext.BADIsarealwaysfasterthanScriptLogicandcanbecomeuseful
wherewehavecomlexbusinessrequirements.
DocumentcoversIntroductionofBADIwrtBPC,creationofBADIs,usefulmethodsduringBADICreationand
Testing/DebuggingCreatedBADIs.
Author(s):AmitKumarTrivedi
Company:InfosysLimited
Createdon:21August2013
AuthorBio
AmitKumarTrivediworksasSeniorSystemsEngineerinInfosysLimited.Hehas3.7yearsofexperiencein
SAPBW/ABAP.HehasworkedonVariousSupportandimplementationProjects.
TableofContents
1)BasicIntroduction
2)CreatingCustomBadi/ScriptLogic/DMPackage
3)UsefulMethodsinWritingBadi
4)Debugging/TestingBadi.
5)ExecutionSequence
1)BasicIntroduction
a)a)BADIvsScriptLogic:MakeuseofBadiwhereinyouhavecomplexlogictoimplement.Badisarealways
fasterifitisofgooddesign.
BADIshavecapabilityofprovidingplatformtowritecomplexlogicsusingABAP.Itcanusecapabilitieslikeinternal
table,methodsavailabletoreadmasterdata/transactionaldatawhichwillbeusefultowritecomplexcodesand
achievecomplexbusinessrequirements.
ItalsohasitsowndisadvantagesthatyouwillnotbeabletoseetheBADIsfromBPCClientwhichcreatesreadability
issues.AlsoyoushouldhaveknowledgeofABAPtoimplementit.
ScriptLogicscanbeusefulwhenwehavelimitedscopeforexecution.Butthesearedifficulttoimplementwhenwe
havecomplexbusinessrequirements.Alsofromexecutionpointofviewtheydonotprovidegoodperformance
becauseofmultipleparsingforeachcallduetowhichmultipleREAD/WRITEoperationtakesplace.
Note:WeshouldavoidputtingallourlogicimplementationinWriteBackBadiasthisisexecutedeverycallofInput
Schedule.InsteadwecanmakeuseofCustomBaditohavedifferentlogicsimplementedasthereisnolimiton
NumberofCustomBadiinanapplication,whereasinasingleimplementationonlyOneWriteBackBadiiswritten.
b)b)WriteBackBadivsCustomBadi
WriteBackBadiisusedwhenwewanttowritebacktherecordswithcertainfashionlikedisaggregation,distribution
http://scn.sap.com/docs/DOC45449
1/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
etc.Forex:Therewouldbescenarioswheretheplanningisdoneathigherlevelsandthedataneedstobe
disaggregatedtothechildmembers,inthiscaseweneedtohaveWriteBackBaditodisaggregatedatatillchild
members.ItsaPreprocesslogicthatgetsexecutedfirstineverycall.ThisiswrittenunderEnhancementSpot
UJR_WRITE_BACK.
CustomBadiisusedtoexecutelogicwhichcanbelinkedwithDataManagerPackages.Wecanachievea
performanceboostbyusingCustomBadiinsteadofscriptlogics.WecanusethisinCurrencyConversions,Unitof
MeasureConversionsetc.ThisiswrittenunderEnhancementSpotUJ_CUSTOM_LOGIC.
2)CreatingCustomBadi/ScriptLogic/DMPackage
a)CreatingaCustomBadi
Note:[TheStepsshownbelowdoesntcovercreationofEnhancementSpot.Alreadyenoughdocumentsarepresent
forthesametogothrough]
Step1:GotoSE19.EntertheEnhancementSpotname(UJ_CUSTOM_LOGICforCustomBadi)andclickoncreate
Impl.asshownbelow.
Step2:Anewwindowwillopen.EntertheEnhacementImplementationNameandshorttextandpressonContinue.
Step3:EntertheBadiImplementation,ImplementingClass,BADIDefinitionandpressoncontinueasshownbelow.
http://scn.sap.com/docs/DOC45449
2/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
Step4:InnewwindowyouwillgetdetailsforthecreatedEnhancementImplementation.
Forex:BadidefinitionName,InterfaceusedforcreatingEnhancementSpot,WhetherImplementationisActive.
Step5:GotoFilterVal.AndprovidecombinationvaluewhichwillbeusedinScriptlogictocalltheCustomBadi.
ClickonCreateCombination.Belowoptionwillcomeasshownbelow.
Afterthat,clickonChangeFilterValueprovideValueforFilterandpresscontinue.
http://scn.sap.com/docs/DOC45449
3/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
Step6:WritingtheCodeforimplementation.DoubleClickonImplementingClassasshownbelow.
DoubleClickonMethodtoopentheABAPwindowtowritetheactualcode.CoupleofDialogWindowswillopenjust
pressonYesandcontinue.
Step7:Blankwindowwillgetopen.YouneedtowriteyourLogicinbetweentheStartofMethodandEndofMethod.
http://scn.sap.com/docs/DOC45449
4/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
Step8:AsimpleCustomBaditoTakeaRECORDANDCopyittoAnotherKey.
methodIF_UJ_CUSTOM_LOGIC~EXECUTE.
TYPES:BEGINOFdata,
measuresTYPEcLENGTH20,
accountTYPEcLENGTH20,
companyTYPEcLENGTH20,
geographyTYPEcLENGTH20,
productTYPEcLENGTH20,
currencyTYPEcLENGTH20,
unitTYPEcLENGTH20,
timeTYPEcLENGTH20,
versionTYPEcLENGTH20,
ENDOFdata.
DATA:wa_dataTYPEdata,
wa_final_dataTYPEdata,
it_dataTYPESTANDARDTABLEOFdata,
it_final_dataTYPESTANDARDTABLEOFdata.
IFct_data[]ISNOTINITIAL."CheckingIfct_dataisnotBlank.
it_data=ct_data."CopyingCT_DATAintoaninternalTable.
SORTit_dataBYcompany."SortingByCompany
DELETEit_dataWHEREcompany<>'ABC'."DeletingAllotherCompanyExceptABC.
SORTit_dataBYaccount."ThenSortingbasedonAccount
DELETEit_dataWHEREaccount<>'XYZ'."DeleingAllOtherAccountsExceptXYZ.
LOOPATit_dataINTOwa_data.
wa_final_data=wa_data.
wa_final_dataaccount='C0049'.
APPENDwa_final_dataTOit_final_data.
wa_final_dataaccount='C0002'.
APPENDwa_final_dataTOit_final_data.
ENDLOOP.
SORTit_final_data.
DELETEADJACENTDUPLICATESFROMit_final_data.
*Overwritebuffertablewithfinalresultset.
ct_data=it_final_data.
ENDIF.
endmethod.
Step9:FinallyActivatetheBadiandBadiisreadytobeusedinScriptlogiccall.
b)b)CreatingaScriptLogicandlinkingitwithCustomBadi
Step1:GotoBPCAdminClientandgoforCreateNewLogic.EnteraTechnicalNameandclickonOktocontinue.
http://scn.sap.com/docs/DOC45449
5/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
Step2:WritebelowcodeandclickonValidateandSave.ScriptLogiciscreated.
c)c)CreatingaDataManagerPackageandlinkingitwithScriptLogic.
Step1:GotoBPCExcelclientandthentoPlanningandConsolidationtabasshownbelow.
http://scn.sap.com/docs/DOC45449
6/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
Step2:FollowthestandardproceduretocreateaDMPackage.AlreadyenoughdocumentsareavailableinSDNfor
thesame.OneSampleDMPackagelinkingwithScriptLogicisshownbelow.
3)UsefulMethodsinWritingBadi
a)a)ReadingtheDimensionMemberData.:ReadingaGEOGRAPHYDimensionMemberdata.
DATA:lv_appset_idTYPEuj_appset_idVALUE'ABC',APPSETID
lo_geographyTYPEREFTOif_uja_dim_data,"ObjectReference
ls_hier_infoTYPEuja_s_hier,
lt_hier_nameTYPEuja_t_hier_name,
ls_attr_listTYPEuja_s_attr,
lt_attr_name_geoTYPEuja_t_attr_name,
lr_dataTYPEREFTOdata.
FIELDSYMBOLS:
<lt_geo_mbr>TYPEHASHEDTABLE,"Allentitymembers
"ObjectCreation
lo_geography=cl_uja_admin_mgr=>create_dim_ref(i_appset_id=lv_appset_id
i_dim_name='GEOGRAPHY').
ChoosingAttributesofDimensiontoberead.
http://scn.sap.com/docs/DOC45449
7/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
IfwewanttoreadonlytwoAttributesCountryandArea&HierarchyfromGEOGRAPHYDimension,then
takeoutthoseattributesandputthemintablelt_attr_name_geoandlt_hire_name.
ls_hier_infohier_name=
'PARENTH1'.
APPENDls_hier_infohier_nameTOlt_hier_name.
ls_attr_listattribute_name=
'COUNTRY'.
APPENDls_attr_listattribute_nameTOlt_attr_name_geo.
ls_attr_listattribute_name='AREA'.
APPENDls_attr_listattribute_nameTOlt_attr_name_geo.
*RetrievingtheDimensionmemberforGeography.
CALLMETHODlo_geography>read_mbr_data
EXPORTING
if_ret_hashtab=abap_true
it_attr_list=lt_attr_name_geo"columns:attributesnamelist
it_hier_list=lt_hier_name"columns:hieraciesnamelist
IMPORTING
er_data=lr_data.
ASSIGNlr_data>*TO<lt_geo_mbr>.
<lt_geo_mbr>willhavethedatareadfromtheDimensionGEOGRAPHYfromBPCandcanbeusedinBadiasper
yourrequirement.
b)b)ReadingtheDimensionNamesofanApplication.
Belowisthetechniqueofreferringtothecubedimensionsindirectlythroughapplicationnamesothatyouweare
immunetocubechangesduetofulloptimize.
DATA:lo_applTYPEREFTOcl_uja_application,
lv_appset_idTYPEuj_appset_idVALUE'ABC',
lv_application_idTYPEuj_appl_idVALUE'APPLICATION',
lt_appl_dimTYPEuja_t_appl_dim,
lt_dim_nameTYPEujq_t_dim,
ls_appl_dimLIKELINEOFlt_appl_dim,
ls_dim_nameLIKELINEOFlt_dim_name,
*RetrievingtheDimensionName
CREATEOBJECTlo_appl
EXPORTING
i_appset_id=lv_appset_id
i_application_id=lv_application_id.
REFRESHlt_appl_dim.
lo_appl>get_appl_dim(
EXPORTING
i_appl_id=lv_application_id
IMPORTING
et_appl_dim=lt_appl_dim).
REFRESHlt_dim_name.
*RetrievingtheDimensionnameOfTheSMPApplication.
LOOPATlt_appl_dimINTOls_appl_dim.
ls_dim_name=ls_appl_dimdimension.
APPENDls_dim_nameTOlt_dim_name.
CLEARls_dim_name.
ENDLOOP.
Furtherlt_dim_namecanbeusedtoreadthetransactionaldatafromcube.Pleaseseenextpointshowtoread
transactionaldatafromcube.
c)c)ReadingtheTransactionalDatafromthecube.
DATA:lv_appset_idTYPEuj_appset_idVALUE'ABC',
lv_application_id1TYPEuj_appl_idVALUE'APPLICATION',
lt_dim_nameTYPEujq_t_dim,
it_selTYPEuj0_t_sel,
http://scn.sap.com/docs/DOC45449
8/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
wa_selTYPEuj0_s_sel,
SelectiontabletofiltertheResultSetfromtheCubeRead.DataforGeography
INDIAwillbereadfromthecube.
CLEAR:it_sel.
wa_seldimension='GEOGRAPHY'.
wa_selattribute='ID'.
wa_selsign='I'.
wa_seloption='EQ'.
wa_sellow=INDIA.
wa_selhigh=''.
APPENDwa_selTOit_sel.
CLEARwa_sel.
**CallSQEtoreadtransactiondata
TRY.
CALLFUNCTION'UJQ_RUN_RSDRI_QUERY'
EXPORTING
i_appset_id=lv_appset_idAppsetId
i_appl_id=lv_application_id1Application
it_dim_name=lt_dim_nameDimensions
it_sel=it_selSelectionTable
if_check_security=abap_truetoenableSecurityCheck
IMPORTING
et_data=it_rate_data.Output
CATCHcx_ujq_exception.
ENDTRY.
OtherImportantParametersavailableinFunctionModule.
a)PackageSize:YoucandefineyourownPackageSizeandthentheoutputwillhavesamenumberof
recordsineachdatapackage.
b)SecurityCheck:DefaultvalueforthisisABAP_TRUE.IfthisvalueissetCubereadchecksforthe
security.
c)DatabaseAggregate:DefaultvalueforthisisABAP_TRUE.Ifthisvalueissettotrue,cuberead
makesuseofDatabaseAggregates.
d)d)ReadingtheChildmembersofaHierarchy.
DATA:lo_geographyTYPEREFTOif_uja_dim_data,
*Togetthechildrenifany
CALLMETHODlo_geography>get_children_mbr
EXPORTING
i_parent_mbr=ASIA"Parent
i_level=99"99=Allchildreninanylevel1=direct
child
if_only_base_mbr=abap_true"Onlybasemember
IMPORTING
et_member=lt_geography_mbr.
lt_geography_mbrwillhavealltheChildMembersforGeographyASIA.
4)Debugging/TestingBadi
DebuggingisthebestwayofunderstandingABAPcode.ThereisasmalldifferenceindebuggingprocessforData
ManagerPackagesandforInputSchedule.
1)DebuggingBadiforDataManagerPackageRun/OfflineRun:
GotoSE24,EnterClassname:CL_UJD_START_PACKAGE.
ClickonDisplay.
http://scn.sap.com/docs/DOC45449
9/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
DoubleclickonMethodRUN_PACKAGE.YouwillbetakentoABAPEditor.
GotoMethodCallRUN_PACKAGE_PandapplyExternalBreakpointatthisline.
GotoyourBadiandapplyExternalBreakpointatthelinefromwhereyouwanttostartthe
Debugging.DebuggingPointerwilldirectlycomeatthatline.
AfterthatyoucanruntheDataManagerPackagegivingyourselections.
http://scn.sap.com/docs/DOC45449
10/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
Youwillberedirectedtothebelowscreen.DoubleclickonLF_SYNCHRONOUESandchange
thevalueofittoXandpressenter.Initiallyitwillbeblank.AfterthatpressF7tonavigateintothe
BadiScreen.
OnceyouclickonF7youwillbedirectedtoyourCustomBadi,whereyoucanfollownormal
wayofdoingthedebugging.
http://scn.sap.com/docs/DOC45449
11/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
ToExecuteSingleStep:PressF5
ToExecute:PressF6
ToReturn:F7
ToContinue:PressF8.
2)DebuggingBadiforInputSchedule/OnlineRun:TheonlydifferenceinInputScheduleBadidebugging
isthatyoudontneedtoputBreakPointinclassratheryoucandirectlyputBreakpointinCustomBadi
andyouwillbetakenintocustomBadiDebuggingscreen.
5)ExecutionSequence
BelowisthesequenceofexecutionofdifferentobjectsinSAPBPC.
WB>CR>DL>WB>CR>CB1>WB>CR>CB2andsoon.
NotationUsed
WB>WriteBackBadi
CR>CubeReadbasedonscoping
DL>DefaultLogic
CB1>CustomBadi1
CB2>CustomBadi2
3997Views
Products:sap_business_planning_and_consolidation
AverageUserRating
(5ratings)
Share
Tweet
Like
10Comments
GaneshWathare21Aug201311:21
Goodone...
Like(1)
UmaArjunan13Nov201310:17
UsefulonetotriggerthedebuggerfromRunPackage.
ButIcouldnotseethemethodRUN_PACKAGE_PintheclassCL_UJD_START_PACKAGE.
CL_UJD_START_PACKAGEWhatisthealternativeclassinBPC10?
Gotanswerfromsdnthruanotherblog
http://scn.sap.com/people/daniel.settanni/blog/2011/07/13/debuggingbpc10fornetweaver
BelowpointsmightbehelpfulforthosewhowantstodebugBADIinBPC10withoutUJKT.
ClassnameisCL_UJXD_PACKAGES_RES
MethodnameisDO_POST>SetextbrkpointinRUN_PACKAGEmethod
beforeproceedingtothenextstep,setthedebugparameter
LS_PACKAGE_RUNIF_DEBUG='X'
thenthebreakpointwhichisalreadysetatthecustomBADIwillstopthere.
ThiswayBADIcanbedebuggeddirectlyfromBPCrun_packagescreen
Like(0)
AmitKumarTrivedi13Nov201307:45(inresponsetoUmaArjunan)
HIUma,
RUN_PACKAGE_PmethodisnotinsideCL_UJD_START_PACKAGE.Youhavetodouble
clickonRUN_PACKAGEMethodinthisclass,whichwillopenamethodwhichusesthis
program.
RegardingBPC10.0iwillletyouknow.AsIdon'thaveinformationaboutthat.
http://scn.sap.com/docs/DOC45449
12/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
Regards,
Amit
Like(0)
VadimKalinin13Nov201310:23
HiAmit,
Justonecorrectiontoyourgooddocument:
Whenyouexplainthepossibleusageofwritebackbadiyoumentiononly"disaggregation,
distributionetc.".Butinreality,thewritebackbadiisusedalsoasareplacementofdefault.lgfifthe
calculationsinthisscriptaresignificantlycomplex.Additionalbenefitofwritebackbadicomparedto
default.lgfisthatonlychangeddatawillbeprocessed(default.lgfreceivesascopeasacombination
ofallmembersofalldimensionsofchangedvalues).
B.R.Vadim
Like(1)
GustavoFraOtero06May201416:15(inresponsetoVadimKalinin)
HiVadimandAmit,
Whatisthedifferentbetweenusewritebackbadiordefault.lgf?
Forexample,IhaveanInputSchedule.Isenddata.IsDefault.lgfexecuted?Iswriteback
badiexecuted?
AndIfIhaveaReportdandIrefreshit.IsDefault.lgfexecuted?Iswritebackbadi
executed?
Whatisthebestpractice?
Forexample:Default.lgf
DefineScope
Whenacc.type="EXP"
start_Badicomplex_add
end_badi
Whenacc.type="INC"
startBadicomplex_rest
endbadi
endwhen
endwhen
or
Forexample:writebackbadi.Managelogicinsidebadi.
Whatisthebesperformance?
Thanks.
Regards
Gustavo
Like(0)
VadimKalinin06May201417:29(inresponsetoGustavoFraOtero)
HiGustavo,
Writebackbadiislaunchedoneverywritetocube(withatableofrecordstobe
written).Itwillbelaunchedbeforedefault.lgfandafterdefault.lgfwillwritenew
data.
Reportrefreshdonothingwithdefault.lgfandwritebackbadireportisonly
readingdata.
Vadim
Like(0)
VadimKalinin05Mar201419:18
Sorry,yourcodeisthecodefromHowtoUsetheWriteBackPreProcessBAdI:
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0309226814f2d1061a6
ef8da29e3727?QuickLink=index&
whereyoureplacethestring"entity"with"RP_TIME2"
Youwantthatwewillwritethemorecomplexbadiinsteadofyou?
Vadim
Like(0)
VadimKalinin05Mar201419:32
http://scn.sap.com/docs/DOC45449
13/14
16/12/2014
ABAPBadiUsageinBPC7.5|SCN
YouneedtofindanABAPprogrammerit'sasimplethingtodoforthepersonwithABAPknowledge.
Like(1)
VadimKalinin05Mar201419:42
Openanewquestionanddescribeyourscript.Thecommentsforthedocumentisnottheright
place...
Like(0)
AshokBabuKumili09Oct201419:39
Thankyousomuchforthisblog.Thisissoorganisedandwell
described.Thescreenshotsareveryhelpful.
Like(0)
SiteIndex
Privacy
ContactUs
TermsofUse
http://scn.sap.com/docs/DOC45449
SAPHelpPortal
LegalDisclosure
Copyright
FollowSCN
14/14