Top Banner
SAP COMMUNITY NETWORK scn.sap.com © 2012 SAP AG 1 How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation Applies to: SAP Business Planning and Consolidation for Netweaver version - SP7 & Above EPM Add-In 10.0 SP 12 Patch 1 for .NET4 & Above Summary This how to guide provides the solution to perform distributions for locked cells (Breakback functionality) Authors: 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.
45

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

Jan 03, 2016

Download

Documents

maleenimudaliar

test
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 1

How to Perform Distributions that

Respect Locked Cells in SAP

Business Planning and

Consolidation

Applies to:

SAP Business Planning and Consolidation for Netweaver version - SP7 & Above

EPM Add-In 10.0 SP 12 Patch 1 for .NET4 & Above

Summary

This how to guide provides the solution to perform distributions for locked cells (Breakback functionality)

Authors: 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.

Page 2: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 2

Table of Contents

1. Scenario ................................................................................................................................................. 3

2. Details and Usage ................................................................................................................................. 3

3. Step-by-step Instructions ....................................................................................................................... 5

3.1 BPC Model ............................................................................................................................................. 5

3.2 BAdI ....................................................................................................................................................... 9

3.3 Script Logic to Call BAdI ...................................................................................................................... 10

3.4 DataManager Package ........................................................................................................................ 15

3.5 Visual Basic to call DataManager Package ......................................................................................... 23

3.6 Custom Excel Ribbon .......................................................................................................................... 27

4. APPENDICES ...................................................................................................................................... 31

4.1 Visual Basic Code for Locking/ Unlocking Cells .................................................................................. 31

4.2 Other Visual Basic Code for Excel Custom Ribbon buttons ................................................................ 32

4.3 Visual Basic Code for frmDistribute ..................................................................................................... 33

4.4 Visual Basic to calculate locked cells string ........................................................................................ 34

4.5 Visual Basic to return range of a report ............................................................................................... 35

4.6 Visual Basic to determine if cell is “locked” ......................................................................................... 35

4.7 Visual Basic to return the cell context in lock format ........................................................................... 36

4.8 Visual Basic to get the context of a report cell..................................................................................... 36

4.9 Visual Basic to return a formatted tuple ............................................................................................... 37

4.10 Visual Basic to create answer prompt xml file ..................................................................................... 37

4.11 Visual Basic to add a StringList pair to the xml file .............................................................................. 40

4.12 Visual Basic to add a StringList pair parent to the xml file ................................................................. 40

4.13 Visual Basic to add a single selection parameter to the xml file.......................................................... 41

4.14 Visual Basic to get the current view member for a specified dimension ............................................. 41

4.15 Simulation Ribbon ................................................................................................................................ 42

Related Content ................................................................................................................................................ 44

Copyright........................................................................................................................................................... 45

Page 3: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 3

1. Scenario

Plans are always made with a goal in mind, and financial plans, budgets and forecasts are no different. That goal might be the Revenue or Contribution target that you have been set by the Sales Director, for example. The target you are aiming for might be the result of a complex set of inter-related variables, for example:

You are a divisional sales head targeted on Trade Spend and Contribution

Contribution is dependent on, amongst other things, upon:

o the volume of each type of the many products you sell

o the price you sell them at, and how much they cost to make and distribute

o the additional volume you will sell if you run promotions or offer discounts

o the cost of those promotions or discounts

To put together a realistic plan that meets your objectives within the constraints of this model requires a planning solution that supports efficient and accurate goal-seeking, with the ability to quickly try different scenarios and receive fast feedback. The characteristics of such a system need to include:

The ability to quickly make alternative versions of a plan, amend them, and compare the results

against the original plan, and other alternative versions – so-called “What-If Planning”.

The ability to change fundamental assumptions such and immediately see the effect of this on the

target KPIs. For example, upon changing a product price you want to immediately be able to see

the effect on Contribution across all customers.

The ability to quickly change a large number of data points in a consistent manner. For example, in

a new scenario you want to increase the total volume of a product sold to all customers over all

months, and have the difference distributed over the customers and months using the same ratios

that those data already display, or by referring the ratios found in historical data.

The ability to make those changes to large volumes of data whilst locking down certain data points.

For example, you want to test an alternative scenario where the overall volume is 2% more than

your existing scenario, but sales for to a certain customer are not increased because they have

already signed up to a fixed volume deal for the year.

2. Details and Usage

This section will detail how our distribution with locking solution works from the user’s point of view.

Log in to EPM Office Add-in Excel

Page 4: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 4

After logging in, click on “EPM” ribbon, then, click on “Open” in the next menu, and press on “Open Server Input Form Folder”.

Then, click on “01_PLAN” in the left pane, and “IS02_SALES_VOLUME” in the right pane.

The base Plan for 2013 has not been initialized yet.

You could initialize the base Plan based on the reference to other data.

To do that, double click on the cell for TOTAL_CUSTOMER and 2013 Total, input an amount, tick the third option “Reference to other data”, and select members. Press on “OK”.

Then, press on the refresh button, the data of the template will be updated.

Page 5: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 5

After having created your “what ifs” scenario based on the Base Plan, you would to modify the amount to distribute and to freeze some cells, you could use the break-back functionality.

To do that, select the cell(s) to lock, then, click on “Lock selection” into the Simulation ribbon.

Then, right click on the cell for TOTAL_CUSTOMER and the time 2013, input an amount, tick the second option “Existing Distribution”. Press on “OK”.

To finish, press on the refresh button, the data of the template will be update except your cells locked.

3. Step-by-step Instructions

3.1 BPC Model

This demo has been created on the latest version EPM 10 NW SP12 Patch 1.NET4.

The technical name of the environment is DEMO_SAP, it is made up of one model: SALES_PLANNING : Sales planning process (Financial Model) ;

The model SALES_PLANNING comprises 8 dimensions: BF_ACCOUNT (Account type);

BF_CATEGORY (Category type);

BF_COUNTRY (Entity type);

BF_CUSTOMER (No type);

Page 6: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 6

BF_DATASRC (No type);

BF_PRODUCT (No type);

BF_RPTCURRENCY (Currency type);

BF_TIME (Time type).

Dimensions of the SALES_PLANNING model:

SALES_PLANNING Dimensions

How you can create quickly a template:

Log in to EPM Office Add-in Excel

After logging in, click on “EPM” ribbon, then, click on “New Report” in the next menu.

Page 7: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 7

The EPM – Report Editor pop up will open.

In this step, you could define the layout of you template using the drag and drop functionality.

Here, we put the BF_CUSTOMER dimension in row axys, BF_TIME in column axys, and BF_CATEGORY, BF_COUNTRY, BF_PRODUCT page axys.

If you right click on the dimension in row or in column, you will define which members you want to see in your template.

Here, we selected “Context” in the left pane with the option “Member and base level” and validated our selection (Arrow at the top).

Page 8: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 8

In the Options tab, you could define the placement of total members ( e.g. Top or Bottom), if it is an input form or a report (Use an Input Form), if you want calculate automatically all parents in hierarchy before saving data, or remove empty rows and columns.

Then, press on the button “Ok”

The EPM – Report Editor will hide, and your template will be created.

To modify the formatting you can use the default formatting sheet called “Format Input”.

Page 9: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 9

To use this formatting, you need to go back to the EPM – Report Editor, so, click on Edit Report into the “EPM” ribbon.

In the Options tab, you will define the tab “Format INPUT” as the default formatting sheet.

Then, press on the button “Ok”

On the next screen you can see that the template has been updated with the formatting.

3.2 BAdI

In order to provide the distribution logic that respects locked cells in the NetWeaver backend, we will implement a BAdI using the UJ_CUSTOM_LOGIC Enhancement Spot. The BAdI implementation as well as the supporting code (class ZCL_UJLOGIC_DISTRIBUTION_LOCK) are provided in the attached transport files. You should ask your BASIS consultant to import the transport into your NetWeaver environment in the usual way, via transaction STMS.

Page 10: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 10

This transport contains the following objects:

UJ_CUSTOM_LOGIC implementation ZBPC_DISTRIBUTION_WITH_LOCK – you can view this in

transaction SE19.

ABAP Class ZCL_UJLOGIC_DISTRIBUTION_LOCK – this contains the logic.

Please note that the code has been designed to work for the demonstration Environment and will require full testing/ amendment if it is to be used in a productive solution. This is intended as a demonstration of this approach to fulfilling the distribution with locking functionality only.

3.3 Script Logic to Call BAdI

In this step, we will develop the script to call the BADI which we created in the previous section.

Log to the Planning and Consolidation Administration.

Navigate to the Rules menu, select Logic Scripts and the right model.

Page 11: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 11

Then, click on “New” above the list of the existing logic scripts.

Provide the following name:

DISTRIBUTION

Copy the following logic script.

*XDIM_MEMBERSET BF_ACCOUNT = TECH_VOLUME

*XDIM_MEMBERSET BF_DATASRC = INPUT

*XDIM_MEMBERSET BF_TIME = BAS(2013.TOTAL)

*START_BADI DISTRIBUTE_WITH_LOCK

QUERY = ON

WRITE = ON

DISTRIBUTE_AMOUNT = $DISTRIBUTION_AMOUNT$

DISTRIBUTION_METHOD = $DISTRIBUTION_METHOD$

LOCKED_CELLS = $LOCKED_CELLS$

REFERENCE_DATA = $REFERENCE_DATA$

*END_BADI

*COMMIT

Page 12: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 12

Then, paste it.

Now, you need to validate the syntax of your logic script, click on “Validate” above the script.

Last step, save your new logic script, press on “Save”.

Page 13: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 13

Some Explanations on this logic script:

Concerning the structure of Script Logic, a script can be broken down into 3 components:

Scoping- What am I running the data on? *XDIM_Memberset

Body/Code – What do I want to do with the scoped records? Custom BADI

Writing the record *Commit

To manage the distribution, an ABAP custom logic called “DISTRIBUTE_WITH_LOCK” has been created. So, to pass parameters to the ABAP custom logic The START_BADI and END_BADI syntax has to be used.

There are two optional parameters you can use within a *START_BADI / *END_BADI instruction.

QUERY=ON/OFF //optional; default is OFF WRITE=ON/OFF //optional; default is OFF

Query performs a default query and Write automatically writes back the data.

Set QUERY parameter to OFF if you want to perform your own read inside the BADI implementation;

Set WRITE to OFF to not write back query results automatically. You may code to write to another application from the BADI.

In the DISTRIBUTION logic script, four more parameters have been added:

DISTRIBUTE_AMOUNT = $DISTRIBUTION_AMOUNT$

This parameter is used to save the amount input into the Distribute pop up.

DISTRIBUTION_METHOD = $DISTRIBUTION_METHOD$

The interest of this parameter is to save the type of distribution selected into the Distribute pop up (Equal distribution, Existing distribution, or Reference to other data).

LOCKED_CELLS = $LOCKED_CELLS$

This parameter is used to save all locked cells by the user into the Sales Volume Input Schedule.

REFERENCE_DATA = $REFERENCE_DATA$

Latest parameter is only used when the third distribution method is selected by the user. The category and Time members chosen will be used with this parameter.

Page 14: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 14

For example, for the distribution using break-back showed previously in the second part of this document “ Details and Usage” :

The various values for each parameter are:

DISTRIBUTE_AMOUNT = 450,000

DISTRIBUTION_METHOD = 0 (Equal Distribution)

1 (Existing Distribution)

2 (Reference to other data)

DESTINATION =

/DEMO_SAP/Sales_Planning/PRIVATEPUBLICATIONS/AGRUYELLE/TempFiles/FROM.TMP@@@SAV

E@@@@@@EXPAND@@@|DIMENSION:BF_CATEGORY|Optimistic|DIMENSION:BF_COUNTRY|E

0203|DIMENSION:BF_PRODUCT|PRDGRP2|DIMENSION:BF_RPTCURRENCY|LC|DIMENSION:BF_TI

ME|2013.TOTAL

$REFERENCE_D

$DISTRIBUTION_METH

$DISTRIBUTE_AMOUN

Page 15: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 15

REFERENCE_DATA =

/DEMO_SAP/Sales_Planning/PRIVATEPUBLICATIONS/AGRUYELLE/TempFiles/FROM.TMP@@@SAV

E@@@@@@EXPAND@@@|DIMENSION:BF_CATEGORY|Actual|DIMENSION:BF_TIME|2012.TOT

AL

LOCKED_CELLS =

BF_CUSTOMER|C00001||BF_TIME|2013.01|||BF_CUSTOMER|C00001||BF_TIME|2013.02|||BF_

CUSTOMER|C00001||BF_TIME|2013.03|||BF_CUSTOMER|C00002||BF_TIME|2013.01|||BF_CUS

TOMER|C00002||BF_TIME|2013.02|||BF_CUSTOMER|C00002||BF_TIME|2013.03|||BF_CUSTO

MER|C00005||BF_TIME|2013.01|||BF_CUSTOMER|C00005||BF_TIME|2013.02|||BF_CUSTOMER

|C00005||BF_TIME|2013.03|||BF_CUSTOMER|C00010||BF_TIME|2013.01|||BF_CUSTOMER|C0

0010||BF_TIME|2013.02|||BF_CUSTOMER|C00010||BF_TIME|2013.03|||BF_CUSTOMER|C0000

3||BF_TIME|2013.01|||BF_CUSTOMER|C00003||BF_TIME|2013.02|||BF_CUSTOMER|C00003||

BF_TIME|2013.03|||BF_CUSTOMER|C00004||BF_TIME|2013.01|||BF_CUSTOMER|C00004||BF_

TIME|2013.02|||BF_CUSTOMER|C00004||BF_TIME|2013.03|||BF_CUSTOMER|C00006||BF_TIM

E|2013.01|||BF_CUSTOMER|C00006||BF_TIME|2013.02|||BF_CUSTOMER|C00006||BF_TIME|2

013.03|||BF_CUSTOMER|C00007||BF_TIME|2013.01|||BF_CUSTOMER|C00007||BF_TIME|2013.

02|||BF_CUSTOMER|C00007||BF_TIME|2013.03|||BF_CUSTOMER|C00008||BF_TIME|2013.01|

||BF_CUSTOMER|C00008||BF_TIME|2013.02|||BF_CUSTOMER|C00008||BF_TIME|2013.03|||B

F_CUSTOMER|C00009||BF_TIME|2013.01|||BF_CUSTOMER|C00009||BF_TIME|2013.02|||BF_C

USTOMER|C00009||BF_TIME|2013.03|||BF_CUSTOMER|C99999||BF_TIME|2013.01|||BF_CUST

OMER|C99999||BF_TIME|2013.02|||BF_CUSTOMER|C99999||BF_TIME|2013.03

3.4 DataManager Package

In this step, we will create a data manager package to execute the script logic we created in a previous step.

Log in to EPM Office Add-in Excel

Page 16: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 16

After logging in, click on “Data Manager” ribbon, then, click on “Organize” in the next menu, and press on “Organize Package list”.

Choose the “Company” team and right click in the right pane, then select “Add package” to add a new package.

Click on “Select” in order to choose the process chain for this package.

Select the process chain “/CPMB/ALLOCATION” in the “Business Planning and Consolidation: Script Logic” menu.

Page 17: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 17

Enter “Distribution” Package name and Description and tick “User Package” for the “Task Type”. Then, press on Add.

On the next screen you can see that the package list is successfully updated.

Go back to the specification for the Distribution Package, right click on this package and select “Modify package”.

Click “Modify Script”.

Page 18: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 18

Press on “Advanced” button.

Here, you will replace the dynamic script, so, clear all information in the right pane.

Copy the following logic script.

PROMPT(TEXT,%DISTRIBUTE_AMOUNT%,"Amount to distribute",)

PROMPT(RADIOBUTTON,%DISTRIBUTION_METHOD%,"Which distribution method?",1,{"Existing Ratios","Equal Distribution","Use Reference Data"},{"1","0","2"})

PROMPT(SELECT,%DESTINATION%,"","Specify Destination","%TIME_DIM%,%CATEGORY_DIM%,%ENTITY_DIM%,BF_PRODUCT,%CURRENCY_DIM%")

PROMPT(SELECT,%REFERENCE_DATA%,"","Specify Reference Data for distribution by reference","%CATEGORY_DIM%,%TIME_DIM%")

PROMPT(TEXT,%LOCKED_CELLS%,"Locked Cells",)

INFO(%EQU%,=)

INFO(%TAB%,;)

TASK(/CPMB/ALLOCATION_LOGIC,TAB,%TAB%)

TASK(/CPMB/ALLOCATION_LOGIC,EQU,%EQU%)

Page 19: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 19

TASK(/CPMB/ALLOCATION_LOGIC,SUSER,%USER%)

TASK(/CPMB/ALLOCATION_LOGIC,SAPPSET,%APPSET%)

TASK(/CPMB/ALLOCATION_LOGIC,SAPP,%APP%)

TASK(/CPMB/ALLOCATION_LOGIC,SELECTION,%DESTINATION%)

TASK(/CPMB/ALLOCATION_LOGIC,LOGICFILENAME,DISTRIBUTION.LGF)

TASK(/CPMB/ALLOCATION_LOGIC,REPLACEPARAM,DISTRIBUTION_METHOD%EQU%%DISTRIBUTION_METHOD%%TAB%DISTRIBUTION_AMOUNT%EQU%%DISTRIBUTE_AMOUNT%%TAB%LOCKED_CELLS%EQU%%LOCKED_CELLS%%TAB%REFERENCE_DATA%EQU%%REFERENCE_DATA% )

Then, paste it and press on the “OK” button.

Last step, press on the “Save” button.

Some Explanations on this dynamic script:

Concerning all prompts, as for the logic script, in the dynamic script of the DISTRIBUTION Package various parameters have been created:

Page 20: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 20

%DISTRIBUTE_AMOUNT%

The interest of this parameter is to define the amount to distribute.

%DISTRIBUTION_METHOD%

This parameter is used to define which type of distribution.

%LOCKED_CELLS%

This parameter is used to define all locked cells.

%REFERENCE_DATA%

This parameter is used only when the third distribution method is selected by the user. The category and Time members chosen will be used with this parameter.

%DESTINATION%

The interest of this parameter is to define the type of distribution selected into the Distribute pop up (Equal distribution, Existing distribution, Reference to other data).

In the second part of the dynamic script, has been used the INFO, and TASK instructions:

There are two INFO statements here. The parameter “EQU” is used as the splitter between parameter and value (e.g.in A=B, EQU is just “=”). The parameter “TAB” is used to separate whole parameter & value sets (e.g. for A=B;C=D, the TAB is “;”). You can see how these two variables are used in the final TASK line of this dynamic script file.

The following tasks except the last are usually used to know whish user launches the package, for which environment and model, and which logic script will be used.

The latest task allows you to save all the previous parameters.

If this package was not automatically launched by the Distribution pop up, the user should define the following information to launch the distribution:

%DISTRIBUTE_AMOUNT%

Page 21: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 21

%DISTRIBUTION_METHOD%

%DESTINATION%

Page 22: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 22

%REFERENCE_DATA%

%LOCKED_CELLS%

Page 23: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 23

3.5 Visual Basic to call DataManager Package

Asking the user to enter the long string to identify the locked cells is clearly not an elegant solution. In this solution we will describe how to use visual basic to:

(a) Allow the user to specify which cells they wish to lock by selecting the cells and clicking on a “lock”

button.

(b) Execute the Data Manager package, bypassing the prompt pop-up, and passing through the

required variables, including the locked cells.

First, we’ll create the function to lock the cells the user has selected. Note that we won’t be able to execute this code until we’ve create the custom Excel ribbon in the next section.

Page 24: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 24

This opens up the Visual Basic Editor:

Right-click on and select Insert --> Module.

Copy the Visual Basic code in the following two Appendices:

Visual Basic for Locking/ Unlocking Cells

Visual Basic for Excel Custom Ribbon

Next, we’ll create the pop-up that allows the user to specify the distribution amount, the distribution method and, in the case the user choses “reference to data”, the Category and Year of the reference data.

Page 25: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 25

Create a new Worksheet in the Workbook, entitled Data and enter the following values in cells A1:C5

These cells represent the following:

Cells A1:A3 – the possible values for the Category drop-down.

Cell A4 – the default selection for the Category drop-down.

Cells B1:B3 – the possible values for the Year drop-down

Cell B5 – the default selection for the Year drop-down.

Cells C1:C3 – the default selection for the following radiobuttons respectively:

1. Equal Distribution 2. Existing Distribution 3. Reference to other data

Back in the Visual Basic editor, right-click on the Workbook Project and select Import File.

In the pop-up, select the following file (you’ll need to save it to your hard drive first):

Page 26: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 26

The form should now be imported:

Right click on frmDistribute in the Project Explorer pane, and select View Code:

Copy and paste the code from Appendix Visual Basic Code for frmDistribute into the code for this form.

NOTE – at this point the code will not compile as we need to add additional referenced objects.

Finally, we’ll add the code that executes the Data Manager Package.

Page 27: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 27

Copy and paste the code from the following Appendices into the module:

Calculate Locked Cells String

Return range of a report

Determine if cell is locked

Return the cell context in lock format

Get the context of a report cell

Return a formatted tuple

Create answer prompt xml file

Add a StringList pair to the xml file

Add a StringList pair parent to the xml file

Add a single selection parameter to the xml file

Get the current view member for a specified dimension

3.6 Custom Excel Ribbon

It is possible to trigger some standard BPC Functions such as expand, refresh, send data, run a package … with the EPM or Data Manager ribbons.

But in some cases, the user would like to execute directly a specific task like an allocation, a copy, … without to multiply the click to find the right package in the DM ribbon, or to use some dumpy buttons.

The following part will explain how to add easily the custom Ribbon “Simulation” in order to use the break back functionality using the tools Custom UI Editor for Microsoft Office.

Firstly, you need to download and install Custom UI Editor for Microsoft Office. It is available from the link below:

http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/08/06/7293.aspx

First step, save your Input Form, click on the “EPM” ribbon, then, press on “Save my Input Forms”.

Page 28: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 28

Save your template with “.xlsm” extension, and close the file.

Start the Custom UI Editor and go to File menu and click on Open button, then, select your file.

Right-click on the file name in the left pane, and then, select “Office 2007 Custom UI Part”.

Note:

Office 2007 Custom UI Part will be recognize by Office 2007 and 2010, it is not the case for Office 2010 Custom UI Part which it is only recognize by Office 2010

Page 29: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 29

It will be added the customUI.xml part to the document.

Now, copy the code which is in the appendix in the right pane

Then, you need to validate the syntax of your custom ribbon, press on “Validate” above the script.

Page 30: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 30

The custom ribbon is successfully validated.

Then, save your file.

Go back to the EPM Office Add-in Excel to open your template, click on the

“EPM” ribbon, then, press on “Open my Input Forms”.

The “Simulation” ribbon has been added after the “Data Manager” ribbon.

Last step, save the input schedule into the server. Press on the “EPM” ribbon, click on “Save”, then, press on “Save to Server Root Folder”.

Page 31: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 31

4. APPENDICES

4.1 Visual Basic Code for Locking/ Unlocking Cells

Find below the Visual Basic code for the following three functions:

LockSelectedCells – adds the lock indicator to the currently selected cells

UnlockSelectedCells – removes the lock indicator from the currently selected cells

UnlockAllCells – removes the lock indicator form all cells in the report on the current page

Note:

The Sub functions all contain input parameter control, type IRibbonControl. This is necessary in

order for these sub functions to be called from a button in the Custom Excel ribbon control.

The lock indicator is actually implemented by setting an Icon Criteria Format Condition on the cells

in question.

Sub LockSelectedCells(control As IRibbonControl)

Application.ScreenUpdating = False

Selection.FormatConditions.AddIconSetCondition

Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority

With Selection.FormatConditions(1)

.ReverseOrder = False

.ShowIconOnly = False

.IconSet = ActiveWorkbook.IconSets(xl4RedToBlack)

End With

With Selection.FormatConditions(1).IconCriteria(2)

.Type = xlConditionValueNumber

.Value = -100000000000000#

.Operator = 7

End With

With Selection.FormatConditions(1).IconCriteria(3)

.Type = xlConditionValueNumber

.Value = -10000000000000#

.Operator = 7

End With

With Selection.FormatConditions(1).IconCriteria(4)

.Type = xlConditionValueNumber

.Value = -1000000000000#

.Operator = 7

End With

Application.ScreenUpdating = True

End Sub

Sub UnlockSelectedCells(control As IRibbonControl)

Selection.FormatConditions.Delete

Page 32: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 32

End Sub

Sub UnlockAllCells(control As IRibbonControl)

Cells.FormatConditions.Delete

End Sub

4.2 Other Visual Basic Code for Excel Custom Ribbon buttons

Find below the Visual Basic code for the following sub functions:

SubmitData_Click – this submits all data in the input schedule

Refresh_Click – this refreshes the data in the current input schedule

ViewStatus_Click – this opens the Data Manager Package Status pop-up

Note:

The Sub functions all contain input parameter control, type IRibbonControl. This is necessary in

order for these sub functions to be called from a button in the Custom Excel ribbon control.

Sub SubmitData_Click(control As IRibbonControl)

'This sub will submit the data in the worksheet to the server

Dim EPMObj As FPMXLClient.EPMAddInAutomation

Set EPMObj = New EPMAddInAutomation

'submit the data to the server

EPMObj.SaveAndRefreshWorksheetData

'clean up code

Set EPMObj = Nothing

End Sub

Sub Refresh_Click(control As IRibbonControl)

'This sub will refresh the worksheet

Dim EPMObj As FPMXLClient.EPMAddInAutomation

Set EPMObj = New EPMAddInAutomation

'refresh the worksheet

EPMObj.RefreshActiveSheet

'clean up code

Set EPMObj = Nothing

End Sub

Sub ViewStatus_Click(control As IRibbonControl)

'This sub will run the specified package

Dim EPMObj As FPMXLClient.EPMAddInAutomation

Set EPMObj = New EPMAddInAutomation

'this will open the Data Manager dialog window

'EPMObj.DataManagerOpenRunPackageDialog

'This code will run the package

Page 33: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 33

EPMObj.DataManagerOpenViewStatusDialog

'clean up code

Set EPMObj = Nothing

End Sub

4.3 Visual Basic Code for frmDistribute

Public rngTarget As Range

Private Sub Frame1_Click()

End Sub

Private Sub CommandButton1_Click()

frmDistribute.Hide

End Sub

Private Sub CommandButton2_Click()

frmDistribute.Hide

' performDistribution rngTarget, frmDistribute.txtSourceValue.Value

Dim strDistributionMethod As String

If OptionButton1.Value = True Then

strDistributionMethod = "0"

ElseIf OptionButton2.Value = True Then

strDistributionMethod = "1"

Else

strDistributionMethod = "2"

End If

' Create the Answer Prompt file

createAnswerPromptXML txtSourceValue.Text, _

strDistributionMethod, _

strLockedCells(), _

strMemberCV("BF_CATEGORY"), _

strMemberCV("BF_COUNTRY"), _

strMemberCV("BF_PRODUCT"), _

"LC", _

strMemberCV("BF_TIME"), _

ComboBoxCategory, _

ComboBoxYear

Dim pkgPackageInfo As ADMPackage

Set pkgPackageInfo = New ADMPackage

With pkgPackageInfo

.Filename = "ZDEMO_DISTRIBUTION_WITH_R"

.GroupId = "Sales Planning"

Page 34: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 34

.PackageDesc = "Distribution with reference data"

.PackageId = "Distribution with reference data"

.PackageType = "Process Chain"

.TeamId = ""

.UserGroup = "0001"

End With

Dim dmaDMautomation As EPMAddInDMAutomation

Set dmaDMautomation = New EPMAddInDMAutomation

dmaDMautomation.RunPackage pkgPackageInfo, "C:\DistributionAnswerPrompt.txt"

End Sub

Private Sub OptionButton1_Click()

Worksheets("Data").Range("case").Value = "1"

End Sub

Private Sub OptionButton2_Click()

Worksheets("Data").Range("case").Value = "2"

End Sub

Private Sub OptionButton3_Click()

Worksheets("Data").Range("case").Value = "3"

End Sub

4.4 Visual Basic to calculate locked cells string

This code loops through all cells in the report and, when it finds a cell that is locked, it adds its context information to the return string. The format for a single locked cell is:

<dimension 1>|<member 1>||<dimension 2>|<member x>

To pass back multiple locked cells, these tuples are separated by |||, e.g.

<dimension 1>|<member 1>||<dimension 2>|<member x>|||<dimension 1>|<member 2>||<dimension 2>|<member y>

Public Function strLockedCells() As String

' Loop through each cell in the range contain the report data

Dim rngCell As Range

For Each rngCell In rngReport

' If the cell is locked, add context to the return string

If isCellLocked(rngCell) = True Then

If strLockedCells = "" Then

strLockedCells = strCellContext(rngCell)

Page 35: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 35

Else

strLockedCells = strLockedCells & "|||" & strCellContext(rngCell)

End If

End If

Next

' Can't send back null to the DM Package as the script logic will error.

' Send back "[NONE]" identifier instead

If strLockedCells = "" Then

strLockedCells = "[NONE]"

End If

End Function

4.5 Visual Basic to return range of a report

This function returns a range object defining the report output.

Public Function rngReport() As Range

' EPM tools

Dim objEPMtools As EPMAddInAutomation

Set objEPMtools = New EPMAddInAutomation

Dim strLowerRight As String

strLowerRight = objEPMtools.GetDataBottomRightCell(ActiveSheet, "000")

Dim strUpperLeft As String

strUpperLeft = objEPMtools.GetDataTopLeftCell(ActiveSheet, "000")

Set rngReport = ActiveSheet.Range(strUpperLeft & ":" & strLowerRight)

End Function

4.6 Visual Basic to determine if cell is “locked”

This function returns a Boolean indicating when a cell is locked or not. It determines this by interrogating the format conditions and determining whether there are any.

Private Function isCellLocked(rngCell As Range) As Boolean

If rngCell.FormatConditions.Count = 0 Then

isCellLocked = False

Else

isCellLocked = True

End If

End Function

Page 36: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 36

4.7 Visual Basic to return the cell context in lock format

This function, when passed a cell reference) returns the cell context in terms of the CUSTOMER and TIME specific to that cell:

Public Function strCellContext(rngCell As Range) As String

Dim strCustomerCode As String

strCustomerCode = strContextSpecifiedDimension(rngCell, "BF_CUSTOMER")

If strCustomerCode <> "" Then

strCellContext = strTupleDM("BF_CUSTOMER", strCustomerCode)

End If

Dim strTimeCode As String

strTimeCode = strContextSpecifiedDimension(rngCell, "BF_TIME")

If strCellContext = "" Then

strCellContext = strTupleDM("BF_TIME", strTimeCode)

Else

strCellContext = strCellContext & "||" & strTupleDM("BF_TIME", strTimeCode)

End If

End Function

4.8 Visual Basic to get the context of a report cell

When passed a cell reference (type Range) and the name of a dimension, this function returns the dimension member of that cell’s context (assuming that the dimension in question is defined in the rows or columns).

Public Function strContextSpecifiedDimension(rngCell As Range, strDimension) As String

Dim objEPMtools As EPMAddInAutomation

Set objEPMtools = New EPMAddInAutomation

Dim strConnectionString As String

strConnectionString = objEPMtools.GetActiveConnection(ActiveSheet)

' Get the Nth row of the specified cell

Dim lngRowOffset As Long

lngRowOffset = rngCell(0, 0).Row - rngReport(0, 0).Row

' Get the Nth column of the specified cell

Dim lngColumnOffset As Long

lngColumnOffset = rngCell(0, 0).Column - rngReport(0, 0).Column

' Get the row axis members

Dim strRowAxisMembers() As String

strRowAxisMembers = objEPMtools.GetRowAxisMembers(ActiveSheet, "000")

Page 37: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 37

' Get the number of dimensions in the row axis

Dim lngRowAxisDimensionCount As Long

lngRowAxisDimensionCount = objEPMtools.GetRowAxisDimensionCount(ActiveSheet, "000")

' Get all of the context specifications for the row of the specified cell

For i = 0 To lngRowAxisDimensionCount - 1

strMember = strRowAxisMembers(lngRowOffset * lngRowAxisDimensionCount + i)

If objEPMtools.GetMemberDimension(strConnectionString, strMember) = strDimension Then

strContextSpecifiedDimension = objEPMtools.GetPropertyValue(strConnectionString, strMember, "ID")

End If

Next

' Get the Column axis members

Dim strColumnAxisMembers() As String

strColumnAxisMembers = objEPMtools.GetColumnAxisMembers(ActiveSheet, "000")

' Get the number of dimensions in the row axis

Dim lngColumnAxisDimensionCount As Long

lngColumnAxisDimensionCount = objEPMtools.GetColumnAxisDimensionCount(ActiveSheet, "000")

If strContextSpecifiedDimension = "" Then

For i = 0 To lngColumnAxisDimensionCount - 1

strMember = strColumnAxisMembers(lngColumnOffset * lngColumnAxisDimensionCount + i)

If objEPMtools.GetMemberDimension(strConnectionString, strMember) = strDimension Then

strContextSpecifiedDimension = objEPMtools.GetPropertyValue(strConnectionString, strMember, "ID")

End If

Next

End If

End Function

4.9 Visual Basic to return a formatted tuple

Private Function strTupleDM(strDimension As String, strMember As String) As String

strTupleDM = strDimension & "|" & strMember

End Function

4.10 Visual Basic to create answer prompt xml file

Public Sub createAnswerPromptXML(strDistributeAmount As String, _

strDistributionMethod As String, _

strLockedCells As String, _

strDestinationCategory As String, _

strDestinationCountry As String, _

strDestinationProduct As String, _

strDestinationCurrency As String, _

strDestinationTime As String, _

strReferenceCategory As String, _

strReferenceTime As String)

Dim objDOM As DOMDocument

Dim objRootElem As IXMLDOMElement

Dim objMemberRel As IXMLDOMAttribute

Page 38: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 38

Set objDOM = New DOMDocument

' Set the processing instruction

Dim objProcessingInstruction As IXMLDOMProcessingInstruction

Set objProcessingInstruction = objDOM.createProcessingInstruction("xml", " version='1.0' encoding='utf-16'")

objDOM.appendChild objProcessingInstruction

' Creates root element

Set objRootElem = objDOM.createElement("ArrayOfAnswerPromptPersistingFormat")

objDOM.appendChild objRootElem

' XSI Attribute

Set objMemberRel = objDOM.createAttribute("xmlns:xsi")

objMemberRel.NodeValue = "http://www.w3.org/2001/XMLSchema-instance"

objRootElem.setAttributeNode objMemberRel

' XSD Attribute

Set objMemberRel = objDOM.createAttribute("xmlns:xsd")

objMemberRel.NodeValue = "http://www.w3.org/2001/XMLSchema"

objRootElem.setAttributeNode objMemberRel

' Add the Distribute Amaount parameter

addSingleSelectionParameterToXML "%DISTRIBUTE_AMOUNT%", _

strDistributeAmount, _

objRootElem, _

objDOM

' Add the Distribute Method parameter

addSingleSelectionParameterToXML "%DISTRIBUTION_METHOD%", _

strDistributionMethod, _

objRootElem, _

objDOM

' Create a variable/value pair node for Destination

Dim objDestinationElement As IXMLDOMElement

Set objDestinationElement = getStringListPairParent("%DESTINATION%", _

objRootElem, _

objDOM)

' DESTINATION - BF_CATEGORY

addStringListPair "BF_CATEGORY", _

strDestinationCategory, _

objDestinationElement, _

objDOM

' DESTINATION - BF_COUNTRY

addStringListPair "BF_COUNTRY", _

strDestinationCountry, _

objDestinationElement, _

Page 39: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 39

objDOM

' DESTINATION - BF_PRODUCT

addStringListPair "BF_PRODUCT", _

strDestinationProduct, _

objDestinationElement, _

objDOM

' DESTINATION - BF_RPTCURRENCY

addStringListPair "BF_RPTCURRENCY", _

strDestinationCurrency, _

objDestinationElement, _

objDOM

' DESTINATION - BF_TIME

addStringListPair "BF_TIME", _

strDestinationTime, _

objDestinationElement, _

objDOM

' Create a variable/value pair node for Reference Data

Dim objRefDataElement As IXMLDOMElement

Set objRefDataElement = getStringListPairParent("%REFERENCE_DATA%", _

objRootElem, _

objDOM)

' REFERENCE_DATA - BF_CATEGORY

addStringListPair "BF_CATEGORY", _

strReferenceCategory, _

objRefDataElement, _

objDOM

' REFERENCE_DATA - BF_TIME

addStringListPair "BF_TIME", _

strReferenceTime, _

objRefDataElement, _

objDOM

' Add the Locked Cells parameter

addSingleSelectionParameterToXML "%LOCKED_CELLS%", _

strLockedCells, _

objRootElem, _

objDOM

' Now we need to re-open it and add the text at the beginng

Dim fso As FileSystemObject

Set fso = New FileSystemObject

Dim stream As TextStream

Set stream = fso.OpenTextFile("C:\DistributionAnswerPrompt.txt", ForWriting)

Page 40: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 40

stream.WriteLine "Distribution with reference data{param_separator}" & objDOM.XML

stream.Close

End Sub

4.11 Visual Basic to add a StringList pair to the xml file

Public Function addStringListPair(strVariableName As String, _

strValue As String, _

objParent As IXMLDOMElement, _

objDOM As DOMDocument)

' Create the "StringListPair" node

Dim objStringListPairElement As IXMLDOMElement

Set objStringListPairElement = objDOM.createElement("StringListPair")

objParent.appendChild objStringListPairElement

' Create the "Str" element containing the variable name

Dim objStrElement As IXMLDOMElement

Set objStrElement = objDOM.createElement("str")

objStringListPairElement.appendChild objStrElement

objStrElement.Text = strVariableName

' Create the "lst" element

Dim objLstElement As IXMLDOMElement

Set objLstElement = objDOM.createElement("lst")

objStringListPairElement.appendChild objLstElement

' Create the "string" element containing the variable value

Dim objStringElement As IXMLDOMElement

Set objStringElement = objDOM.createElement("string")

objLstElement.appendChild objStringElement

objStringElement.Text = strValue

End Function

4.12 Visual Basic to add a StringList pair parent to the xml file

Public Function getStringListPairParent(strVariableName As String, _

objParent As IXMLDOMElement, _

objDOM As DOMDocument) As IXMLDOMElement

' Create the "AnswerPromptPersistingFormat" node

Dim objAnswerPromptPersistingFormatElement As IXMLDOMElement

Set objAnswerPromptPersistingFormatElement = objDOM.createElement("AnswerPromptPersistingFormat")

objParent.appendChild objAnswerPromptPersistingFormatElement

' Create the "_ap" node

Dim objApElement As IXMLDOMElement

Set objApElement = objDOM.createElement("_ap")

objAnswerPromptPersistingFormatElement.appendChild objApElement

' Create the parameter name element

Page 41: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 41

Dim objParameterElement As IXMLDOMElement

Set objParameterElement = objDOM.createElement("Name")

objApElement.appendChild objParameterElement

objParameterElement.Text = strVariableName

' Create the values element

Dim objValuesElement As IXMLDOMElement

Set objValuesElement = objDOM.createElement("Values")

objApElement.appendChild objValuesElement

' Create the "_apc" node

Set getStringListPairParent = objDOM.createElement("_apc")

objAnswerPromptPersistingFormatElement.appendChild getStringListPairParent

End Function

4.13 Visual Basic to add a single selection parameter to the xml file

Public Function addSingleSelectionParameterToXML(strVariableName As String, _

strValue As String, _

objParent As IXMLDOMElement, _

objDOM As DOMDocument)

' Create the "AnswerPromptPersistingFormat" node

Dim objAnswerPromptPersistingFormatElement As IXMLDOMElement

Set objAnswerPromptPersistingFormatElement = objDOM.createElement("AnswerPromptPersistingFormat")

objParent.appendChild objAnswerPromptPersistingFormatElement

' Create the "_ap" node

Dim objApElement As IXMLDOMElement

Set objApElement = objDOM.createElement("_ap")

objAnswerPromptPersistingFormatElement.appendChild objApElement

' Create the parameter name element

Dim objParameterElement As IXMLDOMElement

Set objParameterElement = objDOM.createElement("Name")

objApElement.appendChild objParameterElement

objParameterElement.Text = strVariableName

' Create the values element

Dim objValuesElement As IXMLDOMElement

Set objValuesElement = objDOM.createElement("Values")

objApElement.appendChild objValuesElement

' Create the string element with the value passed to the parameter

Dim objStringElement As IXMLDOMElement

Set objStringElement = objDOM.createElement("string")

objValuesElement.appendChild objStringElement

objStringElement.Text = strValue

4.14 Visual Basic to get the current view member for a specified dimension

End Function

Page 42: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 42

Public Function strMemberCV(strDimension As String) As String

Dim epmTools As EPMAddInAutomation

Set epmTools = New EPMAddInAutomation

Dim strConnectionString As String

strConnectionString = epmTools.GetActiveConnection(ActiveSheet)

Dim strMember As String

strMemberCV = epmTools.GetPropertyValue(strConnectionString, epmTools.GetContextMember(strConnectionString, strDimension),

"ID")

End Function

4.15 Simulation Ribbon

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">

<ribbon>

<tabs>

<tab id="customTab" label="Simulation" insertAfterMso="View">

<group id="GrpRefresh" label="Refresh Data">

<button id="BtnRefresh" label="Refresh Data" imageMso="SyncNow" size="large" onAction="Refresh_Click" />

</group>

<group id="GrpSave" label="Save Data">

<button id="BtnSave" label="Save Data" imageMso="FileSave" size="large" onAction="SubmitData_Click" />

</group>

<group id="Grpdm" label="Data Manager">

<button id="BtnViewStatus" label="View Status" imageMso="Info" size="large" onAction="ViewStatus_click" />

</group>

<group id="GrpLockunlock" label="Lock/Unlock">

Page 43: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 43

<menu id="BtnLockunlock" label="Lock/Unlock" imageMso="Lock" size="large">

<button id="MbtnLockMenu" label="Lock Selection" imageMso="PersonaStatusBusy" onAction="LockSelectedCells" />

<button id="MbtnUnlockMenu" label="Unlock Selection" imageMso="PersonaStatusOnline" onAction="UnlockSelectedCells" />

<button id="MbtnUnlockALLMenu" label="Unlock All" imageMso="PersonaStatusOnline" onAction="UnlockAllCells" />

</menu>

<button id="MbtnLock" label="Lock Selection" imageMso="PersonaStatusBusy" onAction="LockSelectedCells" />

<button id="MbtnUnlock" label="Unlock Selection" imageMso="PersonaStatusOnline" onAction="UnlockSelectedCells" />

<button id="MbtnUnlockALL" label="Unlock All" imageMso="PersonaStatusOnline" onAction="UnlockAllCells" />

</group>

</tab>

</tabs>

</ribbon>

</customUI>

Page 44: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 44

Related Content

Enterprise Performance Management Community

Financial Excellence Community

Page 45: How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation.pdf

How to Perform Distributions that Respect Locked Cells in SAP Business Planning and Consolidation

SAP COMMUNITY NETWORK scn.sap.com

© 2012 SAP AG 45

Copyright

© Copyright 2012 SAP AG. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.

Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries.

Oracle is a registered trademark of Oracle Corporation.

UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.

Java is a registered trademark of Oracle Corporation.

JavaScript is a registered trademark of Oracle Corporation, used under license for technology invented and implemented by Netscape.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.

Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.

All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.