You are on page 1of 34
Applies to: ‘SAP BusinessObjects Planning and Consolidation version 10 for NetWeaver BPC 10 SP7 & Above EPM Add-In 10.0 SP 12 Patch 1 for .NET Summary How to call BPC deta manager package trom Visual Basic Author: Tristan Colgate, Amaury Gruyelle, Muthu Ranganathan Company: Bluefin Solutions in collaboration with SAP Created on: 31 August 2012 Author Bio Tristan Colgate, EPM Lead at Bluefin Solutions, UK ‘Amaury Gruyelle, BPC Consultant at Bluefin Solutions, UK ‘Muthu Ranganathan, EPM Product Management at SAP. SAP COMMUNITY NETWORK sen.sep.com © 2012 SAP AG 1 ‘How to Call BPC Data Manager Package from Visual Basic Table of Contents Scenario. Details and Usage Step by Step Instructions. Create the PARAMETERS Excel Name Range Create the PACKAGE Excel Name Range. ‘Add the Visual Basic code Create the User Interface to perform the Copy. co — cos Appendix 24 How to display the Developer tab in the Excel Ribbon. 24 MS Office Excol 2010 21 VBA Code 24. Example XML Prompt File sere Related Content. 33 Copyright. 34. SAP COMMUNITY NETWORK ‘sen sap.com (©2012 SAP AG 2 ‘How to Call BPC Data Manager Package from Visual Basic Scenario ‘The Data Manager packages delivered as standard with BPC are sophisticated, having many different options. Consider the Copy DM Package. Firstly, the user needs to specify how the records are handled during the copy. Then the user specifies whether they want default logic to run after ‘the copy is performed. SAP COMMUNITY NETWORK ‘sen sap.com (©2012 SAP AG 3 Thirdly the user is asked whether ‘they wish the copy to respect ‘work status. Fourthly, they must specify the source and destination data ranges. SAP COMMUNITY NETWORK (©2012 SAP AG ‘How to Call BPC Data Manager Package from Visual Basic ‘sen sap com ‘How to Call BPC Data Manager Package from Visual Basic Finally, the user selects whether they want to run the copy mediately, or schedule it to run later. ‘These options can be confusing to an occasional user of BPC, such as a Cost Centre Manager preparing their annual budget. Many of the options are not relevant to what they are trying to achieve, and would actually cause errors in the way their data is processed if set incorrectly. ‘One solution is to copy the standard package and amend the Prompt script to default those options where appropriate and only present options that are pertinent to the user, in contextualised language that the user will understand, This may, however, still leave the user navigating through a number of screens when they simply wish to perform a simple function, such as copying their data from one version to another. A common question from Users in such a scenario is whether they can simply have drop-down boxes in two calls in the Excel spreadshest where they can specify from and to Categories, and a button that executes the copy: o-oo ee - Mat (REIN r= | mee rsetnest Fortis itn Rew View oer Eonar SAS tee A Be Smee Gent HB ™ Gremaromar| ® Fe) Gl | M- B-) S aAAE iveoracones Bom + | At eaten ro Taare Tou SAP COMMUNITY NETWORK sensep.com (©2012 SAP AG 5 ‘How to Call BPC Data Manager Package from Visual Basic This paper will describe how to achieve this. Details and Usage The solution involves the following components Sone PE Rk ee Rieptem An Excel sheet where the user can specify from ‘and to versions and click the button to execute the copy. AName range called PARAMETERS in the Excel Workbook that ‘specifies all of the pieces parameters that the function in question (in “STOSELECTION our case, tho Copy Srosntcons eto function) expects, along SESSIONS with the values that wil be passes to them, Sroucons SAP COMMUNITY NETWORK © 2012 SAP AG sensep.com How to Call BPC Data Me sger Package from Visual Basic AName range called mn PACKAGE in the Excel i ‘workbook that defines the details of the package we wish to execute Process Chain We also specify here the name of the Prompt File pronaar that is generated during the process. Visual Basic code that, upon being invoked, calls the Data Manager Package specified in the PACKAGE Name range, passing the parameters specified in the PARAMETERS Name range. Step by Step Instructions Create the PARAMETERS Excel Name Range The standard Copy DM Package delivered in the EnvironmentShell BPC model expects the following parameters (as defined in the prompt script file). * TARGETMODE — ~ contains a 0 or a2 * RUNLOGIC contains a0 or a1 * CHECKLCK contains a0 or a1 * SELECTION = Dimension’ Member pairs defining the source data range. © TOSELECTION — —Dimension/ Member pairs defining the target data range. This information can be gleaned by looking at the DM Package prompt script file, which is accessed as follows: Navigate to the DataManager tab on the Excel ribbon SAP COMMUNITY NETWORK sensep.com © 2012SAP AG 7 Select Organize-->Organize Package List In the Organize Package List pop-up, find the Copy Package, right-click and choose Modify Package. Click on Modify Seriptin the subsequent pop-up: SAP COMMUNITY NETWORK (©2012 SAP AG ‘How to Call BPC Data Manager Package from Visual Basic ‘sen sap.com ‘How to Call BPC Data Manager Package from Visual Basic Click on Advanced in the subsequent pop-up: ‘The final popup, Modify Seript, shows the script used to pass parameters back to the DM Package Process Chain. Analyse this information to ‘work out which parameters you need to include in the PARAMETERS Excel Name Range. Now we will create the PARAMETERS Name range in Excel. SAP COMMUNITY NETWORK ‘sen sap.com (©2012 SAP AG 8 Create the cells containing the specification of parameters as per the screenshot. Note: ‘* Prompt names should match those in the DM Prompt definition, with % before and after. © Prompt Type is either Parameter or StingListPairs ‘+ Dimension is only relevant for StringListPairs ‘© Value is the value you want to set this parameter to— this can be hard coded (as is the case for the three Parameters), or can use an Excel formula, as is the case for the source and destination categories which look at the selection the user has made in the from and to version drop-downs. SAP COMMUNITY NETWORK © 2012 SAP AG ‘How to Call BPC Data Manager Package from Visual Basic Ddorce DEIR iene tes rts Famats omer ven Stes © wees a — > SenecTon'i ——srngueoe 6 coun { Aanceronn, ——sriguae usta 4 Recon ng lta wpa {a ssnccronnt segue ar nooutr 1 SSLECTONS. Serge — APICES (2 Senecio ——stguise 2 Srosrecrons—srgunpsn se Teor aa 1D bros scr —srrquasie se praca + 1 Soe ecoani square SF WYCLARENE sensep.com 10 ‘How to Call BPC Data Manager Package from Visual Basic wiua-e ttt a ee Fh Sr sees Pee, oer BF 6 cerca |Beoeme | ome Rew meee: Select the cells (in our case, ‘the range At to D20) Log Off from Planning | Run Enter PARAMETERS into the ‘and Consolidation | Package cell reference box to make the Connection Name range. [= Account pL_accounr-p. SAP COMMUNITY NETWORK ‘sen sap.com (©2012 SAP AG 1 ‘How to Call BPC Data Manager Package from Visual Basic Create the PACKAGE Excel Name Range Log on to the NetWeaver =o ABAP stack via SAPGUI. Go to transaction SE16 (Data Browser) TE Table Edt Goto Settngs Utites System Heb el 4 weee chai s Details about Data Packages are stored in table UJD_PACKAGES2. Enter this table name into the Table Name field and click on SAP COMMUNITY NETWORK ‘sen sap.com (©2012 SAP AG fa ‘How to Call BPC Data Manager Package from Visual Basic 000 Gly ere mA OR Enter the BPC Environment and Model IDs into the APPSET_ID and APP_ID fields respectively. Click on: In the table returned, identity ‘the row containing the DM Package we are interested in and select it. Click on: & ‘The resulting screen contains all of the details you will need {0 populate the PACKAGE: name range. ‘The following table indicates how you should map the values found in the UD_PACKAGE2 table with the fields you need to populate in the Excel Name Range you will shortly create. SAP COMMUNITY NETWORK ‘sen sap.com (©2012 SAP AG 8 How to Call BPC Data Me sger Package from Visual Basic fork eee 4 fierce CHAIN 1D Filename /CPMBICOPY GROUP ID. Groupld Data Management PACKAGE ID PackageDesc Copy PACKAGE 1D Packageld Copy PACKAGE TYPE PackageType Process Chain TEAM ID. TeamID USER_GROUP UserGroup 0010 * Note that the number in the table must be entered with leading zeroes, as a four character field. Additionally, field PromptFile will contain the name of a file that will be created as part of the process of launching the DM Package. Note that, if you are using this in an Enterprise environment, that you'll need to decide on a file location that can be guaranteed to exist on all end users’ PCs. In our, example we use: C:A\CopyDataManagerPromptFile.txt Now we will create the Excel PACKAGE Name Range’ £8 Loretto Grom Create the cells containing the specification of parameters as por the screenshot. ‘comacore Proce Ca © copySrauanageronpe SAP COMMUNITY NETWORK sensep.com © 2012 SAP AG 4 ‘How to Call BPC Data Manager Package from Visual Basic Dida-c le acl HEME em tet tt famine Semcon Dower Cr ae sseescatee bier S| Somme Beam Select the cells inthe data range (in our case cells F1:G9) i @ Upioza Data © (© & ro Log Off from Planning ‘and Consolidation | Package Status~ [Data Preview Data Manag) Enter PACKAGE into the cell ee reference and hit . EPM Context Account PLACCOUNT-PL Accounts» JSF_CATEGORY Parameter PACKAGE © fe Add the Visual Basic code ‘Note that you must have the “Developer” tab enabled in the Excel ribbon: SAP COMMUNITY NETWORK ‘sen sap.com (©2012 SAP AG 6 ‘How to Call BPC Data Manager Package from Visual Basic Bie we ee ee Sara /¢ OM ire Bi ei 2 Sic toe ae If you cannot see this tab in your ribbon in Excel, then you need to enable it. Follow the instructions in the Appendix to do so before moving on. & Click on the" button in the Developer ribbon tab to open ‘the Visual Basic editor. ‘Bie fe ow Wet Forma Detog ton Lach ats Wor deere Navigate to Tools—-> Aonh oc References from the Visual kalgg§ Be Basie menu bar. BS Macon SAP COMMUNITY NETWORK ‘sen sap.com (©2012 SAP AG 16 Check the boxes as per the screenshot to the right. Note = you may need to scroll down auite a long list to find some of these. In the Project Explorer pane, right click on the VBAProject node for your Exce! Workbook and choose: Insert -> Module SAP COMMUNITY NETWORK (©2012 SAP AG ‘How to Call BPC Data Manager Package from Visual Basic ‘son sap com 7 ‘How to Call BPC Data Manager Package from Visual Basic Copy and Paste the code in Appendix 4.x into the newly created Module, Create the User Interface to perform the Copy ores a cone ey ® | 2 8 <=. 3. Create the following cells. SAP COMMUNITY NETWORK ‘sen sap.com (©2012 SAP AG 8 ‘How to Call BPC Data Manager Package from Visual Basic Use Data Validation in order to provide a drop-down on the Category dimension fields. See BB ee So BE In the Developer ribbon tab, choose Insert--»Button Form Control, Use the lasso tool to draw out the rectangle for the button. SAP COMMUNITY NETWORK ‘sen sap com (©2012 SAP AG 19 ‘The Assign Macro popup appears. Select existing Macro executeDmPackageWithParameter s. Click OK. The button is now displayed. To ‘ast the solution, click on the button. In the Data Manager ribbon tab, click on: fi View + Status SAP COMMUNITY NETWORK (©2012 SAP AG ‘How to Call BPC Data Manager Package from Visual Basic lef) eletelelsis/el5|[ sell aya yl ‘son sap com 20 ‘How to Call BPC Data Manager Package from Visual Basic ‘The Package Status popup should = appear and show your job in smmocxum progress (or perhaps already completed), Appendix How to display the Developer tab in the Excel Ribbon MS Office Excel 2010 Here isthe Excel 2010 Ribbon, Note thatthe Developer tab isnot curently displayed aa a _— oe oe oe EB SAP COMMUNITY NETWORK sen sapcom (©2012 SAP AG a ‘How to Call BPC Data Manager Package from Visual Basic Bian Select the File tab in the ribbon ox and click on Options. ————— Se ee fee = ar The Options pop-up is Seon te 2 displayed: SAP COMMUNITY NETWORK ‘son sap com (©2012 SAP AG 2 Select the Customize Ribbon option in the left pane. In the right-hand panel, select ‘the chackbox labelled Developer, and then click on OK. ‘The Developer tab is now displayed. SAP COMMUNITY NETWORK (©2012 SAP AG ‘How to Call BPC Data Manager Package from Visual Basic ‘son sap com B ‘How to Call BPC Data Manager Package from Visual Basic VBA Code public sub exscuremnsaciag! create the Answer Proupt file in the location " specitied in the wane Range PACKAGE" crestennsverpronptrile "RCKNGE", Get the DM Automation class instance im cbjowautomation as Eruaddmotnutonation set opjpMgutomation = New EEvAdaInoMAutenarion Fun the package specitied in Excel Nane Range "PACKAGE", using the promtp file specified in Name Range "PACKAGE" objmmautonation.RunFackage sbjFackagerrcmshest ("PACERGE"), _ sterilenane("ZACKAGE") End sb Private Fonction strFilenane(styRange As String) As string + Get che range in which the IM package paranteres is set in anggackagerangs As Range Set moPackageRange = application.Wanes (strRange) .RefersToRange Loop through the rows For i= 1 To mngtackageRange Rows Count Ef rngvackagenange(i, 2) .value = "promptrile" Then. stepilename - mgrackagerange(i, 2).value xi Function mad It Next End Function Private Pmction strvackagenescription (strRange As string) As string Get the range in which the mM package paramteres is set Dim engPackageRange As Range Set_mgFackaganange = application anes (stvRange) -RefersToRange SAP COMMUNITY NETWORK sensep.com (©2012 SAP AG 24 ‘How to Call BPC Data Manager Package from Visual Basic Roop through the rows Ber i = 1 zo engoacieagenange Reve count TE rngPackageRange(i, 2) Valut = "Fackageld" Then steeackagenescription ~ mgvackagenange(i, 2).value xi Function znd tf Next pnd pmetion Private Pmction objeackagerrensheet (strRange As string) As ADMPackage Get the range in which the ou package paramteres is sot, im moFackageRange As Range Set mgPackageRange = application anes (stvRange) -RefersToRange cesste che Any pacieage cngect Set cbjPackageronshest = New ADMEackage cough the rows 41 ro engeackagenange.Rows count Select case mgpackageRange(i, 1) value case "rilename" objPackageFrongheet.Pilenane = rngPackageRange(i, 2) Value case "croupra" objBackagePronSheet .Groupld = engPackageRange (i, 2) Value case "packagenesc™ objPackagerscnshest Packagetess = rngPackageRange(i, 2) Value case "eaciages objPackageFronsheet. Packaged = rngPackageRange(i, 2) Value case "PackageType" objPackageFronsheet.PackageType magPackagenange (i, 2) value case "resnza" objPackageFronsheet.TeanId = rngPackageRange(i, 2) Value case *Usexcroup™ objPackageTicnshest UserGroup = mgPackageRange (i, 2) Yelue end Select SAP COMMUNITY NETWORK sensep.com (©2012 SAP AG 25 ‘How to Call BPC Data Manager Package from Visual Basic mad ustion Private Sub createAnsverPromprFiie(strPackageNane As string, _ steParaneceranane As string) | ceeace 2 new 20 aocunent Dim ebjDOM As DoMDocunent set objnow = New ooupocunent + set the processing instruction of the 20M document im objerocessingInstruction As TXMLDONProcessingTnstruction Set cbjerocessinginscruction = _ objDOM. createProcessinginstruction ("a ob}D0H.eppendChild objProcessingl "create root e1enent im cbjnootelen As Dompowtlenent Set cbjRoctBlen = abjnamcreaterlenent (*arrayofAnsuerPronptersistingFormat") objrou.appendchild objrootzien + usr avteibuce Dim objMenberfel As Tempoaccripute Sct cbjMenberRel = objDot.createat tribute (wouns:xsi") objManberel.NadaValue = *hetps//wwi.w3.089/2 chpneotblen. secatceiourencds cejuensexnel 1 /soekSchena~instance” usp ateribute Set cbjMembernel - objnom.createatcribute ("umlns:xsd") cbjMenberRel NodeValue = “http://wes.43.0rg/2001/xMLSchema" opJRootEien. secaccributetiode objMenberRe1 Get the range of celle containing the parameters im mgearaneters As Range Set mngParansters = Thisiordbook.Nanes (stsParanstersMane) .RefersToRange ‘excel anes (strParaneterstiane) .RefersToRange im objcurrentscringPairFarent as TaVLDOMELenent SAP COMMUNITY NETWORK sensep.com (©2012 SAP AG 26

You might also like