Implementing BAdI's For SAP BPC - Tips & Tricks - Element61
Implementing BAdI's For SAP BPC - Tips & Tricks - Element61
Introduction
SAP Business Planning and Consolidation (SAP BPC) is available in a version for SAP
Netweaver and a version for the Microsoft platform. SAP BPC Netweaver has the advantage
that ABAP (Advanced Business Application Programming) can be used, the SAP
programming language.
Search
The SAP BPC script logic can be converted to ABAP, using the SAP BAdI (Business Add Ins)
CONTACT
functionality. BAdI is an enhancement to the standard version of the code of SAP. The
performance of BAdIs is signi cant better than SAP BPC script.
Competences
This document combines several tips & tricks that will help you creating BAdI
Customers implementations for SAP BPC.
Join us
click to enlarge
About us
Once you display the selected enhancement spot, right-click Implementations and choose
Take
Create BAdI Implementation orthe Analytics
select & AI Maturity
an existing Survey
implementation.
EN NL FR
click to enlarge
Another way to access existing BAdI coding is via transaction SE80 Object Navigator. Enter
the desired class and open the method to change it directly.
click to enlarge
Once the Enhancement Implementation is available, you need to lter the BAdI. This
guarantees that the code is only executed for the desired application set and application
(which corresponds to InfoArea and InfoCube respectively). Multiple lter combinations can
be added by clicking Create Filter Combination multiple times.
The lters are speci c for each Enhancement Spot. Below is an example of the
UJR_WRITE_BACK enhancement Spot.
click to enlarge
News
Declare Data
Academy At the beginning of the method, several constants, eld symbols, etc are declared. A
constant is a xed value, eg value AST (Account Type Asset). If this value has to be changed,
Events the change has to be done only once.
The object it_dim_obj contains the metadata of the dimensions. You can nd the InfoObject
name for each dimension and all of its attributes.
https://www.element61.be/en/resource/implementing-badis-sap-bpc-tips-tricks 2/9
4/22/2020 Implementing BAdI’s for SAP BPC - Tips & Tricks | element61
click to enlarge
click to enlarge
Search
CONTACT
Competences
click to enlarge
Customers The object uj00_cs_dim_type is de ned in the global type pool UJ00. uj00_cs_dim_type-
account can thus be replaced by uj00_cs_dim_type-entity etc for other dimensions.
News
begin of uj00_cs_dim_type,
account type uj_dim_type value 'A',
Academy
entity type uj_dim_type value 'E',
time type uj_dim_type value 'T',
Events
currency type uj_dim_type value 'R',
Suppose the attributes account type and account group are needed. The list of attributes for
Take the Analytics & AI Maturity Survey
a dimension is fetched using the function get_attr_list. The actual members are fetched via
function read_mbr_data.
Contact us
"Get attribute AccountType / Account Group
https://www.element61.be/en/resource/implementing-badis-sap-bpc-tips-tricks 3/9
4/22/2020 Implementing BAdI’s for SAP BPC - Tips & Tricks | element61
click to enlarge
The internal table ct_array is a generated object that contains all the records coming from
the BPC application. Looping over this table ct_array gives access to each record.
During the rst loop several objects are created that will capture the new, calculated
records. Object lt_tab
is a temporary object that is created at runtime with the same structure as ct_array. Then the
structure of lt_tab is assigned to the eld-symbols so the latter has a structure and it is a
table. To be able to work with one line of the table, the eld-symbols is created similarly. A
eld-symbols can be assigned to the individual eld of one line using the ASSIGN
Search COMPONENT
statement. Eg, the column account can then be accessed via .
CONTACT
Competences
IF
Now all elds are accessible via their corresponding eld-symbols. All kinds of calculations
and manipulations can be executed using these eld-symbols.
https://www.element61.be/en/resource/implementing-badis-sap-bpc-tips-tricks 4/9
4/22/2020 Implementing BAdI’s for SAP BPC - Tips & Tricks | element61
The following code retrieves the hierarchy information for entity and is also repeated for the
time component.
Data is disaggregated pro rata to existing data. So we need to look up the existing data that
corresponds to the data coming from the BPC application. This is achieved by launching a
RSDRI query, which requires a list of dimensions to be returned and the list of lters to be
applied. First step is to retrieve the cube metadata.
CLEAR ls_application.
lo_appl_mgr->get(
EXPORTING
if_with_measures = abap_false
if_summary = abap_false
IMPORTING
CONTACT
es_application = ls_application ).
If the processed line is a parent, we need to get its children to be able to distribute the data
across the children afterwards. This code has to be repeated for the time dimension.
i_level = -1
if_only_base_mbr = abap_true
IMPORTING
et_member = lt_ent_children.
DESCRIBE TABLE lt_ent_children LINES nr_ent_chil.
We prepare a range to lter on entity base members. The same range has to be expanded
for the time dimension.
We save the cube dimensions in a list and expand the range to use the same restrictions as
in BPC.
REFRESH lt_dim_list.
LOOP AT ls_application-dimensions INTO ls_dimensions.
APPEND ls_dimensions-dimension TO lt_dim_list.
ls_range-dimension = ls_dimensions-dimension.
ASSIGN COMPONENT ls_dimensions-dimension
OF STRUCTURE
TO
.
ls_range-low =
.
APPEND ls_range TO lt_range.
ENDLOOP.
https://www.element61.be/en/resource/implementing-badis-sap-bpc-tips-tricks 5/9
4/22/2020 Implementing BAdI’s for SAP BPC - Tips & Tricks | element61
lo_appl_mgr->create_data_ref(
EXPORTING
i_data_type = 'T'
it_dim_name = lt_dim_list
if_tech_name = abap_false
if_signeddata = abap_true
IMPORTING
er_data = lr_data ).
ASSIGN lr_data->* TO
.
Now we can execute the RSDRI query which retrieves the required date from the SAP BW
InfoCube and stores it in eld symbols
TRY.
lo_query = cl_ujo_query_factory=>get_query_adapter(
i_appset_id = lv_environment_id
i_appl_id = lv_application_id ).
lo_query->run_rsdri_query(
EXPORTING
it_dim_name = lt_dim_list
it_range = lt_range
if_check_security = abap_false
IMPORTING
et_data =
et_message = lt_message
).
CATCH cx_ujo_read.
ENDTRY.
click to enlarge
Conclusion
SAP BPC Netweaver can make use of ABAP, the SAP programming language. BAdI is an
enhancement to the standard version of the code of SAP. The performance of BAdIs is
signi cant better than SAP BPC script. These functionalities enable endless possibilities.
Annex
This annex contains the ABAP declarations for all elds contained in this insight.
https://www.element61.be/en/resource/implementing-badis-sap-bpc-tips-tricks 6/9
4/22/2020 Implementing BAdI’s for SAP BPC - Tips & Tricks | element61
DATA:
ls_record_r TYPE REF TO data,
lt_attr_list TYPE uja_t_attr, "Attributes info
ls_attr_list TYPE uja_s_attr,
lt_attr_name TYPE uja_t_attr_name, "Attribute names
lr_data TYPE REF TO data,
lt_tab TYPE REF TO data,
ls_account TYPE ujr_s_dim_handler, "account
lo_account TYPE REF TO if_uja_dim_data.
FIELD-SYMBOLS:
TYPE ujr_s_dim_handler,
TYPE any,
TYPE
uj_dim_member,"account member of result rec
Topic
Technology
Competence
CONTACT US
https://www.element61.be/en/resource/implementing-badis-sap-bpc-tips-tricks 7/9
4/22/2020 Implementing BAdI’s for SAP BPC - Tips & Tricks | element61
JOIN US
LEARN MORE
ELEMENTARY
BI-KIPEDIA
6
JOIN US
TEAM
CONTACT US
OUR COMPETENCES
Business Intelligence
Performance Management
Consolidation
Financial Reporting
Financial Planning & Analysis
Sales & Operations Planning
Disclosure Management
Conso Outsourcing & Interim
Data Strategy
Data Science
Advanced Analytics
Big Data
Data Management Platform
Customer Data Platform
Technologies
https://www.element61.be/en/resource/implementing-badis-sap-bpc-tips-tricks 8/9
4/22/2020 Implementing BAdI’s for SAP BPC - Tips & Tricks | element61
https://www.element61.be/en/resource/implementing-badis-sap-bpc-tips-tricks 9/9