how to migrate bpc 7.x badis to bpc 10

38
SAP How-to Guide Database & Technology SAP Business Planning and Consolidation How To… Migrate BPC 7.x BADIs to BPC 10 Applicable Releases: SAP Business Planning and Consolidation 10.0, version for SAP NetWeaver, SP06 and higher. SAP Business Planning and Consolidation 7.5, version for SAP NetWeaver, SP04 and higher. Version 1.0 April 2013

Upload: shubhranshu-patra

Post on 25-Oct-2015

547 views

Category:

Documents


23 download

DESCRIPTION

BPC 7.x equivalent in BPC 10

TRANSCRIPT

Page 1: How To Migrate BPC 7.x BADIs to BPC 10

SAP How-to Guide

Database & Technology

SAP Business Planning and Consolidation

How To… Migrate BPC 7.x BADIs to BPC 10

Applicable Releases:

SAP Business Planning and Consolidation 10.0, version for SAP

NetWeaver, SP06 and higher.

SAP Business Planning and Consolidation 7.5, version for SAP NetWeaver,

SP04 and higher.

Version 1.0

April 2013

Page 2: How To Migrate BPC 7.x BADIs to BPC 10

© Copyright 2013 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 Sun Microsystems, Inc.

JavaScript is a registered trademark of Sun Microsystems, Inc., used

under license for technology invented and implemented by Netscape.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP

BusinessObjects Explorer, StreamWork, 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 Software Ltd. Business Objects is an SAP company.

Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere,

and other Sybase products and services mentioned herein as well as their

respective logos are trademarks or registered trademarks of Sybase, Inc.

Sybase 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.

The information in this document is proprietary to SAP. No part of this

document may be reproduced, copied, or transmitted in any form or for

any purpose without the express prior written permission of SAP AG.

This document is a preliminary version and not subject to your license

agreement or any other agreement with SAP. This document contains

only intended strategies, developments, and functionalities of the SAP®

product and is not intended to be binding upon SAP to any particular

course of business, product strategy, and/or development. Please note

that this document is subject to change and may be changed by SAP at

any time without notice.

SAP assumes no responsibility for errors or omissions in this document.

SAP does not warrant the accuracy or completeness of the information,

text, graphics, links, or other items contained within this material. This

document is provided without a warranty of any kind, either express or

implied, including but not limited to the implied warranties of

merchantability, fitness for a particular purpose, or non-infringement.

SAP shall have no liability for damages of any kind including without

limitation direct, special, indirect, or consequential damages that may

result from the use of these materials. This limitation shall not apply in

cases of intent or gross negligence.

The statutory liability for personal injury and defective products is not

affected. SAP has no control over the information that you may access

through the use of hot links contained in these materials and does not

endorse your use of third-party Web pages nor provide any warranty

whatsoever relating to third-party Web pages.

SAP ‚How-to‛ Guides are intended to simplify the product implement-

tation. While specific product features and procedures typically are

explained in a practical business context, it is not implied that those

features and procedures are the only approach in solving a specific

business problem using SAP NetWeaver. Should you wish to receive

additional information, clarification or support, please refer to SAP

Consulting.

Any software coding and/or code lines / strings (‚Code‛) included in this

documentation are only examples and are not intended to be used in a

productive system environment. The Code is only intended better explain

and visualize the syntax and phrasing rules of certain coding. SAP does

not warrant the correctness and completeness of the Code given herein,

and SAP shall not be liable for errors or damages caused by the usage of

the Code, except if such damages were caused by SAP intentionally or

grossly negligent.

Disclaimer

Some components of this product are based on Java™. Any code change

in these components may cause unpredictable and severe malfunctions

and is therefore expressively prohibited, as is any decompilation of these

components.

Any Java™ Source Code delivered with this product is only to be used by

SAP’s Support Services and may not be modified or altered in any way.

Page 3: How To Migrate BPC 7.x BADIs to BPC 10

Document History

Document Version Description

1.00 First official release of this guide

Page 4: How To Migrate BPC 7.x BADIs to BPC 10

Typographic Conventions

Type Style Description

Example Text Words or characters quoted

from the screen. These

include field names, screen

titles, pushbuttons labels,

menu names, menu paths,

and menu options.

Cross-references to other

documentation

Example text Emphasized words or

phrases in body text, graphic

titles, and table titles

Example text File and directory names and

their paths, messages,

names of variables and

parameters, source text, and

names of installation,

upgrade and database tools.

Example text User entry texts. These are

words or characters that you

enter in the system exactly

as they appear in the

documentation.

<Example

text>

Variable user entry. Angle

brackets indicate that you

replace these words and

characters with appropriate

entries to make entries in the

system.

EXAMPLE TEXT Keys on the keyboard, for

example, F2 or ENTER.

Icons

Icon Description

Caution

Note or Important

Example

Recommendation or Tip

Page 5: How To Migrate BPC 7.x BADIs to BPC 10

Table of Contents

1. Business Scenario .................................................................................................................1

2. Background Information .......................................................................................................1

2.1 More Information on the BAdI Framework ..................................................................... 1

3. Prerequisites ......................................................................................................................... 2

4. Step-by-Step Procedure ...................................................................................................... 3

4.1 Available BAdIs in BPC 10.0 ............................................................................................ 3

4.2 API changes between BPC 7.x and BPC 10.0 ................................................................ 4

4.2.1 A note on the BPC RESTful framework ............................................................ 4

4.2.2 Master Data Reading and Writing ..................................................................... 4

4.2.3 Transaction Data Reading and Writing ............................................................. 7

4.3 Best Practice Recommendations for writing BAdIs ..................................................... 9

4.3.1 Use CL_UJK_LOGGER to write the log. ............................................................ 9

4.3.2 Fast Looping vs Slow Looping ........................................................................... 9

4.3.3 Fast Table Access vs Slow Table Access ....................................................... 10

4.3.4 Avoid MOVE-CORRESPONDING ...................................................................... 11

4.3.5 Use UJKT to analyze performance and identify bottlenecks ........................ 11

4.3.6 Use standard NetWeaver tracing techniques .................................................12

4.3.7 Other useful tips .................................................................................................13

5. Appendix ............................................................................................................................. 14

A. Interface Mapping Table ................................................................................................ 14

B. Example: Basic Reading and Writing ............................................................................ 19

C. Example: Get Application MetaData ............................................................................ 23

D. Example: Process Dimensions and Save Members ................................................... 25

E. Example: Read Transaction Data via RSDRI ............................................................... 28

F. Example: Write Transaction Data via RSDRI ............................................................... 30

Page 6: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 1

1. Business Scenario

In this guide, we will demonstrate how to migrate your BPC 7.x BAdIs to BPC 10 or BPC on HANA.

Additionally, we will give a few examples of some best practices and recommendations when

writing your BAdIs.

2. Background Information

BPC has introduced a series of BAdis that allow for enhancing the functionality of BPC. However

due to the open flexibility of coding in ABAP, there is no limitation or strict guidance for consultants

or developers to follow. Consequently, customers may find that the overall performance of Script

Logic and BPC in general can be impacted if improper coding techniques or mistakes are made.

Based on multiple project experiences, an average of 20% performance improvement can be

expected just by simply refining poorly performing ABAP code. In addition to providing information

on how to migrate your BAdIs to the latest BPC version, this guide also attempts to address some

of the most common mistakes and techniques used in BAdI coding, and provides several examples

of how you can make the most out of your custom code. Please note that system tuning is not in

the scope of this document.

2.1 More Information on the BAdI Framework

SAP Business Add-Ins (BAdIs) are arguably one of the most important technologies used to adapt

SAP software to specific requirements. As of Release 7.0 of the SAP NetWeaver Application Server

ABAP, BAdIs are part of the Enhancement Framework, where they represent explicit enhancement

options. BAdIs are the basis for Object Plug-Ins that can enhance the functions in ABAP programs

without having to make core software modifications. As such, BAdI calls can be integrated into

customer applications (like BusinessObjects Planning and Consolidation, version for SAP

NetWeaver for example) to allow enhanced customization of standard application functionality.

This guide describes guidelines for migrating a BPC 7.x BAdI to BPC 10.0. The Step-By-Step

section will outline the key focus points for a successful migration, as well as introduce a few Best

Practice and Recommendations for writing BAdI code itself. The Appendix section contains a

mapping table of BPC 7.x APIs to BPC 10.0 as well as some example code. This code is only meant

as an example and it may not match the exact needs of your own particular Business Scenario – it

is only intended to guide you in the creation/modification of your own BAdI Implementation.

For more detailed documentation of the BAdI Framework, please refer to the SAP Help Site for

BAdIs (see Section 3 – Additional Documentation).

Page 7: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 2

3. Prerequisites

Required/recommended expertise or prior knowledge

SAP BusinessObjects Planning and Consolidation 10, version for SAP NetWeaver

BPC NetWeaver Script Logic

BPC NetWeaver BAdI Framework

ABAP programming skills

Access to SAP NetWeaver transaction codes: SE20, SE19, SE37, SE80, SE24

Relevant SAP Notes:

Note 1634922 – BPC 10.0 NW Collective Note for Performance Improvement

Note 1657612 – Enable shared memory

Note 1657623 – SAP Buffer Tuning for BPC 10NW

Note 1689814 – Stabilize InfoCube's technical name in the modeling process

Note 1461749 – E2E Root Cause Analysis for SBOP PC (BPC)

Note 1734706 – BPC 10.0 NW on HANA (HANABPC) Collective Note

Note 1676242 – Installing HANABPC 800 on SAP NW 730

Additional Documentation:

Other EPM How-To Guides

http://wiki.sdn.sap.com/wiki/display/BPX/Enterprise+Performance+Management+

%28EPM%29+How-to+Guides

SAP Help Library – Business Add Ins (BAdI)

http://help.sap.com/saphelp_nw73/helpdata/en/8f/f2e540f8648431e10000000a1

550b0/frameset.htm

SAP Help Library – BPC NetWeaver Script Logic

http://help.sap.com/saphelp_bpc10_nw/helpdata/en/a6/69182aed2c4df78e3f7b9d

586735ac/frameset.htm

BPC 10 and BPC 10 on HANA Performance Guide –

https://documents.wdf.sap.corp/share/proxy/alfresco/api/node/content/workspa

ce/SpacesStore/9d07efb6-da71-4206-b402-

e4828708adf1/BPC%20Performance%20on%20customer%20data.pdf

Parallelizing BPC 10.0 Script Logic using RUNLOGIC_PH

https://scn.sap.com/docs/DOC-35152

RESTful web API wiki page

https://en.wikipedia.org/wiki/Representational_state_transfer#RESTful_web_APIs

Page 8: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 3

4. Step-by-Step Procedure

4.1 Available BAdIs in BPC 10.0

The following table is a list of the available BAdIs in BPC 10.0

BPC Module BAdI Name Description

BPF BADI_UJ_BPF_REVIEW_LOGIC

BAdI for Review Logic of BPF Step

Region.

BPF BADI_UJ_BPF_REVIEW_VALIDATION

BPC: BAdI for Checking if User is

Allowed to Review BPF Step Region.

BPF BADI_UJ_BPF_SUBMIT_LOGIC

BPC: BAdI for submitting Logic of

BPF Step Region to SUBMITTED

status.

Data Manager BADI_UJD_RETRACT

BAdI for Data Manager Retract

Data Manager BADI_UJD_ROUTINE

BAdI for Data Manager Routine

Journal BADI_UJJ_CALCULATED_AMOUNT

BAdI for adding calculated amounts

on journal save

Modeling BADI_UJ_PARAM_CHANGE

BPC: BAdI for Appset/Application

Parameter Change

Query BADI_UJ_SQE_POST_PROCESS

BPC: BAdI for post-processing of

query logic

Script Logic BADI_UJ_CUSTOM_LOGIC

BPC: BAdI for Script Logic

Security UJE_DIM_PROCESSED_BADI

BAdI for DAP update when

dimension is processed

Validation BADI_UJ_VALIDATION_RULE_LOGIC

Validation logic before write back

Work Status BADI_UJW_STATE_CHANGE

BAdI for changing work status

Work Status UJW_LOCKOUT_SCHEDULE_BADI BAdI for data locking

Write Back BADI_UJR_WRITE_BACK

BAdI for pre-processing of write

back

Page 9: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 4

4.2 API changes between BPC 7.x and BPC 10.0

In BPC 10.0, the Script Logic BAdI *definition* is compatible with BPC 7.x, which means the BAdI

definition itself doesn’t need to be recreated. However, the source code located inside the actual

BAdI might need to be adjusted due to changes in the BPC Application Programming Interface

between 7.x and 10.0. For instance, if you wrote code in your BPC 7.x BAdI which used a

deprecated BPC API, then this BAdI would not work correctly in BPC 10.0 and would need to be

adjusted accordingly.

4.2.1 A note on the BPC RESTful framework

The BPC 10.0 Front End (both the EPM Add-In and the Web Admin Client) communicate with the

BPC 10.0 Back End (NetWeaver BW Server) by directly leveraging the NetWeaver Web Application

Server (Internet Communication Framework) and RESTful services. It is important to note that

the .NET layer was removed in BPC 10.0 by using these RESTful services. Due to this major

architectural change, all UJ*_API* remote function modules (used in the old BPC 7.x .NET

communication layer) were deprecated in BPC 10.0. In order to keep backwards compatibility, you

might still see some of them in the system, but please be aware that these remote function

modules aren’t being used anymore. You can find all the new RESTful services and interfaces used

in BPC 10.0 within the UJX* ABAP Packages. Though it is not recommended to modify or use

RESTful classes directly, they can be a very good entry point for debugging. For more information

on how to debug using a REST entry point, see the following blog:

http://scn.sap.com/people/daniel.settanni/blog/2011/07/13/debugging-bpc-10-for-netweaver

Note that Data Manager is an exceptional case. By default, data manager packages run in

asynchronous (or background) mode. Since we cannot debug a background process directly, we

must change some variables in the debugger at runtime in order to force the data manager process

to run in the foreground. (The blog describes how to do this in the section ‚Debugging Data

Manager Packages‛). For more background information about the REST framework and standard

practices, please see the Prerequisites section for a useful wiki link.

4.2.2 Master Data Reading and Writing

UJA is the ABAP Package that contains all the modeling and metadata related interfaces. In BPC

10.0 however, the UJA ABAP Package has been mostly redefined. Almost all of the previous BPC

7.x UJA* interfaces have been deprecated.

Note

See Appendix A for a mapping table of BPC 7.x and BPC 10.0 interfaces.

In BPC 10.0, the modeling functionality is driven by a class called CL_UJA_BPC_ADMIN_FACTORY.

This class is the main entry point for all modeling related operations. Because it is a dynamic entry

point meant to handle multiple modeling operations, it normally takes several method calls to finish

one single operation.

Here for simplicity, we suggest using an alternate interface from class CL_UJK_MODEL.

CL_UJK_MODEL is a class delivered since BPC 7.X and the interface is relatively unchanged when

comparing ADMIN APIs. The benefit of using the CL_UJK_MODEL class is that it provides you most

of the basic operations with a single method call.

Page 10: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 5

For example, if you need to read master data from a certain dimension, by using the factory class,

you have to write the following code:

call method cl_uja_bpc_admin_factory=>get_masterdata_query

exporting

i_appset_id = lo_context->d_appset_id

i_application_id = lo_context->d_appl_id

i_dimension_id = l_dim

receiving

ro_result = lo_md_query.

call method lo_md_query->select_all_attr

exporting

if_inc_slt = abap_true

if_inc_txt = abap_true.

lo_md_query->set_sel_hier( lt_hier_list ).

lo_md_query->set_sel( lt_sel ).

lo_md_query->df_secure_reading = abap_true.

call method cl_uja_bpc_admin_factory=>get_masterdata_reader

exporting

i_appset_id = lo_context->d_appset_id

i_application_id = lo_context->d_appl_id

i_dimension_id = l_dim

receiving

ro_return = lo_md_reader.

call method lo_md_reader->read

exporting

io_read_opt = lo_md_query

importing

er_data = lr_data.

However, if you are using CL_UJK_MODEL, the code is as simple as the following:

CALL METHOD cl_ujk_model=>get_member_list

EXPORTING

i_appset_id = l_appset

i_appl_id = l_appl

i_dim_name = l_dim

if_sort = abap_false

if_ret_hashtab = abap_false

* if_only_base =

it_sel = lt_sel

* if_allow_empty = ABAP_FALSE

IMPORTING

et_member = lt_member.

Page 11: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 6

The following table shows some useful methods contained in the CL_UJK_MODEL class:

Method Name Description

CHECK_ATTR_EXIST

Check if the dimension property exists or not

CHECK_DIM_EXIST

Check if the dimension exists in the model or not

CHECK_DIM_SECURED

Check if the dimension is a secured dimension

CHECK_MEMBER_EXIST

Check if the members exist in the given dimension

CREATE_STRUCTURE

Create a dynamic internal table with the given dimensions as

columns

GET_APPL_LIST

Return the model list from a given environment.

GET_APPL_PARAM

Return the global/environmental/model parameter values from a

given application name

GET_CHILDREN

Get the children members from a given parent member of a given

dimension. You can expect 3 different return types by specifying

‚ALL‛(children member from all levels), ‚DEP‛(children members

from one level lower than the parent), ‚BAS‛(base members only)

GET_DIM_BY_TYPE

Return the dimension name of a given dimension type:

( A, C, E, T, I, G, S )

GET_DIM_LIST

Return the dimension list of a given model

GET_MD_PRO

Return property values by giving a dimension and property name

GET_MEMBER_LIST

Return dimension member list by given conditions

GET_MEMBER_PRO_VALUE

Return the value of a given dimension member’s property

GET_SECURED_DIM

Return secured dimensions from a model

GET_STORAGE_TYPE

Return the storage type of a model

GET_STRUCTURE

Return a dynamic table structure with all the dimensions’ name as

columns.

shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
Page 12: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 7

4.2.3 Transaction Data Reading and Writing In BPC 7.x, the Query or Read logic is defined in the ABAP Package UJQ, while the Write logic is

defined in the ABAP Package UJR. In BPC 10.0, although you can still find the UJQ and UJR

Packages, the interfaces have been deprecated. Instead, they have all been redesigned into the

UJO Package.

Tip

In Appendix B, you will find an example of ABAP code using the new UJO query and write interface.

Another good alternative approach for reading and writing data is to use

CL_UJK_QUERY=>QUERY() and CL_UJK_WRITE=>WRITE().

CL_UJK_QUERY=>QUERY() will let the BPC Shared Query Engine automatically judge which type of

query( HANA/MDX/RSDRI ) to use. The basic rule for which type to use is as follows:

For BPC on HANA, if there is neither a member formula nor a parent node, the query will be executed via RSDRI; if there is no member formula but there is a parent node, the query will be executed via HANA TREX; as of the publication of this guide, if there is a member formula, the query will be executed via BW MDX.

Note

HANA MDX will be introduced into BPC (BPC on HANA platform only) as a new type of query in the near future. With HANA MDX support, some member formulas can be pushed to the HANA MDX engine itself (greatly improving member formula performance). This is a promising feature, and it might even become best practice in the future, but until it is available we don’t recommend heavy use of the BW MDX engine for performance reasons.

For BPC 10.0 classic, if there is a member formula or a parent node, the query will be executed via BW MDX; otherwise it will be executed via RSDRI.

CL_UJK_WRITE=>WRITE() will always use a delta setting and let the write back engine of BPC

calculate the delta values. This means that whatever value you send will be the full value (you don’t

write deltas values using this method, only the final or full value).

In BPC 7.x, a common way of invoking the query engine is as follows:

CREATE OBJECT lo_sqe

EXPORTING

i_appset_id = i_appset_id

i_appl_id = i_appl_id.

CALL METHOD lo_sqe->if_ujq_sqe~run_axis_query

EXPORTING

it_axis = lt_axis

IT_FORMULA = IT_FORMULA

if_check_member_failed = abap_false

IMPORTING

et_data = et_data.

shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
Page 13: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 8

While in BPC 10.0, the code to invoke the query engine looks as follows:

CALL METHOD cl_ujo_query_factory=>get_query_adapter

EXPORTING

i_appset_id = i_appset_id

i_appl_id = i_appl_id

i_keydate = cl_ujk_model=>g_keydate

RECEIVING

adapter = lo_sqe.

CALL METHOD lo_sqe->run_axis_query_symm

EXPORTING

it_axis = lt_axis

* IT_SLICER =

it_formula = lt_ujo_formulas

* I_TABLETYPE =

* I_KEYDATE =

* I_DYN_HIER = ABAP_FALSE

* I_DHCELL =

* I_PASSBY_SECURITY = ABAP_FALSE

IMPORTING

et_data = et_data.

Tip

Though the method is called ‚axis query‛, the internal engine is smart enough to choose which type of query to use. For example, if the selection is all base members, the RSDRI query type will be used automatically.

Page 14: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 9

4.3 Best Practice Recommendations for writing BAdIs The following is a summary of some best practices and recommendations when writing effective

BAdI code. After each Recommendation icon we will show some sample code to highlight

the suggestion. Please note that we are only providing a summary which has been gathered by

various BPC implementation project experiences and this section is in no way intended to cover all

Best Practices for writing BAdIs.

4.3.1 For Script Logic BAdIs, use CL_UJK_LOGGER for logs

All logs that are attached by CL_UJK_LOGGER=>LOG will be printed out to the formula log. Putting

the following line of code in your BAdI will submit a log ‚l_log‛ to the formula log:

cl_ujk_logger=>log( i_object = l_log ).

4.3.2 Fast Looping vs Slow Looping

In the Script Logic BAdI signature of the EXECUTE method, there is an importing parameter called

CT_DATA. This parameter is defined as a standard table and it is delivered with all dimensions

(including the MEASURES) as columns in ascending alphabetical order. The last column in this

table is SIGNEDDATA. Most of the time, the Script Logic BAdI will be executing operations on this

table. Efficient and quick access to this table is very important. Here we show several examples of

Fast Looping vs Slow Looping. Before the loop sample code, we define some variables as follows:

data: lr_rec TYPE REF TO data.

FIELD-SYMBOLS:

<ls_rec> TYPE any,

<l_account> TYPE any.

Recommendation

Try to use ASSIGN COMPONENT before the LOOP instead of ASSIGN COMPONENT inside the LOOP. Also, try to use LOOP INTO instead of LOOP ASSIGNING

* case 1. use ASSIGN outside of the loop

CREATE DATA lr_rec LIKE LINE OF ct_data.

ASSIGN lr_rec->* to <ls_rec>.

ASSIGN COMPONENT 'ACCOUNT' of STRUCTURE <ls_rec> to <l_account>.

LOOP AT ct_data INTO <ls_rec>.

if <l_account> eq 'ACCPAY'.

* your logic

ELSE.

* your logic

ENDIF.

ENDLOOP.

Recommendation

When using ASSIGN COMPONENT, try to use ASSIGN COMPONENT <number> instead of ASSIGN COMPONENT <component name>

* case 2. use ASSIGN <number>

LOOP AT ct_data ASSIGNING <ls_rec>.

* Because the order of columns for CT_DATA is always static and ascending

* we know in advance which column is which dimension.

shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
Page 15: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 10

* In below case, ACCOUNT is the first dimension

ASSIGN COMPONENT 1 of STRUCTURE <ls_rec> to <l_account>.

if <l_account> eq 'ACCPAY'.

* your logic

ELSE.

* your logic

ENDIF.

ENDLOOP.

Important Recommendation

Try to use a dynamic where clause when looping at the table. If defined correctly this can drastically reduce the number of loop attempts. This new feature is delivered in NW 730

* case 3. dynamic conditions

DATA l_cond TYPE string VALUE 'ACCOUNT = ''ACCPAY'''.

LOOP AT ct_data ASSIGNING <ls_rec> WHERE (l_cond).

* your logic

ENDLOOP.

4.3.3 Fast Table Access vs Slow Table Access

Recommendation

Try to use READ FROM WITH TABLE KEY instead of READ FROM TABLE WITH KEY. Using the table key will result in much faster reads. Using a different key than the table key is slower.

* case 4. Read a static hashed table

DATA: lt_cv TYPE ujk_t_cv,

ls_cv TYPE ujk_s_cv.

READ TABLE lt_cv WITH TABLE KEY dim_upper_case = 'ACCOUNT' INTO ls_cv.

Recommendation

Try to READ from a Hashed table or Sorted table instead of a Standard table. In general reading hash tables using table keys is the fastest way; reading a sorted table is not as fast as reading a hash table, but it is still faster than reading a standard table. We should always try to leverage this approach. Notice that looping on a hashed table is no slower than looping on a standard table. But be advised that a hashed table consumes more memory. So try to be efficient in your use of hashed tables. Below is an example of copying CT_DATA to a hashed table and reading from it.

* case 5. copy CT_DATA to a hashed table and read

DATA:

l_time_cond TYPE string,

lr_key TYPE REF TO data,

lr_hashtable TYPE REF TO data.

FIELD-SYMBOLS:

<lht_data> TYPE HASHED TABLE,

<ls_key> TYPE any,

<l_signeddata> TYPE any,

<l_time> TYPE any.

shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
shpatra
Highlight
Page 16: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 11

CALL METHOD cl_ujk_model=>get_structure

EXPORTING

* i_appset_id =

* i_appl_id =

i_type = 'H'

* it_dim =

if_with_measure = abap_true

* if_tech_name =

* if_with_signeddata = ABAP_TRUE

RECEIVING

rr_data = lr_hashtable.

ASSIGN lr_hashtable->* TO <lht_data>.

<lht_data> = ct_data. "copy CT_DATA to hash table

* Create the record data reference and the template for TIME field

CREATE DATA lr_rec LIKE LINE OF ct_data.

ASSIGN lr_rec->* TO <ls_rec>.

ASSIGN COMPONENT 'TIME' OF STRUCTURE <ls_rec> TO <l_time>.

* Create the key data reference for hashed table and the template for SIGNE

DDATA field

CREATE DATA lr_key LIKE LINE OF <lht_data>.

ASSIGN lr_key->* TO <ls_key>.

ASSIGN COMPONENT 'SIGNEDDATA' OF STRUCTURE <ls_key> TO <l_signeddata>.

* Looping on 2013.JAN, and read from 2012.DEC

l_time_cond = 'TIME = ''2013.JAN'''.

LOOP AT ct_data INTO <ls_rec> WHERE (l_time_cond).

<l_time> = '2012.DEC'.

READ TABLE <lht_data> FROM <ls_rec> INTO <ls_key>. "SIGNEDDATA is autom

atically assigned

WRITE / '2012.DEC data: '.

4.3.4 Avoid MOVE-CORRESPONDING

MOVE-CORRESPONDING will compare each field between two structures which is relatively slow.

So it’s better to use ‘=’ directly if two structures already have the same columns in the same order.

4.3.5 Use UJKT to analyze performance and identify bottlenecks Transaction UJKT is a very useful tool to debug the execution of Script Logic. Once you know the exact script that triggers the BAdI and the scoping, you can directly run it in UJKT.

shpatra
Highlight
shpatra
Highlight
Page 17: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 12

4.3.6 Use standard NetWeaver tracing techniques

There are many ways to trace activities within NetWeaver. If you find that you cannot identify the

bottleneck using transaction UJKT and simple debugging, it is possible to set up a trace on the

server. For more information about Standard NetWeaver Performance Traces you can refer to the

following help site:

http://help.sap.com/saphelp_nw73/helpdata/en/47/cc212b3fa5296fe10000000a42189b/conte

nt.htm?frameset=/en/ba/104e0763ce4615a384c98f05c33385/frameset.htm

You can also leverage transaction SE30 which is a very powerful tool to find bottlenecks from a NW

system. Besides the ability to directly run programs and transactions, it also allows you trace any

transaction on the server.

In the following screenshot we highlight the option of setting up a trace ‚Schedule‛ on the UJKT

Transaction:

With this option, you can effectively trace any BPC User’s incoming session.

Page 18: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 13

4.3.7 Other useful tips There are two default parameters in the Script Logic BAdI call. By default they are set to ‘ON’. If the

QUERY/WRITE is not necessary, you can switch them off to improve performance.

QUERY ON/OFF

WRITE ON/OFF

Sample:

*START_BADI TEST

QUERY=ON //the BAdi will trigger automatic query.

WRITE=OFF //the BAdi will NOT write automatically.

*END_BAIDLOOP AT ct_data INTO <ls_rec> WHERE (l_time_cond).

There is a Model level parameter called SCRIPT_LOGIC_DETAIL_LOG which is used to control

whether detailed transaction data entries should be shown in the BPC Data Manager log. By default

this parameter is set to ‘ON’. If you want to switch it off, you can maintain it in transaction SPRO by

setting it to ‘OFF’. This can be very helpful for example, if the BAdI is generating millions of

transaction data records.

shpatra
Highlight
shpatra
Highlight
Page 19: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 14

5. Appendix

A. Interface Mapping Table Interface in BPC 7X Method in BPC 7X Interface in BPC10 Method in BPC10

IF_UJ_MODEL

CREATE_MD_DATA_R

EF

IF_UJA_MEMBER_MANAGE

R CREATE_DATA_REF

IF_UJ_MODEL GET_DIM_TECHNAME

IF_UJA_DIMENSION_MANA

GER GET

IF_UJ_MODEL GET_LOG_LEVEL

IF_UJ_MODEL GET_AUDIT_SETTING IF_UJU_AUDIT GET_AUDACTSET

IF_UJ_MODEL

GET_DIM_DATA_BY_T

YPE

IF_UJA_DIMENSION_MANA

GER GET

IF_UJ_MODEL GET_APPSET_DATA IF_UJA_APPSET_MANAGER GET

IF_UJ_MODEL GET_DIM_DATA

IF_UJA_DIMENSION_MANA

GER GET

IF_UJ_MODEL GET_APPL_DATA

IF_UJA_APPLICATION_MAN

AGER GET

IF_UJ_MODEL GET_DIM_BY_TYPE IF_UJA_APPSET_MANAGER GET_DIMENSIONS

IF_UJA_APPLICATION_

DATA

GET_APPLICATION_IN

FO

IF_UJA_APPLICATION_MAN

AGER GET

IF_UJA_APPSET_DATA GET_APPSET_INFO IF_UJA_APPSET_MANAGER GET

IF_UJA_DIM_DATA GET_INFO

IF_UJA_DIMENSION_MANA

GER GET

IF_UJA_DIM_DATA GET_MD_READER CL_UJA_ADMIN_FACTORY

GET_MASTERDATA_RE

ADER

IF_UJ_MODEL

CREATE_TX_DATA_RE

F

IF_UJA_APPLICATION_MAN

AGER CREATE_DATA_REF

IF_UJA_APPLICATION_

DATA GET_DIM_LIST

IF_UJA_APPLICATION_MAN

AGER GET

IF_UJA_APPLICATION_

DATA GET_PARAM_VALUE

IF_UJA_APPLICATION_MAN

AGER

IF_UJA_APPSET_DATA GET_DIM_LIST IF_UJA_APPSET_MANAGER GET_DIMENSIONS

IF_UJA_DIM_DATA WRITE_MBR_DATA

IF_UJA_MEMBER_MANAGE

R SAVE

IF_UJA_DIM_DATA IS_LONG_ATTR

IF_UJA_DIM_DATA READ_MD2XML Obsolete

IF_UJA_DIM_DATA UPDATE_HIER IF_UJA_HIER_MANAGER

Page 20: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 15

IF_UJA_DIM_DATA GET_DIM_VERSION

IF_UJA_DIMENSION_MANA

GER GET

IF_UJA_DIM_DATA VALIDATE_MEMBER

IF_UJA_MEMBER_MANAGE

R VALIDATE

IF_UJA_DIM_DATA WRITE_MBR_TXT

IF_UJA_MEMBER_MANAGE

R SAVE then PROCESS

IF_UJA_DIM_DATA

READ_BASE_MBR_DA

TA Obsolete

IF_UJA_DIM_DATA VALIDATE_MBR_TXT

IF_UJA_MEMBER_MANAGE

R VALIDATE

IF_UJA_DIM_DATA GET_MD_HANDLER

IF_UJA_DIM_DATA GET_ODBO_DETAIL

IF_UJA_DIM_DATA CREATE_HIER IF_UJA_HIER_MANAGER CREATE

IF_UJA_DIM_DATA REMOVE_HIER IF_UJA_HIER_MANAGER DELETE

IF_UJA_DIM_DATA WRITE_HIER_DATA IF_UJA_HIER_MANAGER WRITE_DATA

IF_UJ_MODEL GET_DIMS_BY_TYPE IF_UJA_APPSET_MANAGER GET_DIMENSIONS

IF_UJA_DIM_DATA CREATE_DATA_REF

IF_UJA_MEMBER_MANAGE

R CREATE_DATA_REF

IF_UJA_DIM_DATA READ_MBR_DATA IF_UJA_MD_READER READ

IF_UJA_DIM_DATA GET_HIER_OF_MBR IF_UJA_HIER_MANAGER GET_HIER_OF_MBR

IF_UJA_DIM_DATA PROCESS_MEMBER

IF_UJA_MEMBER_MANAGE

R PROCESS

IF_UJA_APPLICATION_

DATA CREATE_DATA_REF

IF_UJA_APPLICATION_MAN

AGER CREATE_DATA_REF

IF_UJA_APPSET_DATA GET_APPL_LIST IF_UJA_APPSET_MANAGER GET_APPLICATIONS

IF_UJA_DIM_DATA GET_TECHNAME

IF_UJA_DIMENSION_MANA

GER GET

IF_UJA_DIM_DATA HAS_HIER

IF_UJA_DIMENSION_MANA

GER GET

IF_UJA_APPLICATION_

DATA SET_PARAMS

IF_UJA_DIM_DATA GET_MEMBER_LIST IF_UJA_MD_READER READ

IF_UJA_DIM_DATA GET_CHILDREN_MBR IF_UJA_MD_READER READ

IF_UJA_APPL_COMP CAN_MODIFY No Change, it is kept

IF_UJA_APPL_COMP CAN_DELETE No Change, it is kept

IF_UJA_APPL_COMP CREATE No Change, it is kept

IF_UJA_APPL_COMP COPY No Change, it is kept

IF_UJA_APPL_COMP MODIFY No Change, it is kept

Page 21: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 16

IF_UJA_APPL_COMP DELETE No Change, it is kept

IF_UJA_APPL_COMP GET_TYPE No Change, it is kept

IF_UJA_DIM_DATA GET_HIER_REF

CL_UJA_BPC_ADMIN_FACT

ORY

GET_HIERARCHY_READ

ER

IF_UJA_DIM_DATA GET_ATTR_LIST

IF_UJA_DIMENSION_MANA

GER GET

IF_UJA_DIM_DATA QUERY_HIER_MBR IF_UJA_MD_READER QUERY_HIER_MBR

IF_UJA_APPSET_DATA GET_PARAMS IF_UJA_APPSET_MANAGER GET_PARAMETERS

IF_UJA_APPSET_DATA GET_REQUIRED_ATTR

IF_UJA_APPSET_DATA GET_APPSET_DATA

IF_UJA_APPSET_DATA SET_PARAMS

IF_UJA_APPSET_DATA GET_TEMPLATE_VER IF_UJA_APPSET_MANAGER GET

IF_UJA_DIM_DATA GET_DEFAULT_MBR IF_UJA_MD_READER GET_DEF_MBR

IF_UJA_APPSET_DATA SET_PARAM_VALUE

IF_UJA_APPSET_DATA INC_PENTRY_VER

IF_UJA_BIZ_RULE GET_COPY_OPE No Change, it is kept

IF_UJA_BIZ_RULE GET_FXTRANS No Change, it is kept

IF_UJA_BIZ_RULE GET_VALIDATION No Change, it is kept

IF_UJA_BIZ_RULE GET_ICBOOK No Change, it is kept

IF_UJA_BIZ_RULE GET_CONSOLIDATION No Change, it is kept

IF_UJA_BIZ_RULE GET_US_ELIM No Change, it is kept

IF_UJA_BIZ_RULE GET_CALC_ACCOUNT No Change, it is kept

IF_UJA_BIZ_RULE GET_APPSET_RULES No Change, it is kept

IF_UJA_BIZ_RULE GET_APP_RULES No Change, it is kept

IF_UJA_BIZ_RULE COPY_RULE No Change, it is kept

IF_UJA_BIZ_RULE DELETE_RULE No Change, it is kept

IF_UJA_BIZ_RULE GET_RULE_DATA No Change, it is kept

IF_UJA_BIZ_RULE SET_RULE_DATA No Change, it is kept

IF_UJA_BIZ_RULE

GET_XML_RULE_DAT

A No Change, it is kept

IF_UJA_BIZ_RULE

SET_XML_RULE_DAT

A No Change, it is kept

IF_UJA_BIZ_RULE

CHECK_CORRELATIO

N No Change, it is kept

IF_UJA_BIZ_RULE

DELETE_RULE_BY_NA

ME No Change, it is kept

Page 22: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 17

IF_UJA_BIZ_RULE VALIDATE_RULE No Change, it is kept

IF_UJA_BIZ_RULE

VALIDATE_RULE_IN_T

AB No Change, it is kept

IF_UJA_BIZ_RULE

VALIDATE_RULE_IN_X

ML No Change, it is kept

IF_UJA_BIZ_RULE

GET_RULENAME_BY_

TYPE No Change, it is kept

IF_UJA_DATA_CHECK VERIFY No Change, it is kept

IF_UJA_DIM_OBSERVE

R CAN_MODIFY No Change, it is kept

IF_UJA_DIM_OBSERVE

R MODIFY No Change, it is kept

IF_UJA_DIM_OBSERVE

R CHECK_MD_CHANGE No Change, it is kept

IF_UJA_DIM_OBSERVE

R ON_MD_CHANGE No Change, it is kept

IF_UJA_HIER FREE No Change, it is kept

IF_UJA_HIER TRAVERSE_CHILDREN No Change, it is kept

IF_UJA_HIER GET_CHILDREN No Change, it is kept

IF_UJA_HIER LOAD No Change, it is kept

IF_UJA_HIER GET_PARENTS No Change, it is kept

IF_UJA_HIER GET_ALL_MEMBER No Change, it is kept

IF_UJA_HIER CHECK_MEMBER No Change, it is kept

IF_UJA_HIER CHANGE_KEY_DATE No Change, it is kept

IF_UJA_HIER FREE_CUST_DATA No Change, it is kept

IF_UJA_HIER QUERY_MEMBER No Change, it is kept

IF_UJA_HIER

CHECK_BASE_MEMBE

R No Change, it is kept

IF_UJA_HIER GET_MAX_LEVEL No Change, it is kept

IF_UJA_HIER UPDATE No Change, it is kept

IF_UJA_HIER

AGGREGATE_CHILDC

NT No Change, it is kept

IF_UJA_HIER GET_FIRST_MEMBER No Change, it is kept

IF_UJA_HIER GET_SIBLING No Change, it is kept

IF_UJA_ODBO GET_DETAIL_DATA

IF_UJA_DIM_DATA GET_HIER_LIST

IF_UJA_DIMENSION_MANA

GER GET

Page 23: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 18

IF_UJA_DIM_DATA GET_ATTR_TNAME

IF_UJA_DIMENSION_MANA

GER GET

IF_UJA_DIM_DATA GET_MBR_FORMULA IF_UJA_MD_READER GET_FORMULA

IF_UJA_DIM_DATA IS_ROOT_NODE IF_UJA_MD_READER IS_ROOT_NODE

IF_UJA_APPLICATION_

DATA GET_APPL_DIM

IF_UJA_APPLICATION_MAN

AGER GET

IF_UJA_APPLICATION_

DATA

GET_DIM_SECURE_IN

FO

IF_UJA_APPLICATION_MAN

AGER GET

IF_UJ_MODEL GET_APPL_PREFIX

IF_UJA_APPLICATION_MAN

AGER GET

IF_UJ_MODEL GET_APPSET_PREFIX IF_UJA_APPSET_MANAGER GET

IF_UJA_APPSET_DATA GET_PARAM_VALUE IF_UJA_APPSET_MANAGER GET_PARAMETERS

IF_UJA_APPLICATION_

DATA GET_PARAM_LIST

IF_UJA_APPLICATION_MAN

AGER

IF_UJA_APPLICATION_

DATA GET_ODBO_DETAIL

IF_UJA_APPLICATION_

DATA GET_ODBO_INFO

IF_UJ_MODEL GET_DIM_LIST IF_UJA_APPSET_MANAGER GET_DIMENSIONS

IF_UJ_MODEL GET_BIZ_RULES

IF_UJA_APPLICATION_

DATA GET_FORMULA

Page 24: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 19

B. Example: Basic Reading and Writing

report zbpc_read_write_example_v10.

data: l_appset_id type uj_appset_id value 'APSHELL_SAM',

l_appl_id type uj_appl_id value 'Planning',

lt_dim_list type uja_t_dim_list,

lt_axis type ujo_t_query_dim,

ls_axis type ujo_t_members,

ls_member type ujo_s_member,

lt_slicer type ujo_t_members,

lo_appl_mgr type ref to if_uja_application_manager,

lo_sqe type ref to if_ujo_query,

lr_data type ref to data.

field-symbols: <lt_query_result> type standard table.

*************************************************************************

* Test case

*************************************************************************

"axis

ls_member-dimension = 'ACCOUNT'.

ls_member-member = 'PL110'.

insert ls_member into table ls_axis.

insert ls_axis into table lt_axis.

clear ls_axis.

ls_member-dimension = 'TIME'.

ls_member-member = '2006.02'.

insert ls_member into table ls_axis.

insert ls_axis into table lt_axis.

clear ls_axis.

ls_member-dimension = 'CATEGORY'.

ls_member-member = 'Actual'.

insert ls_member into table ls_axis.

insert ls_axis into table lt_axis.

clear ls_axis.

ls_member-dimension = 'ENTITY'.

ls_member-member = 'US'.

insert ls_member into table ls_axis.

insert ls_axis into table lt_axis.

clear ls_axis.

Page 25: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 20

ls_member-dimension = 'RPTCURRENCY'.

ls_member-member = 'USD'.

insert ls_member into table ls_axis.

insert ls_axis into table lt_axis.

clear ls_axis.

ls_member-dimension = 'INTERCO'.

ls_member-member = 'I_US'.

insert ls_member into table ls_axis.

insert ls_axis into table lt_axis.

clear ls_axis.

ls_member-dimension = 'AUDITTRAIL'.

ls_member-member = 'Input'.

insert ls_member into table ls_axis.

insert ls_axis into table lt_axis.

clear ls_axis.

ls_member-dimension = 'PRODUCT'.

ls_member-member = 'ProductA'.

insert ls_member into table ls_axis.

insert ls_axis into table lt_axis.

clear ls_axis.

ls_member-dimension = 'MEASURES'.

ls_member-member = 'PERIODIC'.

insert ls_member into table ls_axis.

insert ls_axis into table lt_axis.

append 'ACCOUNT' to lt_dim_list.

append 'TIME' to lt_dim_list.

append 'CATEGORY' to lt_dim_list.

append 'ENTITY' to lt_dim_list.

append 'RPTCURRENCY' to lt_dim_list.

append 'INTERCO' to lt_dim_list.

append 'AUDITTRAIL' to lt_dim_list.

append 'PRODUCT' to lt_dim_list.

append 'MEASURES' to lt_dim_list.

*************************************************************************

* Create data ref

*************************************************************************

call method cl_uja_bpc_admin_factory=>get_application_manager

exporting

i_appset_id = l_appset_id

i_application_id = l_appl_id

Page 26: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 21

receiving

ro_return = lo_appl_mgr.

call method 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 <lt_query_result>.

*************************************************************************

* Query

*************************************************************************

call method cl_ujo_query_factory=>get_query_adapter

exporting

i_appset_id = l_appset_id

i_appl_id = l_appl_id

receiving

adapter = lo_sqe.

call method lo_sqe->run_axis_query_symm

exporting

it_axis = lt_axis

it_slicer = lt_slicer

importing

et_data = <lt_query_result>.

*************************************************************************

* write data back

*************************************************************************

DATA: lo_ujo_wb TYPE REF TO if_ujo_write_back,

ls_wb_param TYPE if_ujo_write_back=>gs_wb_param,

ls_wb_status TYPE ujo_s_wb_status,

ls_work_status TYPE ujr_s_work_status,

ls_audit TYPE ujr_s_update_audit,

lt_message TYPE uj0_t_message,

l_measure TYPE uj_dim_member.

Page 27: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 22

FIELD-SYMBOLS:

<lt_error_records> TYPE ANY TABLE.

create data lr_data like <lt_query_result>.

assign lr_data->* to <lt_error_records>.

ls_work_status-module_id = uj00_c_mod_name_dm.

ls_work_status-blockstatus = 0.

ls_audit-actcode = uju0_cs_act_code-logic_exe.

CALL METHOD cl_ujo_wb_factory=>create_write_back

RECEIVING

ro_write_back = lo_ujo_wb.

ls_wb_param = cl_ujo_wb_factory=>default_wb_param( ).

ls_wb_param-work_status = ls_work_status.

ls_wb_param-default_logic = abap_false.

ls_wb_param-update_audit = abap_true.

ls_wb_param-duplicate = abap_true.

ls_wb_param-mdata_check = abap_false.

ls_wb_param-sign_trans = abap_true.

ls_wb_param-measures_formula = l_measure.

ls_wb_param-audit_info = ls_audit.

ls_wb_param-work_status = ls_work_status.

CALL METHOD lo_ujo_wb->write_back

EXPORTING

i_appset_id = l_appset_id

i_appl_id = l_appl_id

is_wb_param = ls_wb_param

it_records = <lt_query_result>

IMPORTING

es_wb_status = ls_wb_status

et_error_records = <lt_error_records>

et_message = lt_message.

write 'Success'.

Page 28: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 23

C. Example: Get Application MetaData

REPORT ZBPC_GET_APPL_METADATA_V10.

DATA: lv_environment_id TYPE uj_appset_id VALUE 'FPS',

lv_application_id TYPE uj_appl_id VALUE 'GROSSMARGIN',

lt_dim_list TYPE uja_t_dim_list,

lo_appl_mgr TYPE REF TO if_uja_application_manager,

lo_query TYPE REF TO if_ujo_query,

lr_data TYPE REF TO data,

lt_message TYPE uj0_t_message,

ls_application TYPE uja_s_application,

ls_dimensions TYPE uja_s_dimension.

FIELD-SYMBOLS: <lt_data> TYPE STANDARD TABLE.

lo_appl_mgr = cl_uja_bpc_admin_factory=>get_application_manager(

i_appset_id = lv_environment_id

i_application_id = lv_application_id ).

CLEAR ls_application.

lo_appl_mgr->get(

EXPORTING

if_with_measures = abap_false " BPC: Generic indicator

if_summary = abap_false " BPC: Generic indicator

IMPORTING

es_application = ls_application ). " Applications table type

REFRESH lt_dim_list.

LOOP AT ls_application-dimensions INTO ls_dimensions.

APPEND ls_dimensions-dimension TO lt_dim_list.

ENDLOOP.

* Create internal table structure based on this

* applications dimension list

lo_appl_mgr->create_data_ref(

EXPORTING

i_data_type = 'T' " H=Hash, T=Standard Table, S=Structure, O=Sorted Table.

it_dim_name = lt_dim_list

if_tech_name = abap_false

if_signeddata = abap_true

Page 29: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 24

IMPORTING

er_data = lr_data ).

ASSIGN lr_data->* TO <lt_data>.

* Write out details.

WRITE:/ 'Environment:', ls_application-appset_id,

/ 'Model(Application):', ls_application-application_id,

/ 'Description:', ls_application-description(30),

/ 'Application Type:', ls_application-application_type,

/ 'InfoCube Name:', ls_application-infocube.

skip 1.

WRITE:/ 'Dimension List:'.

LOOP AT ls_application-dimensions INTO ls_dimensions.

WRITE:/ 'Dimension:', ls_dimensions-dimension,

'Description:', ls_dimensions-description(30),

'Dimension Type:', ls_dimensions-dim_type.

ENDLOOP.

Page 30: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 25

D. Example: Process Dimensions and Save Members

REPORT zbpc_process_dim_mbr_v10.

DATA: ls_message TYPE uj0_s_message,

lt_messages TYPE uj0_t_message,

l_success TYPE uj_flg,

l_appset_id TYPE uj_appset_id VALUE 'ENV_TEST',

l_dimension_id TYPE uj_dim_name VALUE 'PRODUCT',

lo_member_mgr TYPE REF TO if_uja_member_manager,

lo_dimension TYPE REF TO if_uja_dimension_manager,

lo_master_data_store TYPE REF TO if_ujam_master_data_store,

lo_context TYPE REF TO if_uj_context,

ls_dimension TYPE uja_s_dimension,

lt_errors TYPE uja_t_members_error,

lr_members TYPE REF TO data,

lr_data TYPE REF TO data.

FIELD-SYMBOLS:

<lt_member_data> TYPE STANDARD TABLE,

<ls_member_data> TYPE any,

<lv_field> TYPE any.

TRY.

lo_context = cl_uj_context=>get_cur_context( ).

cl_uj_context=>set_cur_context(

i_appset_id = l_appset_id

i_module_name = lo_context->d_calling_module

is_user = lo_context->ds_user

).

lo_dimension = cl_uja_bpc_admin_factory=>get_dimension_manager(

i_appset_id = l_appset_id

i_dimension_id = l_dimension_id

).

lo_dimension->get(

EXPORTING

if_with_hier_maxlevel = abap_false

IMPORTING

Page 31: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 26

es_dimension = ls_dimension

).

CREATE OBJECT lo_master_data_store TYPE cl_ujam_master_data_store.

* creating masterdata table

lr_members = lo_master_data_store->get_table_buffer( ls_dimension ).

ASSIGN lr_members->* TO <lt_member_data>.

* Add members to <LT_MEMBER_DATA>, these are the member that will be saved.

CREATE DATA lr_data LIKE LINE OF <lt_member_data>.

ASSIGN lr_data->* TO <ls_member_data>.

* Fill each field, such as ID, and EVDESCRIPTION, update other fields here as well as

* any properties that need to be updated.

ASSIGN COMPONENT 'ID' OF STRUCTURE <ls_member_data> TO <lv_field>.

IF sy-subrc = 0.

<lv_field> = 'ProductD'.

ENDIF.

ASSIGN COMPONENT 'MBR_NAME' OF STRUCTURE <ls_member_data> TO <lv_field>.

IF sy-subrc = 0.

<lv_field> = 'ProductD'.

ENDIF.

ASSIGN COMPONENT 'EVDESCRIPTION' OF STRUCTURE <ls_member_data> TO <lv_field>.

IF sy-subrc = 0.

<lv_field> = 'Product D Update'.

ENDIF.

ASSIGN COMPONENT 'PARENTH1' OF STRUCTURE <ls_member_data> TO <lv_field>.

IF sy-subrc = 0.

<lv_field> = 'TotalProduct'.

ENDIF.

ASSIGN COMPONENT 'OBJVERS' OF STRUCTURE <ls_member_data> TO <lv_field>.

IF sy-subrc = 0.

<lv_field> = 'A'. "Version flag, should be "A" for Active

ENDIF.

ASSIGN COMPONENT 'ROWFLAG' OF STRUCTURE <ls_member_data> TO <lv_field>.

IF sy-subrc = 0.

<lv_field> = 'I'. " This is an action flag, I=Insert, M=Modify

ENDIF.

APPEND <ls_member_data> TO <lt_member_data>. " Add to the table.

* Create member manager

Page 32: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 27

lo_member_mgr = cl_uja_bpc_admin_factory=>get_member_manager(

i_appset_id = l_appset_id

i_dimension_id = l_dimension_id ).

****

* Save the members UNCOMMENT ONLY when you want to write the data!!!!!

****

* lo_member_mgr->save(

* EXPORTING

* ir_members = lr_members " List of members to save

* IMPORTING

* et_errors = lt_errors

* ).

****

* NOW PROCESS THE DIMENSION

****

DATA: ls_dimensions TYPE uja_s_dim_name,

lt_dimensions TYPE uja_t_dim_name.

CLEAR ls_dimensions. REFRESH lt_dimensions.

ls_dimensions-dimension = l_dimension_id. " Add dimensions to the list

APPEND ls_dimensions TO lt_dimensions.

lo_member_mgr->process(

EXPORTING

it_dim_list = lt_dimensions

if_set_offline = abap_false

if_validate = abap_true

IMPORTING

ef_success = l_success

et_message_lines = lt_messages ).

CATCH cx_uj_no_auth .

ENDTRY.

Page 33: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 28

E. Example: Read Transaction Data via RSDRI

REPORT ZBPC_READ_TDATA_V10.

DATA: lv_environment_id TYPE uj_appset_id VALUE 'TESTENV',

lv_application_id TYPE uj_appl_id VALUE 'TESTMODEL',

lt_dim_list TYPE uja_t_dim_list,

lo_appl_mgr TYPE REF TO if_uja_application_manager,

lo_query TYPE REF TO if_ujo_query,

lr_data TYPE REF TO data,

lt_message TYPE uj0_t_message,

ls_application type UJA_S_APPLICATION,

ls_dimensions type UJA_s_DIMENSION.

FIELD-SYMBOLS: <lt_query_result> TYPE STANDARD TABLE.

lo_appl_mgr = cl_uja_bpc_admin_factory=>get_application_manager(

i_appset_id = lv_environment_id

i_application_id = lv_application_id ).

clear ls_application.

lo_appl_mgr->GET(

exporting

IF_WITH_MEASURES = ABAP_FALSE " BPC: Generic indicator

IF_SUMMARY = ABAP_FALSE " BPC: Generic indicator

importing

ES_APPLICATION = ls_application ). " Applications table type

refresh lt_dim_list.

loop at ls_application-dimensions into ls_dimensions.

append ls_dimensions-dimension to lt_dim_list.

endloop.

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 ).

Page 34: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 29

ASSIGN lr_data->* TO <lt_query_result>.

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 " BPC: Dimension List

* it_range = " BPC: Selection condition

if_check_security = ABAP_FALSE " BPC: Generic indicator

* i_packagesize = " BPC: Size of Returned Data Package

* i_call_badi = ABAP_TRUE

* if_db_aggregate = ABAP_TRUE " BPC: Generic indicator

IMPORTING

et_data = <lt_query_result>

* e_end_of_data = " BPC: Last Data Package Yes/No

* e_split_occurred = " Result may not be completely aggregated

et_message = lt_message " BPC: Messages

* e_stats_guid = " BPC: Statistics Session

* e_cell_filted =

* CHANGING

* c_first_call = " BPC: First Call Yes/No

).

CATCH cx_ujo_read. " Exception of common read

ENDTRY.

* Show transaction data via ALV

DATA: lo_table TYPE REF TO cl_salv_table.

DATA: lo_functions TYPE REF TO cl_salv_functions.

TRY.

cl_salv_table=>factory( IMPORTING r_salv_table = lo_table

CHANGING t_table = <lt_query_result> ).

lo_functions = lo_table->get_functions( ).

lo_functions->set_all( abap_true ).

lo_table->display( ).

CATCH cx_salv_msg.

ENDTRY.

Page 35: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 30

F. Example: Write Transaction Data via RSDRI

REPORT ZBPC_WRITE_TDATA_V10.

DATA: lv_environment_id TYPE uj_appset_id VALUE 'TESTENV',

lv_application_id TYPE uj_appl_id VALUE 'TESTMODEL',

lt_dim_list type uja_t_dim_list,

lo_appl_mgr type ref to if_uja_application_manager,

lo_query type ref to if_ujo_query,

lr_data type ref to data,

ls_application type UJA_S_APPLICATION,

ls_dimensions type UJA_s_DIMENSION,

lt_message TYPE uj0_t_message.

field-symbols: <lt_data> type standard table,

<ls_data> type any,

<lv_category> type any,

<lv_entity> type any,

<lv_time> type any.

lo_appl_mgr = cl_uja_bpc_admin_factory=>get_application_manager(

i_appset_id = lv_environment_id

i_application_id = lv_application_id ).

clear ls_application.

lo_appl_mgr->GET(

exporting

IF_WITH_MEASURES = ABAP_FALSE " BPC: Generic indicator

IF_SUMMARY = ABAP_FALSE " BPC: Generic indicator

importing

ES_APPLICATION = ls_application ). " Applications table type

refresh lt_dim_list.

loop at ls_application-dimensions into ls_dimensions.

append ls_dimensions-dimension to lt_dim_list.

endloop.

lo_appl_mgr->create_data_ref(

EXPORTING

i_data_type = 'T'

it_dim_name = lt_dim_list

Page 36: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 31

if_tech_name = abap_false

if_signeddata = abap_true

IMPORTING

er_data = lr_data ).

ASSIGN lr_data->* TO <lt_data>.

**************

* PUT DATA FOR WRITE BACK INTO <LT_DATA> HERE!!!!!

***************

create data lr_data like line of <lt_data>.

assign lr_data->* to <ls_data>.

* fill each field, by assign a field symbol

ASSIGN COMPONENT 'CATEGORY' OF STRUCTURE <ls_data> to <lv_category>.

if sy-subrc = 0.

<lv_category> = 'ACTUAL'.

endif.

ASSIGN COMPONENT 'ENTITY' OF STRUCTURE <ls_data> to <lv_entity>.

if sy-subrc = 0.

<lv_entity> = 'US'.

endif.

ASSIGN COMPONENT 'TIME' OF STRUCTURE <ls_data> to <lv_time>.

if sy-subrc = 0.

<lv_time> = '2011.OCT'.

endif.

* Now add to the internal table for write back.

append <ls_data> to <lt_Data>.

* BEGIN Write Back operation

DATA: lo_ujo_wb TYPE REF TO if_ujo_write_back,

ls_wb_param TYPE if_ujo_write_back=>gs_wb_param,

ls_wb_status TYPE ujo_s_wb_status,

ls_work_status TYPE ujr_s_work_status,

ls_audit TYPE ujr_s_update_audit,

lv_measure TYPE uj_dim_member.

FIELD-SYMBOLS: <lt_error_records> TYPE ANY TABLE.

create data lr_data like <lt_data>.

assign lr_data->* to <lt_error_records>.

Page 37: How To Migrate BPC 7.x BADIs to BPC 10

How To… Migrate BPC 7.x BADIs to BPC 10

May 2013 32

ls_work_status-module_id = uj00_c_mod_name_dm.

ls_work_status-blockstatus = 0.

ls_audit-actcode = uju0_cs_act_code-logic_exe.

lo_ujo_wb = cl_ujo_wb_factory=>create_write_back( ).

ls_wb_param = cl_ujo_wb_factory=>default_wb_param( ).

ls_wb_param-work_status = ls_work_status.

ls_wb_param-default_logic = abap_false.

ls_wb_param-update_audit = abap_true.

ls_wb_param-duplicate = abap_true.

ls_wb_param-mdata_check = abap_false.

ls_wb_param-sign_trans = abap_true.

ls_wb_param-measures_formula = lv_measure.

ls_wb_param-audit_info = ls_audit.

ls_wb_param-work_status = ls_work_status.

lo_ujo_wb->write_back(

EXPORTING

i_appset_id = lv_environment_id

i_appl_id = lv_application_id

is_wb_param = ls_wb_param

it_records = <lt_data>

IMPORTING

es_wb_status = ls_wb_status

et_error_records = <lt_error_records>

et_message = lt_message ).

Page 38: How To Migrate BPC 7.x BADIs to BPC 10

www.sap.com/contactsap

www.sdn.sap.com/irj/sdn/howtoguides