0% found this document useful (0 votes)
412 views

BPC Custom Logic

Gives a Brief idea of BPC Custom Logic

Uploaded by

Shankar Goutham
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
412 views

BPC Custom Logic

Gives a Brief idea of BPC Custom Logic

Uploaded by

Shankar Goutham
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Cust om BADI s i n Sc r i pt Logi c

SAP 2009 / Page 2


1. BPC version for NetWeaver Script Logic Overview
2. Custom BADIs in Script Logic Overview
3. Create a Custom BADI
4. Testing and Debugging Custom BADIs
5. Custom BADI Example
6. References
Agenda
SAP 2008 / Page 3
BPC ver si on f or Net Weaver Sc r i pt
Logi c Over vi ew
Script Logic enables calculations on base-level cells that result in data stored within
an application. The results are aggregated up the dimensional hierarchy intact,
without being re-calculated at upper levels.
Some example of when to use a Script Logic formulas are: unit times price
calculations, foreign currency translation, allocations, and others.
Script logic can be run in any of three ways:
Automatically after data is sent to the database from BPC for Excel using the Default.lgf
file.
After J ournal data sends using either Default.lgf, or if present, J ournal.lgf files.
From Data Manager as a batch processing event to call Script Logic formulas.
SAP 2008 / Page 4
BPC ver si on f or Net Weaver Sc r i pt
Logi c Over vi ew
Sc r i pt Logi c Feat ur e Compar i son
New Features in SAP Business Planning and Consolidation (not in SAP Business
Planning and Consolidation 5.x):
Script Logic Debugging
Call Custom Logic
Obeys Concurrency Locking within SAP Business Planning and Consolidation.
Changes in SAP Business Planning and Consolidation vs. SAP Business Planning
and Consolidation 5.x:
SQL Based keywords are not supported.
Run stored procedures were replaced with native Script Logic keywords.
See class CL_UJ K_RUN_PROGRAMS for list of procedures
Minor differences in validation checking of Script Logic.
Less SAP NetWeaver BI MDX keywords are supported than Microsoft MDX.
See function module BAPI_MDPROVIDER_GET_FUNCTIONS for a list of SAP
NetWeaver BI supported MDX keywords.
SAP 2008 / Page 5
BPC ver si on f or Net Weaver Sc r i pt
Logi c Over vi ew
Sc r i pt Logi c Basi c s
All Script Logic statements are Case-Insensitive.
New to SAP Business Planning and Consolidation, all AppSet/Application/Dimension/Member
names are case-sensitive.
You will have two files for each Script logic you create.
.LGF - an ASCII file used to create/edit your logic calculations.
.LGX - the compiled logic file.
SAP 2008 / Page 6
BPC ver si on f or Net Weaver Sc r i pt
Logi c Over vi ew
Mai nt ai ni ng Sc r i pt Logi c
Accessed from SAP Business Planning and Consolidation Administration in the
Script Logic subdirectory in the hierarchy of a particular Application.
SAP 2008 / Page 7
BPC ver si on f or Net Weaver Sc r i pt
Logi c Over vi ew
Nest i ng Logi c Fi l es
Default Logic gets executed on every write-back to an application.
Use the *INCLUDE command to have one logic file call another logic file.
BPC ver si on f or Net Weaver Sc r i pt
Logi c Over vi ew
How Sc r i pt Logi c wor k s
The Logic module:
Reads a specific data selection from the application.
Applies to it a set of user-defined formulas (stored in a logic file).
Derives the values.
Writes those values back to the application.
Results are written directly to the application as base data, and are aggregated up
the dimensional hierarchy as they are, without being recalculated at upper levels.
All dimension member formulas are applied to these results.
This process allows you to perform such calculations as units times price because the
formulas are applied only to those members specified in the logic file.
BPC ver si on f or Net Weaver Sc r i pt
Logi c Over vi ew
St r uc t ur e of Sc r i pt Logi c
Logic can be broken down into 3 components
Scoping- What am I running the data on?
Data manager scoping
BPC for Excel Scoping
*XDIM_Memberset
Body/Code What do I want to do with the scoped records?
Script Logic keywords (example *WHEN / *ENDWHEN, *REC Statements)
Allocation Logic
Custom BADI
Writing the record
*Commit
BPC ver si on f or Net Weaver Sc r i pt
Logi c Over vi ew
Runni ng Sc r i pt Logi c
Advanced logic can be automatically invoked each time data is sent to the
database.
Logic contained in the Default logic file is executed immediately after data is sent and the
results can be seen in SAP Business Planning and Consolidation 5.1 right away.
Advanced logic can be run from Data Manager for batch processing of formulas.
Using Data Manager to execute Logic module formulas is useful for calculations that do
not need to be executed immediately.
For example, an administrator may decide to wait until all the data has been entered in
the local currency before generating the translated amounts in the reporting currencies.
BPC ver si on f or Net Weaver Sc r i pt
Logi c Over vi ew
Mai nt ai ni ng Sc r i pt Logi c i n t he Def aul t .LGF f i l e
All logic in DEFAULT.LGF is run after data sends.
The INCLUDE statement shown below enables currency translation to happen in real time,
rather than as a batch process.
BPC ver si on f or Net Weaver Sc r i pt
Logi c Over vi ew
Pros
Real-time - allows for real-time calculations.
Flexible - enables you to apply different formulas to different applications within an application
set (dimension logic is applied to all applications using the dimension).
Syntax options - you can use MDX, Script Logic Keywords, and Custom ABAP.
Cons
Custom maintenance
Can be too technical for certain users (for instance Custom BADI)
If not properly written can be a negative performance impact
SAP 2009 / Page 13
1. BPC version for NetWeaver Script Logic Overview
2. Custom BADIs in Script Logic Overview
3. Create a Custom BADI
4. Testing and Debugging Custom BADIs
5. Custom BADI Example
6. References
Agenda
Cust om BADI s i n Sc r i pt Logi c
Over vi ew
Usage:
*CALL_CUSTOM_LOGIC
Description
This instruction is used to call any custom ABAP programming you have written
Examples:
*XDIM_MEMBERSET ACCOUNT=CASH
*XDIM_MEMBERSET RPTCURRENCY =LC
*XDIM_MEMBERSET TIME =2006.J AN
*XDIM_MEMBERSET CATEGORY =ACTUAL
*XDIM_MEMBERSET INTCO=NON_INTERCO
*CALL_CUSTOM_LOGIC CUST_CALC_ACCT
Operation Type
Control Flow
Category
Technical
Syntax
*CALL_CUSTOM_LOGIC <BADI name>
Cust om BADI s i n Sc r i pt Logi c
Over vi ew
Usage:
*START_BADI
Description
This instruction is used to call any custom ABAP programming you have written *WITH PARAMETERS
Examples:
*XDIM_MEMBERSET ACCOUNT=CASH
*XDIM_MEMBERSET RPTCURRENCY =LC
*XDIM_MEMBERSET TIME =2006.J AN
*XDIM_MEMBERSET CATEGORY =ACTUAL
*XDIM_MEMBERSET INTCO=NON_INTERCO
*START_BADI CUST_CALC_ACCT
ACCT_FROM =10000
ACCT_TO =10001
*END_BADI
Operation Type
Control Flow
Category
Technical
Syntax
*START_BADI
<key1>=<value1>
<key2>=<value2>
*END_BADI
Optional Parameters
You can use the following optional parameters within a *START_BADI / *END_BADI
instruction:
Query - Performs the default query. Valid values are On and Off; the default is On. Set Query
to Off if you want to perform your own query.
Write - Automatically writes back the data. Valid values are On and Off; the default is On.
Example
*START_BADI TEST
QUERY=ON
WRI TE=OFF
*END_BADI
Cust om BADI s i n Sc r i pt Logi c
Over vi ew
Call Custom Logic
Can be used to call ABAP programs and parameters can be passed from the BPC Script
Logic (its like defining new key words)
Script Logic Debugging
Custom Logic can be debugged
If the BADI has a filter, then in the script logic before calling the BADI, the
customer needs to provide the filter value
NOTE: To pass parameters to the BADI, you can use the *START_BADI / *END_BADI
command
NOTE: The BADI will run on data that was filtered through the Data Manager prompts
All BPC Script Logic within BPC 7.0 Obeys Concurrency Locking
BW Transaction RSPLSE
SAP 2009 / Page 17
1. BPC version for NetWeaver Script Logic Overview
2. Custom BADIs in Script Logic Overview
3. Create a Custom BADI
4. Testing and Debugging Custom BADIs
5. Custom BADI Example
6. References
Agenda
Cr eat e a Cust om BADI
To create a BPC Script Logic Custom BADI, you must first create an Enhancement
Implementation of the Enhancement Spot: UJ _CUSTOM_LOGIC
TWO ENTRY POINTS:
(transactions SE19 and SE20)
Cr eat e a Cust om BADI
Using Transaction SE19, you can create a new Enhancement Implementation like so:
Name the new Enhancement Implementation and assign it to an ABAP Package:
Cr eat e a Cust om BADI
Using Transaction SE19, you can create a new Enhancement Implementation like so:
Assign the new
Enhancement
Implementation to
a transport (Type
Workbench
Request) to move
it through the
QA/PROD
landscape:
Cr eat e a Cust om BADI
Using Transaction SE19, the next step is to create the new BADI Implementation like so:
Define the BADI Implementation Name and the ABAP Implementation Class Name
behind the BADI
(The Implementation Class is where you code your custom logic in ABAP)
Cr eat e a Cust om BADI
Using Transaction SE19, the next step is to assign the ABAP Implementation Class to a
transport:
Assign the new
Implementation
Class to a
transport
(Workbench
Request) to
move it through
the QA/PROD
landscape:
Cr eat e a Cust om BADI
Using Transaction SE19, you have just created the starting framework for your new BADI:
This screen allows you to modify your BADI configuration
Cr eat e a Cust om BADI
Define a new KeyWord to call your newly created Script Logic Custom BADI:
The BADI Filter Val is the same as the Key Word you use inside BPC Script Logic. Using this
KeyWord with CALL_CUSTOM_LOGIC or START_BADI / END_BADI will invoke your BADI
code
The BADI Filter
Value is the Script
Logic KeyWord
Click
Here
Cr eat e a Cust om BADI
Choose your KeyWord and set the value:
NOTE: The KeyWord should represent what the Script Logic Custom BADI actually does
(ie CUST_CALC_ACCT)
Cr eat e a Cust om BADI
ACTIVATE the BADI
NOTE: This activation is only for the BADI Enhancement Implementation you must also
activate your ABAP Implementing Class (see next few slides)
Cr eat e a Cust om BADI
ACTIVATE the Implementing Class
NOTE: Once you have activated your BADI you should thereafter only have to deal with your
Implementing Class (unless you want to change the BADI properties such as the Filter Value)
1
st
Click Here
Next, Double-Click the text (or go
straight to Transaction SE24 and enter
the name of your Implementing Class)
Cr eat e a Cust om BADI
ACTIVATE the Implementing Class
NOTE: You have all the options of ABAP Object-Oriented Class Methodologies (Inheritance,
Encapsulation, Poly-Morphism, Public and Private Methods, Attributes and Types, etc)
Your Business-Specific Logic will
go inside the Execute Method
Cr eat e a Cust om BADI
You are now ready to begin coding ABAP for your Script Logic Custom BADI:
NOTE: Beginners should set a break-point inside the execute method first and see what data
will be passed to the BADI (filtering should be done in a careful and controlled manner).
SAP 2009 / Page 30
1. BPC version for NetWeaver Script Logic Overview
2. Custom BADIs in Script Logic Overview
3. Create a Custom BADI
4. Testing and Debugging Custom BADIs
5. Custom BADI Example
6. References
Agenda
Test i ng and Debuggi ng Cust om
BADI s
Program UJ K_SCRIPT_LOGIC_TESTER can be used to test and debug script logic
statements
Test i ng and Debuggi ng Cust om
BADI s
Once you hit execute on the Script Logic Tester, the Debugger should pop up at the break
point you set in the Implementing Class
CT_DATA is the table
containing the retrieved data
NOTE: it is also where you
insert new records to be
written back to the Application
SAP 2009 / Page 33
1. BPC version for NetWeaver Script Logic Overview
2. Custom BADIs in Script Logic Overview
3. Create a Custom BADI
4. Testing and Debugging Custom BADIs
5. Custom BADI Example
6. References
Agenda
Cust om BADI Si mpl e ex ampl e t o
del et e r ec or ds
methodif_uj_custom_logic~execute.
* Declarations
constants:
c_bus type stringvalue 'BUSINESS',
c_acct type stringvalue 'ACCOUNT',
c_ind type stringvalue 'INDUSTRY',
c_data type stringvalue 'SIGNEDDATA'.
data:
l_success type abap_bool,
l_log_msg type string,
l_ref type ref to data,
lines type i,
clines type string,
lo_cx_uj_null_obj type ref to cx_uj_null_obj_ref,
lo_cx_uj_static type ref to cx_uj_static_check.
field-symbols:
<lt_data> type standardtable,
<l_acct> type any,
<l_srcacct> type any,
<l_ind> type any,
<l_data> type any,
<ls_tmpline> type any,
<ls_line> type any,
<l_bus> type any.
* End Declarations
breakconnz.
cl_ujk_logger=>log( 'StartingDelete function.' ).
describe table ct_data lines lines.
clines =lines.
clear l_log_msg.
concatenate 'Read' clines 'lines for deletionin Application' p_appl_idinto l_log_msgseparatedbyspace.
cl_ujk_logger=>log( l_log_msg).
loopat ct_data assigning<ls_line>.
assigncomponent c_data of structure <ls_line>to <l_data>.
clear <l_data>.
endloop.
cl_ujk_logger=>log( 'EndingDelete function.' ).
endmethod.
Ref er enc es
For instructions about implementing an SAP Business Add-In, see the ABAP
online help at:
http://help.sap.com/saphelp_nw70/helpdata/en/32/a83942424dac04e10000000a1550b0/
content.htm.
See each of the BPC version for NetWeaver Support Packages Documentation Addendum
for new supported Script Logic keywords
SDN BLOGS
Running BPC process chains within non-BPC process chains:
https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/12929
How to Pass Parameters to Custom Logic BADI using START_BADI
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20f4252d-98ca-2b10-
e689-f85085ae2d12

You might also like