BPC Currency Conversion

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

BPC Currency Conversion

Objectives
In SAP BPC, we use script logics to copy, calculate and write data based in selection. On

several occasions I have seen, functional consultants find it difficult to understand. In this

presentation I will cover following topics relating to BPC 10.0 NW script logic for simplification and
easy understanding.

1)Definition;

2)Functionalities

3)Syntax

4)Testing of script logics.

Definition
Script Logic

enables calculations on base-level cells that result in data stored within an application. The results
are aggregated up the dimensional hierarchy, without being re-calculated at upper levels. SAP has
provided two types of scrip logics syntax, these are

(1) SQL based syntax

(2) MDX based syntax

. I will cover in detail above syntax in more details in the next few slides.

Functionalities
The script logic;

1)Reads a specific data selection from the model.

2)Applies to it a set of user-defined formulas (stored in a logic file).

3)Derives the values.

4)Writes those values back to the application.

Results are written directly to the model as base data, and are aggregated up the dimensional
hierarchy as they are, without being recalculated at upper levels.

1)All dimension logic formulas are applied to these results.

2)This process allows you to perform calculations.

Script logic can be run in any of three ways:

1) Automatically after data is sent to the database from BPC for Excel using the

Default.LGF file.

2)After Journal data send using either Default. LGF, or if present, Journal. LGF files.
3)Through Data Manager as a batch processing event to call Script Logic formulas.

Advantages of BPC script logics

1)Model dependent calculation, not at a member level of the dimensions;

2)BPC scripts can be called from different places, for example default logic, data manager package
etc.

3)With the help BPC logics, we can perform different type of calculation with or without

calling business rules;

4)In SAP BPC script logics, we can choose desired dimensions with the help of dimension properties.

Disadvantages of BPC script logics

1) BPC script can’t handle very complex calculation processing or bigger data volume. In

case of a complex calculation, ABAP-BADI comes into the picture. We can call ABAP-BADI codes
within the script logics.

Syntax

There are two Syntax options in SAP BPC Script Logic. These are:

1)SQL based syntax

: SQL syntax gives better performance.

2)MDX based syntax.

MDX syntax is used

In record level specific calculations). Multidimensional expressions abbreviated as MDX. While


choosing script logics, we need to consider following points for performance consideration,

1.Use fewer commits’ statements;

2.While developing complex calculation, choose ABAP-BADI.

3.Scoping uses memory; hence scoping should be precise.

4.MDX syntax causes performance issues, so use SQL logics as far as possible.

5.Use limited looping to improve performance.

STRUCTURE OF SCRIPT LOGIC: Script logic structure is divided in three parts.

1)SCOPING

In this section we define the scope of data to which calculation will be applied.

2)BODY

In this section, we tell to the system what to be done I.e., perform calculation,

Transformation, Aggregation etc.

3)COMMIT
In this section we tell to section to save the calculated result to the database.*XDIM_MEMBERSET
Category = PLAN*XDIM_MEMBERSET Entity = C3000

*XDIM_MEMBERSET P_DataSrc = MANUAL

*XDIM_MEMBERSET RptCurrency = LC

SCOPING

*XDIM_MEMBERSET P_Activity = EMPL1*XDIM_MEMBERSET P_ACCT =


CE0004220*XDIM_MEMBERSET TIME = 2007.JAN*WHEN P_ACCT

*IS CE0004220

*REC (EXPRESSION = 901) BODY*ENDWHEN*COMMIT COMMIT

Script Logic can be broken down into 3 components:

•Scoping- What am I running the data on?

•Data manager scoping

•Input schedule scoping

•Scope control

•Body / Code - What do I want to do with the scoped record?

• *IIf Statements

• *REC

• [#] based MDX statements

• *WHEN / *IS / *ENDWHEN

• Allocation Logic

• Writing the records

• *COMMIT

Due to performance issue MDX syntaxes are less favourite among BPC developers. In this section l
will cover commonly used SQL based syntax;

1. *ADD / *ENDADD =

Add set of values members (i.e., accounts) to another set of values (i.e., account).

2. *INCLUDE =

With this syntax, you can include multiple Script Logic files in a script.

Included scripts carry different calculation once you execute the main script. During LGX generation,
all codes are combined into one big piece of code and executed during runtime.

3. *REC =
This statement generates a record / modifies a record that to be posted in the database. Even if it is
for the same destination cell, a source record can generate as many destination cell records. Multiple
REC statements possible between *END/*ENDWHEN statement.

Example: -*REC (FACTOR = 0.9,ACCOUNT="DISCOUNT_EXTSALES"). Which means multiply by 0.9 to


current scoped record and replace account with DISCOUNT_EXTSALES write values to
DISCOUNT_EXTSALES.

4. *XDIM_MEMBERSET =

It restricts the data, filters the

source dataset to the required dataset

for specific calculation, intended in the script logic. For each restriction using a

dimension, there can be a separate XDIM statement. Generally, it is followed by the

Dimension name & Member value/value set.

5. *XDIM_ADDMEMEBERSET =

This statement is used to add more member values to the scope of member value already defined
with the XDIM statement for conditional calculations.

6. *XDIM_FILTER =

Filters the members of the scope of that dimension. It does not filter the scope of data, rather filters
from available scope.

Example - *XDIM_FILTER ACCOUNT = [account].properties(ACCTYPE='AST'). In this case system will


select account members which contains ACCTTYPE property value as

“AST”

7. XDIM_MAXMEMBERS =

Specifies the maximum number of members that should be included in one query.

8. XDIM_PACKAGEBY =

This syntax is used for parallel processing. However, configuration needs to be done in SPRO need to
be done before using this.

9. *SELECT / *ENDSELECT =

Like any other SQL statement, this syntax helps to retrieve a list of values from the master data table
(Dimension) and store them in a defined variable. Can be written in any part of the logic and the
resultant value can be used in any part of the logic as well. Generally better to write in the beginning
of the logic structure.

10. *WHEN / *ENDWHEN =

*WHEN/*ENDWHEN can be used with property values of the

dimension; to further create conditions for data processing / transformation / modification /

manipulation, for the REC statement. Ex: *WHEN ACCOUNT *IS


“XY00001234”

. Same as SELECT/ENDSELECT statement, but this it used when different transformation is needed for
different type of field values in a record. Hence multiple *WHEN/*ENDWHEN statements possible
within a script logic. It works as a loop statement.

11. *DESTINATION_APP =

Use to make the datasets of one model available for other. It transfers the data from one model to
another. Between Dimension

“Category”

values.

12. *LOOKUP / *ENDLOOKUP =

Similar to

“*DESTINATION_APP”

but this does not transfer the data between the model, rather looks up for the required calculation.
It is acts like a

“READ”

statement in traditional ABAP. Example: While doing currency translation of a value,

it will be required to look into the EXCHANGERATES model.

13. *TMVL =

This is used to retrieve a time value after taking into consideration an offset value from a given time
period. REC(FACTOR=1.1, TIME=TMVL(12,2006.APR)). In this case the time value is 2006, Apr + 12
months = 2007,Apr.

14. *COMMIT =

Saves/stores the calculated values in the database. In case of two dependent calculations, resulting
value of the first calculation must be saved into the database with a

“*COMMIT”

statement, before its value is used in another calculation formula within the script logic.

15. *ADD_DIM =

While copying data between two models, if source model does not contain all the dimensions as the
destination model, missing dimensions in the source model can be created/added using this syntax
before data copy. Possible to use this for multiple dimensions in one statement.

16. *RENAME_DIM =

While copying data between two models, if dimension names

between the models do not match; then mismatching dimension names can be renamed to be the
same before copy process. Possible to use this for multiple dimensions in one statement.
17. *SKIP_DIM =

While copying data between two models, if the destination model does

not contain all the dimensions as the source model, some of the destination models can be

skipped from copying process using this syntax. Possible to use this for multiple dimensions in one
statement.

18. *SELECTCASE / *ENDSELETC =

This is a select statement with a CASE together to encourage conditions within. Works as IF, ELSEIF &
ENDIF statement in traditional ABAP.

19. *START_BADI / *ENDBADI =

This script helps in calling BAdIs within the script logic to

perform an endless variety of functions.

20. *RUNALLOCATION

= This syntax help execute SAP delivered allocation logic.

21. *BEGIN / *END =

These syntaxes are used with Boolean Expressions (YES / NO). Similar concept, as may have seen in
BW-BEX formulas. The individual conditions will be enclosed in parenthesis. If the condition is true,
the return value will be 1, else 0.

22. *IIF =

These syntaxes work, just as IF, ELSEIF, ENDIF statements in traditional ABAP. If the

condition satisfies, then it directs the record to undergo a calculation.

23. *FOR / *NEXT =

This syntax is used with a variable, which returns/contains multiple values. This syntax then helps to
process individual variable values, one by one. It works like FOR EACH statement in FOX formula.

24. *GET =

Retrieves the value from the memory

25. *FUNCTION / *ENDFUNCTION =

This syntax is very often used in MDX. Function is used in BPC to enhance readability.

26. *WHEN _REF_DATA =

It sets the focus to either master data or transactional data. When is set to master data, it loops
through all the master data values of the dimension. And when set to transactional data, it loops
through all transactional data, which uses the dimension/values in its scope. Without an explicit
definition, the transactional data mode is

selected by default.
Variables
Variable allows to enter values in runtime. In BPC we use two types of variables (1) user defined
variables and (2) system variables. In case of user defined variables;

• We will have variables in script, for example $PERCENT$

• Then we define variable for prompt in the data manager package, for example

%PERCENT%.

• In run time system will replace $PERCENT$ with values we are passing via %PERCENT%.

For example *XDIM_MEMBERSET TIME = $DIM_INP$ in script logic and a prompt %DIM_INP% in DM
package will prompt the user to enter a time dimension member while running that script logic. If
the user enters2009.JAN, the package will run only for January 2009. If he/she enters BAS(2009.Q1),
the package will run for Jan,Feb, Mar of 2009

System defined variables are;

1.%USER% -

Returns current Planning and Consolidation User

2.%APPSET% -

Returns current Planning and Consolidation AppSet

3.%APPLICATION% -

Returns current Planning and Consolidation Application

4.%YEAR% -

Returns current calendar year.

SAP Delivered Logics


ICDATA.LGF -

ICDATA is used to perform intercompany reconciliation activities. ICDATA must be executed with the
appropriate ICBOOKING business rules.

ICBooking.lgf -

ICBooking is used to perform intercompany reconciliation activities with difference postings.


ICBooking must be executed with the appropriate ICBOOKING business

rules.

ICElim.lgf -

ICElim is used to perform intercompany reconciliation. ICElim must be executed with the appropriate
ICElim business rules.

Validation.lgf -

Validation is used to perform validation activities define within the validation business rules.
MDXlib.lgf -

The MDXlib file provides examples of pre-delivered MDX financial functions.

System_Constants.lgf -

The system constants file is the logic file that maps your dimension names for an application to the
standard (delivered) BPC logic. For example, the file maps the name of the category dimension to the
dimension to be used as the category.

System_Library.lgf -

The System Library includes basic examples of delivered keywords and functions.

Testing and Debugging


To test and debug script , we can use program UJK_SCRIPT_LOGIC_TESTER or TransactionCode: UJKT

You might also like