Top Banner
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2010 SAP AG 1 How to Integrate BPC NW to BI7x Technically using ABAP? Applies to: Document is applicable to all SAP BPC 7.0 NW versions. For more information, visit the Enterprise Performance Management homepage . Summary This document provides an overview of data integration between BPC NW with BI 7.0. SAP Net weaver 7.0 BI is used as the backend server to hold BPC data. Since BPC tool is used for planning and reporting purposes, it typically needs to references other BPC Application data. This guide will provide reusable FMs to access those data at ease. Prerequisite(s): (1) Foundational understanding of BPC Concepts and Terminologies (2) Basic understanding of ABAP <field-symbols> (3) Reading and appreciation of How to Pass Parameters to Custom Logic BADI using START_BADI Author: Benedict Yong Teng Xiang Company: Accenture Consulting Created on: 1 November 2010 Author Bio Benedict Yong is a Certified SAP BI Consultant with 5 years SAP experience. He holds a Bachelor of Management (Australia) and a Diploma in Business InfoTech (Singapore). Prior to his current employment at Accenture Consulting, he was with Hypercube Consulting, practicing SAP Analytics and Business Intelligence. He is situated in Singapore and is bilingual in English and Mandarin.
19

How to Integrate BPC NW to BI7x Technically - Using ABAP

Oct 26, 2014

Download

Documents

YongBenedict
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: How to Integrate BPC NW to BI7x Technically - Using ABAP

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 1

How to Integrate BPC NW to BI7x

Technically – using ABAP?

Applies to:

Document is applicable to all SAP BPC 7.0 NW versions. For more information, visit the Enterprise Performance Management homepage.

Summary

This document provides an overview of data integration between BPC NW with BI 7.0. SAP Net weaver 7.0 BI is used as the backend server to hold BPC data. Since BPC tool is used for planning and reporting purposes, it typically needs to references other BPC Application data. This guide will provide reusable FMs to access those data at ease.

Prerequisite(s):

(1) Foundational understanding of BPC Concepts and Terminologies

(2) Basic understanding of ABAP <field-symbols>

(3) Reading and appreciation of How to Pass Parameters to Custom Logic BADI using START_BADI

Author: Benedict Yong Teng Xiang

Company: Accenture Consulting

Created on: 1 November 2010

Author Bio

Benedict Yong is a Certified SAP BI Consultant with 5 years SAP experience. He holds a

Bachelor of Management (Australia) and a Diploma in Business InfoTech (Singapore). Prior to his current employment at Accenture Consulting, he was with Hypercube Consulting, practicing SAP Analytics and Business Intelligence. He is situated in Singapore and is bilingual in English and Mandarin.

Page 2: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 2

Table of Contents

Overview ............................................................................................................................................................. 3

Introduction ..................................................................................................................................................... 3

Scenario .......................................................................................................................................................... 3

Approach ......................................................................................................................................................... 3

Main Section for FM ............................................................................................................................................ 4

ZBPC_GET_ATTR_BY_DIM .......................................................................................................................... 4

ZBPC_GET_APPL_API_FOR_UJQ ............................................................................................................... 6

Main Section for Program ................................................................................................................................... 9

ZBPC_API_DRIVER ....................................................................................................................................... 9

Conclusion ........................................................................................................................................................ 12

Appendix ........................................................................................................................................................... 12

ZBPC_GET_ATTR_BY_DIM ........................................................................................................................ 12

ZBPC_GET_APPL_API_FOR_UJQ ............................................................................................................. 13

ZBPC_API_DRIVER ..................................................................................................................................... 15

Related Content ................................................................................................................................................ 18

Disclaimer and Liability Notice .......................................................................................................................... 19

Page 3: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 3

Overview

Introduction

The goal of this how-to guide is to create a set of FM that can easily access BPC Applications’ Transactional and Master Data. Hence, reducing development time, project cost and creating business value – with a methodology in place.

Scenario

One sample scenario that may be applicable is that you have a core Sales/Transaction Application that needs to read Pricing/Rate from another Application to do cross-Application computation.

Or simply, you may just want to access the Master Data of the Dimensions easily with a common approach.

Cross-Application Integration, Standardized Methodology, Reusable Function Modules are some of the desired development needs for any application platform.

Approach

The scope of this paper will only be restricted to technical level discussions.

We will be creating 2 FM and one driver program. (Do note that you may use the FM directly without going through the driver program. The program is there to just demonstrate how to use the FM)

ZBPC_GET_ATTR_BY_DIM – For Master Data Access

ZBPC_GET_APPL_API_FOR_UJQ – For Transactional Data Access

ZBPC_API_DRIVER – To Test Functionality of FM

Page 4: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 4

Main Section for FM

FM ‘ZBPC_GET_ATTR_BY_DIM’ will be used for Master Data Access.

FM ‘ZBPC_GET_APPL_API_FOR_UJQ’ will be used for Transactional Data Access.

ZBPC_GET_ATTR_BY_DIM

This FM reads from multiple BPC system tables (e.g. UJA_DIMENSION, UJA_DIM_ATTR) to gather the mapping of the field names between BPC and BI.

This FM can be used independently. It reads out an internal table that has two columns, the first column will be the dimension field and the second column will be the selected attribute field. You also have the option to just get the text in place of an attribute field by flagging ‘I_TEXT_ONLY’ = abap_true.

Typical FM 'ZBPC_GET_ATTR_BY_DIM’ can be used as below:

TYPES: BEGIN OF ty_acct_type,

col1 TYPE string,

col2 TYPE string,

END OF ty_acct_type.

TYPES: ty_t_acct_type TYPE STANDARD TABLE OF ty_acct_type.

DATA: lt_dim_acct TYPE ty_t_acct_type,

ls_dim_acct LIKE LINE OF lt_dim_acct.

DATA: lr_dim_acct TYPE REF TO data.

FIELD-SYMBOLS: <lt_acct_type> TYPE STANDARD TABLE.

CREATE DATA lr_dim_acct TYPE ty_t_acct_type.

ASSIGN lr_dim_acct->* TO <lt_acct_type>.

CALL FUNCTION 'ZBPC_GET_ATTR_BY_DIM'

EXPORTING

i_appset = 'YOUR_APPSET'

i_dim = 'P_ACCT'

i_attr = 'ACCTYPE'

IMPORTING

er_data = lr_dim_acct.

ASSIGN lr_dim_acct->* TO <lt_acct_type>.

"DO whatever you want with the data (i.e. <lt_acct_type>)

….

Page 5: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 5

Sample Output:

Page 6: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 6

ZBPC_GET_APPL_API_FOR_UJQ

This FM has to be used in-conjunction with the standard SAP FM ‘UJQ_RUN_RSDRI_QUERY’.

The rationale for doing so is that, you will not know the actual structure of the BPC equivalent InfoCubes for sure all the time. This is because during Full Optimization, the BPC InfoCubes are deleted from SAP BI and new replica InfoCube containing the migrated data are linked back to the BPC Application. Either way, we need to leverage on ABAP/4 RTTS Classes.

From a BPC perspective, Applications are permanent but InfoCubes are just data storage containers. There is a mapping table in SAP that holds the relationships between individual Application and Infocube (i.e. UJA_APPL). However, after determining that mapping between the Infocubes and the Applications through UJA_APPL, you need to get the names of the individual fields of the underlying tables that form the SAP BI Infocubes from UJA_DIMENSION. And more linkages need to be determined for further integration.

It is best that we use the standard SAP API to access the data from the BPC Application – without too much of a hassle.

cl_uj_model=>get_model( EXPORTING i_appset_id = 'YOUR_APPSET'

RECEIVING ro_model = lo_model ).

"MAKE the TABLE first

lo_model->create_tx_data_ref(

EXPORTING

i_appl_name = 'YOUR_APPLICATION'

i_type = 'T'

it_dim_name = dt_dim_list

if_tech_name = space

IMPORTING

er_data = lo_tranx_ref ).

ASSIGN lo_tranx_ref->* TO <lt_final>.

"FILL the TABLE later

CALL FUNCTION 'UJQ_RUN_RSDRI_QUERY'

EXPORTING

i_appset_id = 'YOUR_APPSET'

i_appl_id = 'YOUR_APPLICATION'

InfoCube

Characteristics

Page 7: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 7

if_check_security = abap_false

IMPORTING

et_data = <lt_final>.

"DO whatever you want with the data (i.e. <lt_final>)

….

However, the standard BPC API uses OO ABAP for processing. It might be too awkward for us who are accustomed to the old FM paradigm. So why not just create a FM to encapsulate the complexity? Pass in simple strings of requirements and get back the data required.

Typical FM ‘ZBPC_GET_APPL_API_FOR_UJQ’ should be used as below:

* MAKE the TABLE first

CALL FUNCTION 'ZBPC_GET_APPL_API_FOR_UJQ'

EXPORTING

i_appset_id = 'YOUR_APPSET'

i_appl_id = 'YOUR_APPLICATION'

if_inc_measure = abap_true

IMPORTING

er_data = lo_metadata.

ASSIGN lo_metadata->* TO <lt_final>.

* FILL the TABLE later

CALL FUNCTION 'UJQ_RUN_RSDRI_QUERY'

EXPORTING

i_appset_id = 'YOUR_APPSET'

i_appl_id = 'YOUR_APPLICATION'

it_dim_name = lt_column

if_check_security = abap_false

IMPORTING

et_data = <lt_final>.

"DO whatever you want with the data (i.e. <lt_final>)

….

In summary, there are will always be two-step in accessing data from SAP BPC NW Application using ABAP (whether through the API or through encapsulation): (1) Dynamically create an internal table that match the current Application database structure; and (2) Fill the generated table structure with actual data from BPC.

Page 8: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 8

Sample Output:

Page 9: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 9

Main Section for Program

ABAP program ‘ZBPC_API_DRIVER’ basically utilizes the mentioned APIs to demonstrate their functionalities.

Prerequisite: ensure the Application used have the following 6 Dimensions:

(1) CATEGORY, (2) P_ACCT, (3) TIME, (4) FLOW, (5) P_DATASRC, and (6) RPTCURRENCY.

As we are using <field-symbols>, short dumps will happen, if the structures do not match during runtime.

ZBPC_API_DRIVER

Typically in BPC planning, it will also be great to gain access to the Master Data. To do that, we can call the FM 'ZBPC_GET_ATTR_BY_DIM'. By using the mentioned BAdI, we will have the main structure ct_data based on the Current View Application, but we would also like to access the data of another ‘Rate’ Application for further computation. To do that, we can call the FM 'ZBPC_GET_APPL_API_FOR_UJQ' & 'UJQ_RUN_RSDRI_QUERY'.

Page 10: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 10

Here is a description of how the program flows:

Part (I) - Accessing Master Data

Get a list of the Master Data Attribute into an internal table for further processing

by -> CALL FUNCTION 'ZBPC_GET_ATTR_BY_DIM'.

Part (II) - Accessing Transactional Data

Get a list of referencing Transactional Data into an internal table for further

processing by -> CALL FUNCTION 'ZBPC_GET_APPL_API_FOR_UJQ' / CALL FUNCTION

'UJQ_RUN_RSDRI_QUERY'.

1. DECLARE a TYPE that matches the Semantic Definition of your BPC Application, in

exact name & sequence (typically using alphabetic order).

e.g.

TYPES: BEGIN OF ty_bpc_basic,

category TYPE c LENGTH 20,

flow TYPE c LENGTH 20,

p_acct TYPE c LENGTH 20,

p_datasrc TYPE c LENGTH 20,

rptcurrency TYPE c LENGTH 20,

time TYPE c LENGTH 20,

signeddata(11) TYPE p DECIMALS 7,

END OF ty_bpc_basic.

2. GET the Meta Definition of the Physical table that contain the desired BPC data by

-> CALL FUNCTION 'ZBPC_GET_APPL_API_FOR_UJQ'

3. ASSIGN the Meta Structure of the result internal table base on the returned Meta

Definition from step 2.

4. POPULATE the result internal table by -> CALL FUNCTION 'UJQ_RUN_RSDRI_QUERY'

5. LOOP AT the result internal table, use the 'ASSIGN COMPONENT' command to access

individual field values.

After the related reference data are collected – continue with business logic.

Note: This driver program is an adaptation of if_uj_custom_logic~execute. Although the code runs on SE38, it can be

ported back into SE19 BAdI implementation with some modifications.

Page 11: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 11

Sample Output:

Page 12: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 12

Conclusion

Above are some of the functionalities that I have managed to emulate. There are more. One for instance, is accessing the hierarchy grouping of the TIME dimension. So on and so forth. Most of SAP BPC NW functionalities are pretty much exposed; with an astute mind, you can probably pick into the locks of BPC. My personal advice is to explore the object class CL_UJ_MODEL & CL_UJQ_QUERY_UTIL.

The value of this paper is not just in creating a set of usable APIs, but at a more conceptual level it opens up our minds to more possibilities.

Appendix

ZBPC_GET_ATTR_BY_DIM

FUNCTION ZBPC_GET_ATTR_BY_DIM.

*"----------------------------------------------------------------------

*"*"Local Interface:

*" IMPORTING

*" REFERENCE(I_APPSET) TYPE C DEFAULT 'ZSCA_PLAN_DM'

*" REFERENCE(I_DIM) TYPE C DEFAULT 'DIM_CSTMR'

*" REFERENCE(I_ATTR) TYPE C DEFAULT 'SLSDIST'

*" REFERENCE(I_KEY_ONLY) TYPE C OPTIONAL

*" REFERENCE(I_TEXT_ONLY) TYPE C OPTIONAL

*" EXPORTING

*" REFERENCE(ER_DATA) TYPE REF TO DATA

*"----------------------------------------------------------------------

TYPE-POOLS: abap, rsd, ujr0, uj00.

TYPES: BEGIN OF ty_package,

dim TYPE string,

attr TYPE string,

END OF ty_package.

TYPES: ty_t_package TYPE STANDARD TABLE OF ty_package.

DATA: lv_select TYPE TABLE OF string.

DATA: lv_table TYPE string.

DATA: lc_cust_tech LIKE uja_dimension-tech_name,

lc_slsd_tech LIKE uja_dim_attr-tech_name.

SELECT SINGLE tech_name FROM uja_dimension

INTO lc_cust_tech

WHERE appset_id = i_appset

AND dimension = i_dim.

lv_table = lc_cust_tech.

IF ( i_text_only NE abap_true ).

REPLACE ALL OCCURRENCES OF REGEX '/CPMB/' IN lv_table WITH '/B28/M'.

REPLACE ALL OCCURRENCES OF REGEX '/CPMB/' IN lc_cust_tech WITH '/B28/S_'.

APPEND lc_cust_tech TO lv_select.

IF ( i_attr NE '').

SELECT SINGLE tech_name FROM uja_dim_attr

INTO lc_slsd_tech

WHERE appset_id = i_appset

AND dimension = i_dim

AND attribute_name = i_attr.

REPLACE ALL OCCURRENCES OF REGEX '/CPMB/' IN lc_slsd_tech WITH '/B28/S_'.

Page 13: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 13

APPEND lc_slsd_tech TO lv_select.

ENDIF.

ENDIF.

IF ( i_text_only EQ abap_true ).

REPLACE ALL OCCURRENCES OF REGEX '/CPMB/' IN lv_table WITH '/B28/T'.

REPLACE ALL OCCURRENCES OF REGEX '/CPMB/' IN lc_cust_tech WITH '/B28/S_'.

APPEND lc_cust_tech TO lv_select.

lc_slsd_tech = 'TXTLG'.

APPEND lc_slsd_tech TO lv_select.

ENDIF.

FIELD-SYMBOLS: <lt_package> TYPE STANDARD TABLE,

<ls_package> TYPE ANY.

CREATE DATA er_data TYPE ty_t_package.

ASSIGN er_data->* TO <lt_package>.

SELECT (lv_select) FROM (lv_table) INTO TABLE <lt_package>.

ENDFUNCTION.

ZBPC_GET_APPL_API_FOR_UJQ

FUNCTION zbpc_get_appl_api_for_ujq.

*"----------------------------------------------------------------------

*"*"Local Interface:

*" IMPORTING

*" REFERENCE(I_APPSET_ID) TYPE UJA_APPL-APPSET_ID

*" REFERENCE(I_APPL_ID) TYPE UJ_APPL_ID

*" REFERENCE(IT_DIM_NAME) TYPE UJA_T_DIM_LIST OPTIONAL

*" REFERENCE(IF_INC_MEASURE) TYPE UJ_FLG DEFAULT 'X'

*" EXPORTING

*" REFERENCE(ER_DATA) TYPE REF TO DATA

*"----------------------------------------------------------------------

TYPE-POOLS: abap, rsd, ujr0, uj00.

DATA: lt_dim_name TYPE uja_t_dim_list,

ls_dim_name TYPE uj_dim_name,

lt_dim TYPE uja_t_dim,

lt_appset_dim TYPE uja_t_dim,

ls_dim TYPE uja_s_dim,

ls_iobj_details TYPE bapi6108,

l_infoobject TYPE bapi6108-infoobject,

l_int TYPE i,

lt_comp TYPE abap_component_tab,

ls_comp TYPE abap_componentdescr,

lo_struct TYPE REF TO cl_abap_structdescr,

lr_data TYPE REF TO data,

ls_appl_info TYPE uja_s_appl_info,

lt_key TYPE STANDARD TABLE OF string,

ld_dim_member TYPE string VALUE 'UJ_DIM_MEMBER',

ld_signeddata TYPE string VALUE 'UJ_SDATA',

ls_view TYPE rsd_s_cube-viewtiobjnm2.

FIELD-SYMBOLS:

<ls_dim> TYPE uja_s_dim.

CONSTANTS: if_tech_name TYPE uj_flg VALUE uj00_cs_flg-false.

DATA:

lo_model TYPE REF TO if_uj_model,

lo_appl TYPE REF TO if_uja_application_data.

cl_uj_model=>get_model( EXPORTING i_appset_id = i_appset_id

Page 14: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 14

RECEIVING ro_model = lo_model ).

lo_model->get_appl_data( EXPORTING i_application_id = i_appl_id

RECEIVING ro_appl_data = lo_appl ).

lo_appl->get_dim_list( IMPORTING et_dim_name = lt_dim_name ).

SELECT d~dimension d~tech_name INTO CORRESPONDING FIELDS OF TABLE lt_appset_dim

FROM uja_dimension AS d JOIN uja_dim_appl AS a

ON d~appset_id = a~appset_id

AND d~dimension = a~dimension

WHERE a~appset_id = i_appset_id AND a~application_id = i_appl_id.

CALL METHOD lo_appl->get_application_info

EXPORTING

i_application_id = i_appset_id

IMPORTING

es_appl_info = ls_appl_info.

IF it_dim_name IS SUPPLIED AND it_dim_name IS NOT INITIAL.

CLEAR ls_dim_name.

LOOP AT it_dim_name INTO ls_dim_name.

IF ls_dim_name = ujr0_c_measure.

ls_dim-tech_name = ujr0_c_measure .

ELSE.

READ TABLE lt_appset_dim INTO ls_dim WITH KEY dimension = ls_dim_name.

ENDIF.

APPEND ls_dim TO lt_dim.

ENDLOOP.

ENDIF.

IF it_dim_name IS INITIAL AND if_tech_name = abap_false.

CLEAR ls_dim_name.

LOOP AT lt_dim_name INTO ls_dim_name.

READ TABLE lt_appset_dim INTO ls_dim WITH KEY dimension = ls_dim_name.

APPEND ls_dim TO lt_dim.

ENDLOOP.

ENDIF.

IF lt_dim IS NOT INITIAL.

LOOP AT lt_dim ASSIGNING <ls_dim>.

IF <ls_dim>-tech_name = ujr0_c_measure.

ls_comp-name = <ls_dim>-tech_name.

ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ld_dim_member ).

ELSE.

IF if_tech_name = uj00_cs_flg-true.

ls_comp-name = <ls_dim>-tech_name.

ELSE.

ls_comp-name = <ls_dim>-dimension.

ENDIF.

l_infoobject = <ls_dim>-tech_name.

CALL FUNCTION 'UJN_API_GET_IOBJ_DETAIL'

EXPORTING

i_infoobject = l_infoobject

IMPORTING

es_iobj_details = ls_iobj_details.

l_int = ls_iobj_details-intlen.

ls_comp-type = cl_abap_elemdescr=>get_c( l_int ).

ENDIF.

APPEND ls_comp-name TO lt_key.

APPEND ls_comp TO lt_comp.

ENDLOOP.

IF if_inc_measure IS NOT INITIAL.

Page 15: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 15

IF if_tech_name = uj00_cs_flg-true.

ls_comp-name = uj00_cs_iobj-keyfigure.

ELSE.

ls_comp-name = ujr0_c_keyfigure.

ENDIF.

ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ld_signeddata ).

APPEND ls_comp TO lt_comp.

ENDIF.

lo_struct = cl_abap_structdescr=>create( p_components = lt_comp

p_strict = abap_false ).

CREATE DATA lr_data TYPE HANDLE lo_struct.

ENDIF.

FIELD-SYMBOLS: <l_data> TYPE ANY.

ASSIGN lr_data->* TO <l_data>.

CREATE DATA er_data LIKE TABLE OF <l_data>.

ENDFUNCTION.

ZBPC_API_DRIVER

REPORT zbpc_api_driver.

FIELD-SYMBOLS: <ls_data> TYPE ANY.

PARAMETERS:

gc_apps TYPE uj_appset_id DEFAULT 'YOUR_APPSET',

gc_appl TYPE uj_appl_id DEFAULT 'YOUR_APPLICATION',

fil_year(4) TYPE c DEFAULT '2011'.

TYPES: BEGIN OF ty_acct_type,

col1 TYPE string,

col2 TYPE string,

END OF ty_acct_type.

TYPES: ty_t_acct_type TYPE STANDARD TABLE OF ty_acct_type.

DATA: lt_dim_acct TYPE ty_t_acct_type,

ls_dim_acct LIKE LINE OF lt_dim_acct.

DATA: lr_dim_acct TYPE REF TO data.

FIELD-SYMBOLS: <lt_acct_type> TYPE STANDARD TABLE.

CREATE DATA lr_dim_acct TYPE ty_t_acct_type.

ASSIGN lr_dim_acct->* TO <lt_acct_type>.

CALL FUNCTION 'ZBPC_GET_ATTR_BY_DIM'

EXPORTING

i_appset = gc_apps

i_dim = 'P_ACCT'

i_attr = 'ACCTYPE'

IMPORTING

er_data = lr_dim_acct.

ASSIGN lr_dim_acct->* TO <lt_acct_type>.

WRITE: / '====DISPLAY MASTERDATA===='.

data: cnt type i.

Page 16: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 16

LOOP AT <lt_acct_type> INTO ls_dim_acct.

if cnt ge 5.

exit.

endif.

APPEND ls_dim_acct TO lt_dim_acct.

WRITE: / ls_dim_acct-col1, '->', ls_dim_acct-col2.

add 1 to cnt.

ENDLOOP.

*"=============================================================

CONSTANTS:

gc_time(20) TYPE c VALUE 'TIME',

gc_acct(20) TYPE c VALUE 'P_ACCT',

gc_cate(20) TYPE c VALUE 'CATEGORY',

gc_flow(20) TYPE c VALUE 'FLOW',

gc_dsrc(20) TYPE c VALUE 'P_DATASRC',

gc_curr(20) TYPE c VALUE 'RPTCURRENCY',

gc_amount(20) TYPE c VALUE 'SIGNEDDATA'.

FIELD-SYMBOLS: <ls_cate> TYPE ANY,

<ls_time> TYPE ANY,

<ls_acct> TYPE ANY,

<ls_enty> TYPE ANY,

<ls_flow> TYPE ANY,

<ls_dsrc> TYPE ANY,

<ls_curr> TYPE ANY,

<ls_amount> TYPE ANY.

TYPES: BEGIN OF ty_bpc_basic,

category TYPE c LENGTH 20,

flow TYPE c LENGTH 20,

p_acct TYPE c LENGTH 20,

p_datasrc TYPE c LENGTH 20,

rptcurrency TYPE c LENGTH 20,

time TYPE c LENGTH 20,

signeddata(11) TYPE p DECIMALS 7,

END OF ty_bpc_basic.

TYPES: ty_t_bpc_basic TYPE STANDARD TABLE OF ty_bpc_basic.

DATA: ct_data TYPE ty_t_bpc_basic.

DATA: ls_line TYPE ty_bpc_basic.

DATA: lo_metadata TYPE REF TO data.

DATA: lt_final TYPE REF TO data.

FIELD-SYMBOLS: <lt_final> TYPE STANDARD TABLE.

* >> Insert for SE19 CONFIG

* CREATE DATA lt_final LIKE ct_data.

* ASSIGN lt_final->* TO <lt_final>.

* <lt_final> = ct_data.

* << Insert for SE19 CONFIG

* >> Delete for SE19 CONFIG

DATA:

lo_model TYPE REF TO if_uj_model,

Page 17: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 17

lo_appl_rate TYPE REF TO if_uja_application_data.

cl_uj_model=>get_model( EXPORTING i_appset_id = gc_apps

RECEIVING ro_model = lo_model ).

lo_model->get_appl_data( EXPORTING i_application_id = gc_appl

RECEIVING ro_appl_data = lo_appl_rate ).

DATA: lt_column TYPE uja_t_dim_list.

lo_appl_rate->get_dim_list( IMPORTING et_dim_name = lt_column ).

CALL FUNCTION 'ZBPC_GET_APPL_API_FOR_UJQ'

EXPORTING

i_appset_id = gc_apps

i_appl_id = gc_appl

if_inc_measure = abap_true

IMPORTING

er_data = lo_metadata.

ASSIGN lo_metadata->* TO <lt_final>.

CALL FUNCTION 'UJQ_RUN_RSDRI_QUERY'

EXPORTING

i_appset_id = gc_apps

i_appl_id = gc_appl

it_dim_name = lt_column

if_check_security = abap_false

IMPORTING

et_data = <lt_final>.

ct_data = <lt_final>.

CLEAR <lt_final>.

* << Delete for SE19 CONFIG

WRITE: / '---------------------------------------------------------------------'.

WRITE: / '====DISPLAY TRANXDATA===='.

LOOP AT ct_data ASSIGNING <ls_data>.

ASSIGN COMPONENT gc_time OF STRUCTURE <ls_data> TO <ls_time>.

ASSIGN COMPONENT gc_acct OF STRUCTURE <ls_data> TO <ls_acct>.

ASSIGN COMPONENT gc_cate OF STRUCTURE <ls_data> TO <ls_cate>.

ASSIGN COMPONENT gc_flow OF STRUCTURE <ls_data> TO <ls_flow>.

ASSIGN COMPONENT gc_dsrc OF STRUCTURE <ls_data> TO <ls_dsrc>.

ASSIGN COMPONENT gc_curr OF STRUCTURE <ls_data> TO <ls_curr>.

ASSIGN COMPONENT gc_amount OF STRUCTURE <ls_data> TO <ls_amount>.

ls_line-time = <ls_time>.

ls_line-p_acct = <ls_acct>.

ls_line-category = <ls_cate>.

ls_line-flow = <ls_flow>.

ls_line-p_datasrc = <ls_dsrc>.

ls_line-rptcurrency = <ls_curr>.

ls_line-signeddata = <ls_amount>.

WRITE: / ls_line-p_acct, ls_line-time, ls_line-signeddata.

APPEND <ls_data> TO <lt_final>.

ENDLOOP.

WRITE: / 'Reference data are collected – continue with business logic,…'.

Page 18: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 18

Related Content

SDN Central Site for BPC

Dynamic Creation of internal table by RTTC

How to Pass Parameters to Custom Logic BADI using START_BADI

How to Pass Dynamic Parameters to Script Logic

For more information, visit the Enterprise Performance Management homepage.

Page 19: How to Integrate BPC NW to BI7x Technically - Using ABAP

How to Integrate BPC NW to BI7x Technically – using ABAP?

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 19

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.