Professional Documents
Culture Documents
english|nederlands|franais
insights HowtoloadandgenerateacustomhierarchyinSAP
webcasts BusinessWarehouse(SAPBW)withoutusingflatfiles
books
byDirkFrancis
casestudies Introduction Thursday,February03,2011
BI-kipedia Oftenreportsneedtoshowdatainatree-likestructure.Thisisenabledviacharacteristichierarchies
inSAPBW.Highleveldataisdisplayedusingthetopnodesofthehierarchy.Moredetaileddatacan
RELATED
historyofperformance bevisualizedbydrillingdowntothelowernodesofthehierarchy. COMPETENCES
management
ConsideranexamplehierarchyCustomerContactsHierarchy'thatisusedtoqualifythetelephone SAPBWPerformanceTuning
usefullinks
callsatelecommunicationscallcenterreceives.
SAPBusinessWarehouse
SAPBusinessObjects4
Image 1: Customer Contacts Hierarchy SAPBOUpgrading&Migration
SAPBOPerformanceTuning
SAPBOImplementation&Know ledge
Transfer
SAPBusinessObjectsArchitecture
SAPBusinessObjectsXiBusiness
Intelligence
BestPracticeETLArchitecture
clicktoenlarge BusinessIntelligence-Data
Integration
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
BusinessIntelligence-Data
Warehousing&DataModeling
Standardmechanismsforloadinghierarchies
BusinessIntelligence
ThereareseveralpossibilitiestosupplythehierarchywithdatainSAPBW: FunctionalPerformanceManagement
Expertise
Hierarchies can be maintained manually in SAP BW, however, doing this for large or
PM&BIAudit
frequentlychanginghierarchiesisofcoursetimeconsuming.
PM&BIRoadmap
Hierarchies can be fetched automatically from all types of source systems.SAPdelivers
numerousBIContentdatasourcestoextractstandarddatafromSAPsourcesystemsforall
kindsofindustriesandmodules.Thisisalsothecaseforlotsofstandardhierarchies,like
profit center, organizational unit However, very often the hierarchy data isavailablein
custom tables in the source system. SAP does not allow for customhierarchiestobe
extractedwithagenericdatasource.
Hierarchies can also be extracted from external systems (non-SAP)usingstagingBAPI's
(Business Application Programming Interface) or flat files, which can be generated
automaticallyviaaprogramandthenloadedintothehierarchyInfoObject.Whenautomating
thisprocedureaproblemisintroducedthatisnotalwayseasytoovercomethephysicalflat
file that is to be uploaded should be placed on the SAP BW server. This isnotalways
possibleforseveralreasons.
Last option to load a hierarchy is the data mart interface whichallowsloadingdatafrom
within a SAP BW system or from another SAP BW system. The problem is that the hierarchy is not (yet) available inaSAPBW
system.However,thisoptionwillprovetobeveryusefultoenableacustomhierarchyextraction.
IfyouwanttoloadastandardSAPhierarchyorahierarchybasedonaflatfile,youcanuseoneoftheabovemechanismstofetchthedata.
However, when loading non-standard SAP hierarchies or hierarchies from other sources, you are facingonebigproblem.SAPBWonly
allowsstandard hierarchy datasources orflat file based hierarchy datasources and one thing is for sure, loading any type of hierarchy
requiresadatasourceoftypehierarchytoinsertthedataintothecorrespondingInfoObjecttables!Sothereisnostandardizedwaytoloada
customhierarchyfromasourcesystem.
Howcanweworkaroundthisproblem?
In short, the solution is to get the data into a DataStore Object (DSO) [1], make suretheInfoObjecthasthecorrectproperties[2],loada
dummyhierarchy(usingthedatamartinterface)[3]andenhancethisextractioninordertoreplacethedummyhierarchywiththedatafrom
theDSO[4].Thisprocedurewillbeexplainedinmoredetailbelow.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
1.DSOcontainingtheHierarchyData
ThefirststepistogetthehierarchydataintoaDSO.Wecanuseatransactionaldatasourceforthispurpose.AcombinationofthenodeID
anditsparentnodeIDisenoughtobuildasimplehierarchy.
clicktoenlarge
Itisimportanttonotethatwedonotneedahierarchydatasource.Nomatterwhatsourceofdataandtypeofextractor,SAPallowsvarious
procedurestofetchthe"transactionaldata.
TheDSOZDSOCUSTusedinthisexamplewaspopulatedwithasimpleflatfile.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Contact;Description;ParentContact
1001Commercial
1002TechnicalSupport
1003ChangeContract1001
1004EndContract1001
1005NewContract1001
1006TV1002
1007Telephone1002
1008Internet1002
1009Up-sell1003
1010Down-sell1003
1011Side-sell1003
1012End1004
1013New1005
1014DigitalTV1006
1015AnalogTV1006
1016Mobile1007
1017Fixed1007
2.HierarchyInfoObject
clicktoenlarge
UsingtransactioncodeRSD1,maintaintheInfoObjectasanInfoSourcewithDirectUpdate'.
Choose an Application Component after enabling the corresponding checkbox. Depending on theInfoObjectproperties,thiswillallow
loadingattribute,textandhierarchydataforthecharacteristic.
MarkthecharacteristicasanInfoProviderbyassigningittoanInfoArea.TheInfoObjectwillthenbedisplayedintheInfoProvidertreeinthe
DataWarehousingWorkbench.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Enablethecharacteristicasanexportdatasource.ThisallowstheextractionoftheInfoObjectdatausingthedatamartinterface.
clicktoenlarge
ObviouslyyouwillalsoneedtospecifythattheInfoObjectcontainshierarchies.Theexactsettings,liketime-dependentandversions,affect
thetablesbeinggeneratedandthiswillinturnrequirespecificcodinginthedatasourceenhancementafterwards.
clicktoenlarge
3.DummyHierarchyExtraction
NowtheInfoObjectiscorrectlymaintainedandactivated,wecanbuildadummyhierarchy,whichwewilluseafterwardsasastartingpoint
forthedataextraction.Thismanualprocessneedstobedoneonlyonce(perSAPBWsysteminyourlandscape).UsethebuttonMaintain
Hierarchies'inordertocreatethedummyhierarchy.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
clicktoenlarge
Addingone(dummy)nodetothishierarchyissufficienttoactivatethehierarchy.Atextnodeistheeasiesttoadd.
Thenextstepisgeneratinganexportdatasource.Thiswillinfactgenerateadatamartforextractingattributes(M),texts(T)andhierarchies
(H), depending on the InfoObject settings. Go to the Data Warehousing Workbench' (transaction code RSA1) and right-click on the
InfoObject.Inthecontextmenu,chooseAdditionalFunctions'>GenerateExportDataSource'.Thedatasourcetypicallygetsthetechnical
name 8 <M', T' or H'> and can be found in the application component called Data Marts Master Data'(DM-IO)afterreplicatingthis
applicationcomponentinthedatasourcesareaoftheDataWarehousingWorkbench(remembertochecktheBWsystemitselfasasource
systemonthetopleftofthescreen).IfthisspecificapplicationcomponentisnotyetactivateinyourBWsystem,thenewdatasourcecanbe
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
systemonthetopleftofthescreen).IfthisspecificapplicationcomponentisnotyetactivateinyourBWsystem,thenewdatasourcecanbe
foundintheapplicationcomponentUnassignedNodes'(NODESNOTCONNECTED).
Now we have a hierarchy datasource and we can link it to our InfoObject hierarchy via transfer rules.Hierarchydatasourcesarenotyet
supported using SAP Netweaver 2004s/7.0 technology and therefore we still need touseaSAPBW3.5datasourceandtransferrulesto
build the connection. In fact we connect the InfoObject to itself. In order to create transfer rules, right-click onthehierarchyandusethe
context menu to go to Additional Functions' > Create transfer rules'. Next we need to select the correct source system. Aswewantto
employtheexportdatasourcewecreatedearlier,selectthesameSAPBWsystemastheoneyouareloggedonto.Alistofallavailable
datasources for that source system will pop up. Select the export datasource we created earlier. It should have thename8<H'>. The
transferrulesaregeneratedautomaticallyandinfacttheyestablishthelinkbetweentheexportdatasourceandtheInfoObjecthierarchy.
Image 10 InfoPackage
clicktoenlarge
4.ExtractionEnhancement
Sofarwehavebuiltadataflowthatallowstheextractionofadummyhierarchyintoanewhierarchythatisanexactcopyoftheoriginalone.
NowwestillneedtoinsertthehierarchydatathatiscurrentlyresidingintheDSO.Thiscanbedoneinauserexit,anenhancementofthe
generatedhierarchydatasource.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Hierarchydatasourcescanbeenhancedlikeanyothertypeofdatasource.Eachtypehasitsownfunctionmodule,withintheenhancement
"RSAP0001-CustomerfunctioncallsintheserviceAPIthatiscalledautomaticallyduringextraction:
EXIT_SAPLRSAP_001:Transactionaldata
EXIT_SAPLRSAP_002:Masterdataattributesortexts
EXIT_SAPLRSAP_004:Hierarchies
IfenhancementRSAP0001isnotyetactiveinyoursystem,itcansimplybeactivatedandassignedtoaproject.
ThefunctionmoduleEXIT_SAPLRSAP_004'iscalledeverytimeahierarchydatasourceisexecuted.ItispartofthefunctiongroupXRSA-
CustomerExitsintheServiceAPI'.ThisfunctionmodulecontainsanincludecalledZXRSAU04'.ThisincludecanbeenhancedusingABAP
codingtofetchthedatafromtheDSOweloadedearlier.ThemostimportanttableinthisexitistableC_T_HIENODEwhichshouldbefilled
withtheactualhierarchydata.ThistablehasthetypeRSAP_T_HIENODEwhichisdefinedlikethestructureROSHIENODE.
clicktoenlarge
Note that not all fields are required in order to successfully build your hierarchy.DependingonthehierarchypropertiesintheInfoObject
settings,otherfieldsandevenothertablescanbecomerequired.
The above example hierarchy is quite straight-forward and therefore it is sufficient to populate only a selection of fields ofthetable
C_T_HIENODENODEID,IOBJNM,NODENAME,TLEVELandPARENTID.
Let's have a more detailed look atthesefields.ThefieldNODEID has to be uniquelydefined.ThefieldIOBJNM should be filledwiththe
InfoObjectnameZCUSTCONT'orthevalue0HIER_NODE'ifyouwanttoloadatextnode.ThefieldNODENAMEshouldbefilledwiththe
actualvalue(InfoObjectvalueorthedescriptionofthetextnode).CompoundedInfoObjectscanalsobeused,butthenweneedtospecify
thecompoundedvalueaswell.ImaginethatourInfoObjectZCUSTCONTiscompoundedwithcountry.IfwefillthefieldNODENAMEwith
thevalue"BE1003,thisvaluewillbeautomaticallysplitintothecountry"BEandtheCustomerContact"1003.
ThenextfieldiscalledTLEVELandcontainsthehierarchylevelofthenode.Ifthehierarchylevelofanodeisnotequaltothesumofthe
hierarchylevelofitsparentsand1,thiswillgenerateanerrorwhenloadingthehierarchy.Thetopnodeofahierarchyiscalledarootand
multiplerootsareallowedinasinglehierarchy.Thisrootnodealwayshashierarchylevel1.PARENTIDcontainsthenodeidoftheparent.
ThefieldNODENAMEhastobeunique,exceptwhenthefieldLINKcontainsthevalueX'(incapitals!)whichallowsforonehierarchynode
to be included several times in the hierarchy (at different hierarchy branches). Inotherwords,oneNODENAMEcanhavemultipleparent
nodes.Whenusingtheseduplicatehierarchynodesinareport,thekeyfigurevalueforthatInfoObjectvaluewillbedisplayedmultipletimes
inthehierarchy.Ofcoursethiskeyfigurevaluewillonlybetakenintoaccountonceintheresultrows!Whenusingintervals,youwillalso
havetofillthetableC_T_HIEINTV.
IfwehaveaDSOthatonlycontainsthenodeidanditsparentnodeid,wehaveenoughinformationtobuildourhierarchy.Howeverweneed
tocalculatethehierarchylevelmanually.Bestpracticeistostartwiththeroot(s)andfinditschildren,thenfindthechildrenofthosechildren
andsoon.Notethateachrootshouldofcoursebelistedseparatelyaswell.
Let's take a closer look at the coding. As the include ZXRSAU04' is executed each time a hierarchy datasourceisexecuted,itis
recommendedtomakeadistinctionbetweenthedatasources.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Thisproceduremakessurethatyourcodingisnotexecutedwhenotherhierarchydatasourcesareexecuted.
ThefirstthingtodointheABAPprogramistodeletethedummyhierarchydatafromtheinternaltableC_T_HIENODE.
NowwecansetthehierarchydescriptionCustomerContacts'.
NextweneedtofetchthehierarchydatafromtheDSOintoaninternaltable.
For each node we need to find out the hierarchy level and the nodeIDofitsparent.Makesureallrelevantfieldsarefilled.Asmentioned
earlier,thisvariesaccordingtotheInfoObjectproperties.Theeasiestwayistoworktop-downandstartwiththeroot(s).Arootisanodethat
doesnothaveaparent.Ahierarchycanconsistofmultipleroots.Oncewehaveidentifiedtheroots,wecansearchforitschildren.Thenwe
needtosearchforthechildrenofthechildren.EveryrecordissavedinthetableC_T_HIENODE.Wecontinuethisprocessuntileveryrecord
isprocessed.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Now that we have completed the datasource enhancement, the last step is executing the Infopackage. This willpopulatethehierarchy
basedonthedatasetthatwepreviouslyloadedintoaDSO.Thecompleteloadingprocedurecanbeautomatedbyimplementingaprocess
chain.
That'sit!ThehierarchyisreadyforuseintheSAPBWreports.
Conclusion
UsingSAPNetWeaverBW7.1(orprior),thereisnostandardizedwaytoloadacustomhierarchy.Hierarchiescanonlybeloadedusingthe
BW 3.x data flow and datasource migration is impossible. The procedure described in this insight is a good workaroundtoenablean
automated custom hierarchy extraction. With the brand new hierarchy framework that isdeliveredwithSAPNetWeaverBW7.30,thiswill
becomeeasierasanytypeofdatasourcecanbeused.
back
Share 13
Advisory|IBMBusinessIntelligence&CPM|SAPBusinessIntelligence&CPM|MicrosoftBusinessIntelligence|InterimManagement|Hosting home|sitemap|contact
20092011|copyrightbyelem ent61|allrightsreserved
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com