Sie sind auf Seite 1von 77

SAP BusinessObjects EPM Business Add-Ins

How-To Guide
How To... Create BAdI Implementation for additional SAP BPC Solution
Systems Applications and Products (SAP)
SAP BusinessObjects Planning and Consolidation 7.5, version for SAP
Net Weaver, SP00 and higher.
IT Practice / Topic Area:
Development SAP Business Add-Ins
Version 1.0
June 2012

Author
Hans Raj Prajapati (SAP ABAP Consultant: PricewaterhouseCoopers Ltd.)

Document History
Document Version Description
1.0 First release of this guide

Table of Contents
1. Business Planning and Consolidation
(BPC).................................................................................................................................
1
2. Business Add Ins
(BAdI).........................................................................................................................................
..................... 1
3. Background
Information.................................................................................................................................
............................ 1
4. Prerequisites...............................................................................................................................
................................................
1
5. BPC Script /
Scope..........................................................................................................................................
............................ 1
6. Business
Scenario......................................................................................................................................
.................................
1
6.1 Business Scenario
1........................................................................................................................................................................
.. 2
6.2 Business Scenario
2........................................................................................................................................................................
.. 8
7. Step-by-Step
Procedure...................................................................................................................................
...........................
1
7.1 Create a BAdI
Implementation................. ...............................................................................................................................
........
25
7.2 Understand / write BAdI Implementation
code............................................................................................................................... 5
7.3 Test the BAdI
Implementation.................................................................................................................................................
.........
1

8.
Appendix.....................................................................................................................................
............................................... 1
8.1 Source Code for BAdI
Implementation............................................................................................................................................. 23

1. Business Planning and Consolidation


What is SAP BPC
SAP BusinessObjects Planning and Consolidation (formerly OutlookSoft) is a corporate performance
management tool that can cater for all types of planning and forecasting, from simple small processes to
complex multi layer processes, while also providing consolidation and easy to use reporting.
SAP BPC offers a robust, multiuser platform, which is fully integrated with Microsoft Excel. Initially leveraging off the power of
Microsoft SQL Server and Analysis Services there is now another version that uses SAP Netweaver as its back-end database.
Although similar, especially to the end user, these two versions of the product do offer different functionalities

2. Business Add Ins


What is SAP Business Add-Ins
Business add-ins are enhancements to the standard version of the system. They can be inserted into the SAP System to
accommodate user requirements too specific to be included in the standard delivery. Since specific industries often require
special functions, SAP allows you to predefine these points in your software.

Why SAP Business Add-Ins for SAP BPC


Business add-ins are used with BPC scope / script to improve BPC performance but in a faster way to do customised calcualtion
These are used to replace script calculation with scrip file / scope.

3. Background Information
This How-To guide provides a solution to this in the form of a class that can be included in all BAdi implementations. It checks
the source of data submitted to the BAdi, and depending upon requirement output data is send back using same table.

4. Prerequisites

SAP GUI / Developer Access to SAP Business Warehouse (SAP BW)


SAP BusinessObjects Planning and Consolidation, version for SAP NetWeaver
o Version 7.5
o Version 7.0

5. BPC Scope

What is BPC Script / Scope


it is set of instructions used to filter data coming from CUBE and pass value to BAdI by filtering data as per given dimensions
defined in SAP BPC and SAP R/3 using BI
Scope used is given below
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------//FACILITY IT - AMC COST ACTUAL ALLOCATIONS
*XDIM_MEMBERSET ACCOUNT_A AS %GROUP1% = ALLOCATED_SEATS,UNALLOCATED_SEATS
*XDIM_MEMBERSET ACCOUNT_A AS %GROUP2% = FACIT_AMC,44113001,44117152,PER_ALLOC_FACIT_AMC
*XDIM_MEMBERSET ACCOUNT_A = %GROUP1%,%GROUP2%
*XDIM_MEMBERSET BUSAREA = <ALL>
*XDIM_MEMBERSET CATEGORY = ACTUAL
*XDIM_MEMBERSET COMP_CODE = 6500
*XDIM_MEMBERSET COSTCENTER AS %GROUP3% = BAS(65_DIS)
*XDIM_MEMBERSET COSTCENTER AS %GROUP4% = BAS(65_HPDK)
*XDIM_MEMBERSET COSTCENTER AS %GROUP5% = BAS(65_TRAN)
*XDIM_MEMBERSET COSTCENTER = %GROUP3%,%GROUP4%,%GROUP5%,NO_COSTCENTER
*XDIM_MEMBERSET CURRENCY = <ALL>
*XDIM_MEMBERSET DATASRC = INPUT
*XDIM_MEMBERSET DEPARTMENT = NO_DEPT
*XDIM_MEMBERSET FLOW = F_999
*XDIM_MEMBERSET PROCESS_P AS %GROUP6% = BAS(NO_IO)
*XDIM_MEMBERSET PROCESS_P AS %GROUP7% = BAS(ALL_PROCESS)
*XDIM_MEMBERSET PROCESS_P AS %GROUP8% = BAS(VERTICAL_INP)
*XDIM_MEMBERSET PROCESS_P = %GROUP6%,%GROUP7%,%GROUP8%
*XDIM_MEMBERSET TIME = 2011.DEC
*CALL_CUSTOM_LOGIC AC_FACIT_AMC
Note: *CALL_CUSTOM_LOGIC AC_FACIT_AMC : this statement is used to call BDC implementation using filter value
i.e. AC_FACIT_AMC

6. Business Scenario

Sap BusinessObjects Planning and Consolidation, version for Netweaver (hereafter referred to as BPC) provides a BAdi
(UJ_CUSTOM_LOGIC) that can be used to extend the functionality of script logic packages. Due to the way Input Schedule
initiated script logic operations (i.e. included in default logic) differ from data manager initiated script logic operations you get
consistent results with the same logic depending on where it was executed from.
And this scenario is used for distributing AMC total cost with respect to respective vertical percentage and process wise
employee.

Lets understand requirement by taking a scenario / example to calculate AMC cost as


per process

6.1 Business Scenario 1

If there are 5 GLs and their total sum is Rs. 100 cost and their vertical wise percentage are
10 % for ABU vertical ,
40% for BFSI &
50% for TM and
Respective Processes are as follows
10001 with employee ALLOCATEDSEATS
10002 with employee ALLOCATED SEATS
10003 with employee UNALLOCATED SEATS
10004 with employee ALLOCATED SEATS
10005 with employee UNALLOCATED SEATS
10006 with employee ALLOCATED SEATS

10
15
5
5
5
5

falling
falling
falling
falling
falling
falling

under
under
under
under
under
under

ABU,
ABU,
ABU,
BFSI,
BFSI,
TM,

Then
ABU cost will be
BFSI cost will be
TM cost will be

= total cost * ABU vertical %


= total cost * BFSI vertical %
= total cost * TM vertical %

i.e.
i.e.
i.e.

100 * 10 / 100
100 * 40 / 100
100 * 50 / 100

= 10
= 40
= 50

So after allocation respective vertical cost (10 + 40 + 50) will be equals to total cost i.e. 100 always.
Now allocating these cost to respective processes as per number of employee.
So for a process cost will be equals to (process respective vertical cost / total respective vertical employee) * current
process employee.
Therefore
Total ABU employees will be
Total FBSI employees will be
Total TM employees will be

10 + 15 + 5 +
5+5
5
=5

= 30
= 10

And respective final process cost will be as under

10001 with employee ALLOCATED SEATS 10, falling under ABU


employee) = 3.3333

= [10 (ABU cost) / 30 (total ABU employee)] * 10 (10001

10002 with employee ALLOCATED SEATS 15 falling under ABU = [10 (ABU cost) / 30 (total ABU employee)] * 15 (10002
employee) = 5.0000
10003 with employee UNALLOCATED SEATS 5 falling under ABU = [10 (ABU cost) / 30 (total ABU employee)] * 5 (10003
employee) = 1.6666
10004 with employee ALLOCATED SEATS 5 falling under BFSI = [40 (ABU cost) / 10 (total BFSI employee)] * 5 (10004
employee) = 20.0000
10005 with employee UNALLOCATED SEATS 5 falling under BFSI = [40 (ABU cost) / 10 (total BFSI employee)] * 5 (10005
employee) = 20.0000
10006 with employee ALLOCATED SEATS 5 falling under TM = [10 (ABU cost) / 5 (total TM employee)] * 5 (10006 employee) =
10.0000
After all calculation allocating these values to respective dimensions and passing back to BPC

7. Business Scenario 2
This scenario covers actual dimensions name, their property, input, calculation as well
as final output

INPUT 1:
It gives ACCOUNT Dimensions for Cost in SIGNEDDATA (Amount) field
i.e. FACIT_AMC and two GL account Code i.e. 44113001 and 44117152.

CALCULATION 1:
For value in dimension ACCOUNTS and value in dimension COSTCENTER , Add all the cost as per COMPANY_CODE and
TIME , value of other dimension like PROCESS , BUSAREA will be same as shown below

INTERMEDIATE OUTPUT 1:

Replace each COSTCENTER value by NO_COSTCENTER to get respective total value

INPUT 2:
It gives ACCOUNT Dimension i.e. PER_ALLOC_FACIT_AMC for vertical wise percentage distribution of cost (got from previous
calculation i.e. INPUT 1)

INTERMEDIATE OUTPUT 2:
INPUT 1 calculation

Calculate vertical wise cost i.e. Multiplication of vertical wise cost % and total cost from

INPUT 3:
It gives ACCOUNT Dimension i.e. ALLOCATED_SEATS / UNALLOCATED_SEATS and respective processes number of employee
and each process have vertical value in last column i.e. ABU / TM / BFSI .

Continued

INTERMEDIATE OUTPUT 3:
It gives ACCOUNT Dimension i.e. ALLOCATED_SEATS / UNALLOCATED_SEATS and respective processes number of employee
Calculate vertical wise total no of employee using processes vertical property

FINAL OUTPUT:

Output for its each process as per vertical Dimension ACCOUNT will have value ALLOC_FACTAMC_COSTS and AMOUNT or
SIGNEDDATA will have value equals to (Vertical wise total cost / Vertical wise total employee) * Process employee number

Continued

Continued

9.Step-by-step Procedures
9.1

Create a BAdI Implementation

STEP 1:

Enter /nSE19 and Enter Enhancement Spot i.e. UJ_CUSTOM_LOGIC and Press Create Impl. Button

STEP 2: Enter Enhancement Implementation Name and its description say ZBPC_AC_FACIT_AMC_EI

STEP 3 : Enter Package Name say ZBW

STEP 4: Create request using create button .

Give its description then press button ok.

STEP 5: It will Give request Number Automatically for the same

STEP 6: Create BAdI Implementations: Enter Name say ZBPC_AC_FACIT_AMC_BI & its Implementing Class name say
ZBPC_AC_FACIT_AMC_CL

STEP 7: Select BAdI Definition Name and Enter or Press OK Button.

STEP 8: Enter Package Name say ZBW or last entered package will be displayed here automatically and Press OK or Enter.

STEP 9: Select Request Name or last entered or created request will be displayed here automatically and Press OK or Enter.

STEP 10: It will display a screen showing Inactive Enhancement Implementation and Under Tab Enh. Implementation Elements
it is showing BAdi Implementations highlighted in yellow color.Expand it using Left Arrow button under BAdi Implementations

STEP 11: It will display a screen showing Inactive Enhancement Implementation and Under Tab Enh. Implementation Elements
it is showing BAdi Implementations highlighted in yellow color and its element ie Implementing Class and Filter Val. Double Click
on Filter Val.

STEP 12: It will display a Filter Values screen and Click on Combination button it add a row under Combination 1 with Value 1
equals to ????
Double Click on this value.

STEP 13: Enter Value 1 say AC_FACIT_AMC and press Enter or ok.

STEP 14: It will display this screen back with filter value

STEP 15: Double Click on Implementing Class highlighted in yellow color under BAdi Implementations and it will display
method

STEP 16: Press Enter or Yes.

STEP 17: Press Enter or Yes.

STEP 18: It will open class builder for that method.

STEP 19: Press control F2 or Change Button

STEP 20: Write Code

STEP 21: Press Pretty Printer whenever required for making code good looking / pretty

STEP 22: Press Activate Button or Control F3 and then press Enter button or OK.

STEP 23: Code Activated and Exit.

STEP 24: Again to change Code Enter /nSE19 and Enter New BAdi Enhancement Implementation as ZBPC_AC_FACIT_AMC_EI as
created previously and Press Change button .

STEP 25: Expand BAdI Implementations highlighted in yellow color by clicking on arrow button

STEP 26: Double Click on BAdI Implementations highlighted in yellow color.

STEP 27: Double Click on Method IF_UJ_CUSTOM_LOGIC~EXECUTE highlighted in light blue color.

STEP 28: Change code check and activate it.

STEP 29: Method IF_UJ_CUSTOM_LOGIC~EXECUTE have following Parameters in custom class ZBPC_AC_FACIT_AMC_IC.
Parameter I_APPSET_ID contain value selected by user from transaction UJKT or defined in BPC package e.g. APPSET_BP.
Parameter I_APPL_ID contain value selected by user from transaction UJKT or defined in BPC package e.g. BI_Test as per
appset id.

9.2

Understand / Write the BAdI Implementation code

Important Points
1. Firstly understand parameters of method IF_UJ_CUSTOM_LOGIC~EXECUTE i.e.
1.1I_APPSET_ID TYPE UJ_APPSET_ID
BPC:
1.2I_APPL_ID
TYPE UJ_APPL_ID
BPC:
1.3IT_PARAM
TYPE UJK_T_SCRIPT_LOGIC_HASHTABLE OPTIONAL
1.4IT_CV
TYPE UJK_T_CV
dimensions and its value
1.5ET_MESSAGE
TYPE UJ0_T_MESSAGE
1.6CT_DATA
TYPE STANDARD TABLE OPTIONAL
output
1.7CX_UJ_CUSTOM_LOGIC

AppSet ID
: it gives selected appset id
Application ID : it gives selected application id
script logic hash table
Script Logic Current View : it is hashed table gives
BPC: Messages: it is used to trigger message
it gives dimension wise selected input and to pass
BPC Exception: Custom Logic Exception

2. CT_DATA table is a dynamic internal table and its dimensions / fields depends upon BPC / BI configuration
Example: CT_DATA table have fields or called DIMENSION_A that depends upon SAP BPC configuration and
This table will be required to get input as well as to send output data back to BPC
In this example it has 13 fields given below
1. account_a type c length 50
2. busarea type c length 20
3. comp_code type c length 20
4. process_p type c length 20
5. time
type c length 20
6. category type c length 20
7. costcenter type c length 20
8. currency type c length 20
9. datasrc type c length 20
10.department type c length 20
11.flow
type c length 20
12.measures type c length 20
13. signeddata type /b28/oisdata
3.
4.
5.
6.

CT_DATA
CT_DATA
CT_DATA
CT_DATA
used

will be used to get input and to pass final output


can contain input as well as output when passing data back to cube
can also contain output only i.e. input can be deleted
table cannot contain account id that is total sum of its child. it will throw an exception i.e. Sum member cannot be

7. Required types for internal table , work area , variables , constants will be used
8. SIGNEDDATA field will always contain positive or negative value and will have specific types e.g.
signeddata type /b28/oisdata .
9. To write code in BAdI Implementation important points are
9.1.Delete duplicate record from table CT_DATA before reading data if exists.
9.2.READ dynamic table CT_DATA records and prepare table as per required logic i.e.
9.2.1. Cost
9.2.2. Cost Percentage
9.2.3. Head counts / Seats
9.2.4. Processes detail
9.3.Also get required dimensions property as per logic i.e.
9.3.1. Process dimension Property or
9.3.2. Company Code dimension property or
9.3.3. Account dimension Property or
9.3.4. Business area dimension property or
9.3.5. Other dimension property as per logic .
9.4.Depending upon required logic either delete input data from CT_DATA or
9.5.Before sending new value of the required combination output to the ct_data table , delete one by one old value data
that exists in ct_data table due to first time run of BADI logic or last run of BADI for the same new combination
9.6.Put required validation i.e. Company code currency check with ct_data values , process property validation , zero
signeddata is required or not , divide by zero and mainly respective dimensions ids.
9.7.Rread Dimensions property : lets take code to understand it
)* Get the current context details using below code
call method cl_uj_context=>get_cur_context
receiving
ro_context = context_ro.
context_ro->switch_to_srvadmin( ).
* Assign the user details
and
* wa_user is of type uj0_s_user.
* i_appset_id are application id e.g. APPSET_BP

is coming from method parameters

wa_user = context_ro->ds_user.
try.
call method cl_uj_context=>set_cur_context
exporting
i_appset_id = i_appset_id
is_user
= wa_user
i_appl_id = i_appset_id."c_application.
catch cx_uj_obj_not_found .
endtry.
**
Below code will read dimensions used in ct_data property and v_dimensions is the field used to pass dimension
**
Its value PROCESS_P is used here to read process property similarly other can be used by passing dimensions
name
try.
create object lo_dim_reader
exporting
i_appset_id = i_appset_id
i_dimension = v_dimension.
catch cx_uja_admin_error .
endtry.
**
**

BELOW CODE WILL GIVE REFERENCE OF PROCESS_P DIMENSIONS DATA i.e. rf_data_pp type ref to data,
using this reference pass data to field symbols
<fs_it_pp> type standard table. Now it contains process

property

**
Its value PROCESS_P is used here to read process property similarly other dimension can be used
**
So <fs_it_pp> is dynamic table and dynamic concept will be used to read data & to populate normal internal table
from this
try.
call method lo_dim_reader->read_mbr_data
importing
er_data = rf_data_pp.
catch cx_uja_admin_error .
endtry.
"<~~~ moving data
assign rf_data_pp->* to <fs_it_pp>.

sort <fs_it_pp> by (c_id) (c_cocode) (c_parenth1).


"<~~~ it will give property of dimension 'PROCESS_P
loop at <fs_it_pp> assigning <fs_wa_pp>.
unassign <fs_value>.
assign component 'PARENTH1' of structure <fs_wa_pp> to <fs_value>.
move:<fs_value> to wa_npp-parenth1.
unassign <fs_id>.
assign component 'ID' of structure <fs_wa_pp> to <fs_id>.
unassign <fs_ba>.
assign component 'BA' of structure <fs_wa_pp> to <fs_ba>.
unassign <fs_calc>.
assign component 'CALC' of structure <fs_wa_pp> to <fs_calc>.
unassign <fs_cocode>.
assign component 'COCODE' of structure <fs_wa_pp> to <fs_cocode>.
unassign <fs_vertical>.
assign component 'VERTICAL' of structure <fs_wa_pp> to <fs_vertical>.
"<~~ for country level hierarchy
if wa_npp-parenth1 eq 'NO_IO'.
move :

<fs_ba>
to wa_npp-ba
,
<fs_vertical>
to wa_npp-vertical,
<fs_id>
to wa_npp-id
,
<fs_calc>
to wa_npp-calc ,
<fs_cocode>
to wa_npp-cocode .

append wa_npp to it_npp.


clear wa_npp.
"<~~Gives process property

else.
move : <fs_id> to wa_pp-id
,
<fs_ba> to wa_pp-ba
,
<fs_vertical> to wa_pp-vertical,
<fs_calc> to wa_pp-calc ,
<fs_cocode> to wa_pp-cocode .
check wa_pp-ba is not initial or wa_pp-vertical is not initial.
append wa_pp to it_pp.
clear : wa_pp.
endif.
endloop.
unassign : <fs_value>,<fs_id>,<fs_ba>, <fs_calc>,<fs_cocode>,<fs_vertical>.

9.3

Test the BAdI Implementation


9.1Put a break point using keyword BREAK-POINT or better to use user specific i.e. BREAK SAP_usename

9.2Run transaction UJKT


9.3Select required application set name, application id name and BPC user name.
9.4Select Scope / Script File Location :or paste scope here
9.5Validate it : there must be no problem in validation
9.6Execute it : there must be no error
9.7Break point will trigger and as per logic output data will be passed to cube
9.8Check it using BPC

10.
10.1

Appendix
Source Code for BAdI Implementation

method if_uj_custom_logic~execute.
*$----- 'Start Code : Addition : PwC : Hans : Dt : 06.06.2012 '-----$
*$----- 'Add Code Here'-----$
check ct_data is not initial .
*&---- TYPE Declaration
types: begin of ty_pp,
id
type c length 20,
ba
type c length 20,
vertical
type c length 20,
calc
type c length 20,
cocode
type c length 10,
parenth1
type c length 20,
end of ty_pp,
begin of ty_ap,
group
type c length 20,
id
type c length 20,
calc
type c length 20,
parenth1
type c length 20,
end of ty_ap,
begin of ty_npp,
parenth1
type c length 50,
calc
type c length 20,
cocode
type c length 10,
id
type c length 20,
ba
type c length 20,
vertical
type c length 20,
end of ty_npp,
begin of ty_ba,
parenth
type c length 20,
parenth1
type c length 20,
id
type c length 20,
calc
type c length 20,
category
type c length 5,
dedicated
type c length 10,

geography type c length 10,


end of ty_ba ,
begin of ty_parent,
sign type c length 1,
option type c length 2,
low type c length 50 ,
high type c length 50 ,
end of ty_parent,
begin of ty_ccp,
comp_code type c length 20 ,
currency type c length 20,
end of ty_ccp ,
begin of ty_ctdata,
account_a type c length 50,
busarea type c length 20,
comp_code type c length 20,
process_p type c length 20,
pp1
type c length 20,
pp2
type c length 20,
vrt
type c length 20,
time
type c length 20,
signeddata type /b28/oisdata ,"(11) type p decimals 7,
category type c length 20 ,
costcenter type c length 20,
currency type c length 20,
datasrc type c length 20,
department type c length 20,
flow
type c length 20,
measures type c length 20,
ba
type c length 20,
dpt
type c length 20,
end of ty_ctdata.
data :it_ctd_h
wa_ctd_h

type standard table of ty_ctdata,


type ty_ctdata,

It_ctd_i
wa_ctd_i

type standard table of ty_ctdata,


type ty_ctdata,

it_ctd_s
wa_ctd_s

type standard table of ty_ctdata,


type ty_ctdata,

it_ctd_c
wa_ctd_c

type standard table of ty_ctdata,


type ty_ctdata,

it_ctd_cf
wa_ctd_cf

type standard table of ty_ctdata,


type ty_ctdata,

it_ctd_c_cm
type standard table of ty_ctdata,
wa_ctd_c_cm type ty_ctdata,
it_ctd_cp_vrt type standard table of ty_ctdata,
wa_ctd_cp_vrt
type ty_ctdata,
it_pp
wa_pp
it_bap
wa_bap

type standard table of ty_pp,


type
ty_pp,
type standard table of ty_ba,
type
ty_ba,

it_bavp
wa_bavp

type standard table of ty_ba,


type
ty_ba,

it_npp
wa_npp

type standard table of ty_npp,


type
ty_npp,

it_ccp
wa_ccp

type standard table of ty_ccp,


type
ty_ccp.

data : v_signeddata_c
v_signeddata_vrt
v_signeddata_ba
v_signeddata_cm
v_signeddata_cf
v_signeddata_p

type
type
type
type
type
type

/b28/oisdata,
/b28/oisdata,
/b28/oisdata,
/b28/oisdata,
/b28/oisdata,
/b28/oisdata,

v_flag,
v_low
type string ,
c_parent
type string ,
v_index
type sy-tabix,
v_loop
type sy-tabix,
v_busarea
type c length 20,
v_process_p
type c length 20,
v_busarea_f
type c length 20,
v_account_vrt
type c length 50,
v_account_a
type c length 50,
v_account_c
type c length 50,
v_account_s
type c length 50,
v_vertical
type c length 10,
v_department
type c length 10,
v_dimension
type uj_appl_id value 'PROCESS_P'.
data : rf_ctd
type ref to data,
rf_ba_cs
type ref to data,
lo_dim_reader
type ref to cl_uja_dim,
rf_data_pp
type ref to data,
rf_data_bap
type ref to data,
rf_data_ccp
type ref to data,
context_ro
type ref to if_uj_context,
wa_user
type uj0_s_user.
constants: c_application type uj_appl_id value 'APPSET_BP',
c_account_a
type string value 'ACCOUNT_A',
c_busarea
type string value 'BUSAREA',
c_category
type string value 'CATEGORY',
c_comp_code
type string value 'COMP_CODE',
c_cost_center
type string value 'COSTCENTER',
c_currency
type string value 'CURRENCY',
c_datasrc
type string value 'DATASRC',
c_department
type string value 'DEPARTMENT',
c_flow
type string value 'FLOW',
c_measures
type string value 'MEASURES',
c_process_p
type string value 'PROCESS_P',
c_time
type string value 'TIME',
c_signeddata
type string value 'SIGNEDDATA',
c_parenth1
type string value 'PARENTH1',

c_group
c_id
c_ba
c_cocode
c_hier
c_vertical
c_ps
c_us
c_csc
c_as
c_uas
c_te
c_nb
c_ni
c_pafa
c_ssb
c_chc
c_rd
c_ri
c_ndo
c_nin
c_db
c_ib
c_swb
c_rpc
c_cb
c_hc
c_empgrade
c_nc
c_fa
c_avc
c_afc
c_sign
c_option
field-symbols :

type string value 'GROUP',


type string value 'ID',
type string value 'BA',
type string value 'COCODE',
type string value 'HIER',
type string value 'VERTICAL',
type string value 'PRODN_SEATS',
type string value 'UNALLOCATED_SEATS',
type string value 'COSTS_SEAT_CENTRE',
type string value 'ALLOCATED_SEATS' ,
type string value 'UNALLOCATED_SEATS',
type string value 'TOTAL_EMPLOYEE',
type string value 'NO_BA',
type string value 'NO_IO',
type string value 'PER_ALLOC_FACIT_AMC',
type string value 'SUPPORT_SEATS_B',
type string value 'COSTS_HC_CENTRE',
type string value 'RATE_DOM',
type string value 'RATE_INTL',
type string value 'NO_DOM',
type string value 'NO_INTL',
type string value 'DOMTRVL_BUD',
type string value 'INTTRVL_BUD',
type string value 'STAFF_WELFARE_BUD',
type string value 'RATE_PER_CONV',
type string value 'CONVEYANCE_BUD',
type string value 'HC_CONV',
type string value 'EMPGRADE',
type string value 'NO_COSTCENTER',
type string value 'FACIT_AMC',
type string value 'ALLOC_VCS_COSTS',
type string value 'ALLOC_FACITAMC_COSTS',
type string value 'I',
type string value 'EQ'.
<fs_t>
<fs_p>
<fs_wa_ap_c1>
<fs_id>
<fs_process_p>

type any,
type any,
type any,
type any,
type any,

<fs_account_a>
type any,
<fs_signeddata> type any,
<fs_department> type any,
<fs_value>
type any,
<fs_vertical>
type any,
<fs_ba>
type any,
<fs_calc>
type any,
<fs_cocode>
type any,
<fs_group>
type any,
<fs_parenth1> type any,
<fs_wa_ctd_a> type any,
<fs_it_ctd_a> type standard table,
<fs_it_ctd_h> type standard table,
<fs_it_pp>
type standard table,
<fs_wa_pp>
type any,
<fs_it_ap>
type standard table,
<fs_wa_ap>
type any,
<fs_it_bap>
type standard table,
<fs_wa_bap>
type any,
<fs_it_ccp>
type standard table,
<fs_wa_ccp>
type any .

data:

it_parent
wa_parent
it_dpt_ba
wa_dpt_ba
it_dpt_e1
wa_dpt_e1
it_ba
wa_ba
it_dpt_vrt
wa_dpt_vrt

type
type
type
type
type
type
type

table of ty_parent,
ty_parent,
table of ty_parent,
ty_parent,
table of ty_parent,
ty_parent,
table of ty_parent,
type
ty_parent,
type table of ty_parent,
type
ty_parent.

"<~~ Start Changes: PwC : Hans on 15.05.2012


"<~~ for exception as in CCS
*************************GET CF Cube Data
*****CF cube structure creation

create data rf_ctd like ct_data.


assign rf_ctd->* to <fs_it_ctd_a> .
move ct_data to <fs_it_ctd_a>.
*&---- Begin: of Reading Processes' Properties from BPC
* Get the current context details
call method cl_uj_context=>get_cur_context
receiving
ro_context = context_ro.
context_ro->switch_to_srvadmin( ).
* Assign the user details
wa_user = context_ro->ds_user.
try.
call method cl_uj_context=>set_cur_context
exporting
i_appset_id = i_appset_id
is_user
= wa_user
i_appl_id = i_appset_id."c_application.
catch cx_uj_obj_not_found .
endtry.
try.
create object lo_dim_reader
exporting
i_appset_id = i_appset_id
i_dimension = v_dimension.
catch cx_uja_admin_error .
endtry.
try.
call method lo_dim_reader->read_mbr_data
importing
er_data = rf_data_pp.
catch cx_uja_admin_error .
endtry.
"<~~~ moving data

assign rf_data_pp->* to <fs_it_pp>.


sort <fs_it_pp> by (c_id) (c_cocode) (c_parenth1).
"<~~~ it will give property of dimension 'process_p' ie. BASE(NO_IO).
"<~~~ to check country code
loop at <fs_it_pp> assigning <fs_wa_pp>.
unassign <fs_value>.
assign component 'PARENTH1' of structure <fs_wa_pp> to <fs_value>.
move:<fs_value> to wa_npp-parenth1.
unassign <fs_id>.
assign component 'ID' of structure <fs_wa_pp> to <fs_id>.
unassign <fs_ba>.
assign component 'BA' of structure <fs_wa_pp> to <fs_ba>.
unassign <fs_calc>.
assign component 'CALC' of structure <fs_wa_pp> to <fs_calc>.
unassign <fs_cocode>.
assign component 'COCODE' of structure <fs_wa_pp> to <fs_cocode>.
unassign <fs_vertical>.
assign component 'VERTICAL' of structure <fs_wa_pp> to <fs_vertical>.
"<~~ for country level hierarchy
if wa_npp-parenth1 eq 'NO_IO'.
move :
<fs_ba> to wa_npp-ba
,
<fs_vertical> to wa_npp-vertical,
<fs_id> to wa_npp-id
,
<fs_calc> to wa_npp-calc ,
<fs_cocode> to wa_npp-cocode .
append wa_npp to it_npp.
clear wa_npp.

"<~~Gives process property


else.
move : <fs_id> to wa_pp-id
,
<fs_ba> to wa_pp-ba
,
<fs_vertical> to wa_pp-vertical,
<fs_calc> to wa_pp-calc ,
<fs_cocode> to wa_pp-cocode .
check wa_pp-ba is not initial or wa_pp-vertical is not initial.
append wa_pp to it_pp.
clear : wa_pp.
endif.
endloop.
unassign : <fs_value>,<fs_id>,<fs_ba>, <fs_calc>,<fs_cocode>,<fs_vertical>.
sort : it_pp by id cocode.
"<~~~ it will give ba wise property
v_dimension = 'BUSAREA'.
try.
create object lo_dim_reader
exporting
i_appset_id = i_appset_id
i_dimension = v_dimension.
catch cx_uja_admin_error .
endtry.
try.
call method lo_dim_reader->read_mbr_data
importing
er_data = rf_data_bap.
catch cx_uja_admin_error .
endtry.
"<~~~ moving data

assign rf_data_bap->* to <fs_it_bap>.


sort <fs_it_bap> by (c_id) .
"<~~ this will give business area / vertical property as per dimension busarea
loop at <fs_it_bap> assigning <fs_wa_bap>.
unassign <fs_value>.
assign component 'PARENTH1' of structure <fs_wa_bap> to <fs_value>.
move <fs_value> to wa_bap-parenth1.
*

check wa_bap-parenth1 eq c_ab or wa_bap-parenth1 eq c_verticals.


unassign <fs_value>.
assign component 'ID' of structure <fs_wa_bap> to <fs_value>.
move <fs_value> to wa_bap-id.
unassign <fs_value>.
assign component 'CALC' of structure <fs_wa_bap> to <fs_value>.
move <fs_value> to wa_bap-calc.
unassign <fs_value>.
assign component 'DEDICATED' of structure <fs_wa_bap> to <fs_value>.
move <fs_value> to wa_bap-dedicated.
unassign <fs_value>.
assign component 'GEOGRAPHY' of structure <fs_wa_bap> to <fs_value>.
move <fs_value> to wa_bap-geography.
unassign <fs_value>.
assign component 'CATEGORY' of structure <fs_wa_bap> to <fs_value>.
move <fs_value> to wa_bap-category.
append wa_bap to it_bap.
clear : wa_bap.
endloop.

"<~~ this will give all business area and verticals as per hierarchy
loop at it_bap into wa_bap where parenth1 eq 'ALL_BA' or parenth1 eq 'VERTICALS'.
if wa_bap-parenth1 eq 'VERTICALS'.
wa_bap-parenth = 'VERTICALS'.
append wa_bap to it_bavp.
elseif wa_bap-parenth1 eq 'ALL_BA '.
loop at it_bap into wa_bavp where parenth1 eq wa_bap-id.
wa_bavp-parenth = 'ALL_BA '.
append wa_bavp to it_bavp.
endloop.
endif.
endloop.
"'''
"<~~~ it will give COMP_CODE wise property
v_dimension = 'COMP_CODE'.
try.
create object lo_dim_reader
exporting
i_appset_id = i_appset_id
i_dimension = v_dimension.
catch cx_uja_admin_error .
endtry.
try.
call method lo_dim_reader->read_mbr_data
importing
er_data = rf_data_ccp.
catch cx_uja_admin_error .

endtry.
assign rf_data_ccp->* to <fs_it_ccp>.
loop at <fs_it_ccp> assigning <fs_wa_ccp>.
unassign <fs_value>.
assign component 'ID' of structure <fs_wa_ccp> to <fs_value>.
check sy-subrc is initial.
move <fs_value> to wa_ccp-comp_code.
unassign <fs_value>.
assign component 'CURRENCY' of structure <fs_wa_ccp> to <fs_value>.
check sy-subrc is initial.
move <fs_value> to wa_ccp-currency.
append wa_ccp to it_ccp.
clear : wa_ccp.
endloop.
"
"(1)<~~
"(2)<~~
"(3)<~~
"(4)<~~

this
this
this
this

will
will
will
will

give
give
give
give

total cost as per business area / vertical and department


% cost as per vertical and department
total no of employee as per business area / vertical
common cost as per vertical

sort ct_data.
*$---- In input duplicate record may come -----$
delete adjacent duplicates from ct_data comparing all fields .
loop at ct_data assigning <fs_wa_ctd_a>.
clear : wa_ctd_h.
v_index = sy-tabix.
***'COMP_CODE'
unassign <fs_value>.

assign component 4 of structure <fs_wa_ctd_a> to <fs_value>.


move <fs_value> to wa_ctd_h-comp_code.
"<~~~ it will give check waether company code belongs to respective hierarchy or not
clear wa_npp.
read table it_npp into wa_npp with key cocode = <fs_value> .
if sy-subrc is not initial.
continue.
endif.
"<~~ Start Code : Addition : PwC: Hans : Dt : 22.05.2012
"<~~~ To read Company currency to remove multiple currency record in same combination of record in ct_data
clear wa_ccp.
read table it_ccp into wa_ccp with key comp_code = wa_npp-cocode.
unassign <fs_value>.
assign component 'CURRENCY' of structure <fs_wa_ctd_a> to <fs_value>.
check wa_ccp-currency eq <fs_value>.
"<~~ End Code : Addition : PwC: Hans : Dt : 22.05.2012
unassign <fs_value>.
assign component 13 of structure <fs_wa_ctd_a> to <fs_value>.
move <fs_value> to wa_ctd_h-signeddata.
do 12 times .
v_loop = sy-index.
unassign <fs_value>.
assign component v_loop of structure <fs_wa_ctd_a> to <fs_value>.
check sy-subrc is initial.
if v_loop eq 1 .
move <fs_value> to wa_ctd_h-account_a.
elseif v_loop eq 2.

move <fs_value> to wa_ctd_h-busarea.


elseif v_loop eq 3.
move <fs_value> to wa_ctd_h-category.
elseif v_loop eq 5.
move <fs_value> to wa_ctd_h-costcenter.
elseif v_loop eq 6.
move <fs_value> to wa_ctd_h-currency.
elseif v_loop eq 7.
move <fs_value> to wa_ctd_h-datasrc.
elseif v_loop eq 8.
move <fs_value> to wa_ctd_h-department.
elseif v_loop eq 9.
move <fs_value> to wa_ctd_h-flow.
elseif v_loop eq 10.
move <fs_value> to wa_ctd_h-measures.
elseif v_loop eq 11.
move <fs_value> to wa_ctd_h-process_p.
elseif v_loop eq 12.
move <fs_value> to wa_ctd_h-time.
*

elseif v_loop eq 13.

endif.
enddo.
***'Process_P
"<~~~ prepare header table
"<~~~ prepare sum at company code , ba , time level of all account
if wa_ctd_h-costcenter ne c_nc
and
wa_ctd_h-process_p eq wa_npp-id and
( wa_ctd_h-account_a eq c_fa
or
wa_ctd_h-account_a eq '44113001' or
wa_ctd_h-account_a eq '44117152' ).
move wa_ctd_h to wa_ctd_c.
clear :wa_ctd_c-account_a,
wa_ctd_c-costcenter,
wa_ctd_c-busarea .
move : c_afc to wa_ctd_c-account_a,
c_nc to wa_ctd_c-costcenter,
c_nb to wa_ctd_c-busarea.
"<~~ it will give common cost as per vertical and department
collect wa_ctd_c into it_ctd_c.
"<~~~ for vertical level
elseif wa_ctd_h-account_a eq c_pafa.
split: wa_ctd_h-process_p at '_' into wa_ctd_h-pp1 wa_ctd_h-pp2.
clear : wa_ctd_cp_vrt.
move wa_ctd_h to wa_ctd_cp_vrt.
"<~~ it will give cost percentage vertical wise
append wa_ctd_cp_vrt to it_ctd_cp_vrt.

*$----Vertical wise employee sum ----$


elseif wa_ctd_h-costcenter eq c_nc and ( wa_ctd_h-account_a eq c_as or wa_ctd_h-account_a eq c_uas ) .
*$---- Checking process property ----$
clear wa_pp.
read table it_pp into wa_pp with key id = wa_ctd_h-process_p binary search.
check sy-subrc is initial and wa_pp-vertical is not initial.
"<~~~ for vertical wise sum of employee
clear wa_ctd_s.
move : wa_ctd_h to wa_ctd_s ,
wa_ctd_h to wa_ctd_i,
c_te
to wa_ctd_s-account_a . " 'TOTAL_EMPLOYEE' : for reference only to sum using collect all employee
move : c_nb to wa_ctd_s-busarea,
wa_pp-vertical to wa_ctd_s-vrt,
wa_pp-vertical to wa_ctd_i-vrt.
clear : wa_ctd_s-process_p .
*

$---- Total Seats ----$


collect wa_ctd_s into it_ctd_s.
"<~~~ prepare item table ie all individual process wise employee
"<~~ give all process for ba / vertical
append wa_ctd_i to it_ctd_i.
endif.
endloop.
unassign <fs_wa_ctd_a>.
break biuser.

"<~~~ we can not pass data back to cube / ct_data that have ID for Total bcoz
*
it will give exception as total is calculated at BPC level using its child in hierarchy
loop at ct_data assigning <fs_wa_ctd_a>.

v_loop = sy-tabix.
unassign <fs_value>.
assign component 1 of structure <fs_wa_ctd_a> to <fs_value>.
check sy-subrc is initial.
if <fs_value> eq c_fa.
delete ct_data index v_loop.
endif.
endloop.
unassign <fs_wa_ctd_a>.
"<~~ this will give verticla wise total cost
loop at it_ctd_c into wa_ctd_c .
"<~~~ passing final account id for cost
if wa_ctd_c-account_a eq c_afc.
move : c_pafa to v_account_a.
endif.
"<~~~ calculate cost % vertical wise
loop at it_ctd_cp_vrt into wa_ctd_cp_vrt where account_a = v_account_a
busarea = wa_ctd_c-busarea and
comp_code = wa_ctd_c-comp_code and
time
= wa_ctd_c-time
and
category = wa_ctd_c-category and
costcenter = wa_ctd_c-costcenter and
datasrc = wa_ctd_c-datasrc and
department = wa_ctd_c-department and
flow
= wa_ctd_c-flow .
move : wa_ctd_cp_vrt
to wa_ctd_cf,
c_afc
to wa_ctd_cf-account_a.

and

multiply wa_ctd_cf-signeddata by wa_ctd_c-signeddata.


append wa_ctd_cf to it_ctd_cf.
clear : wa_ctd_cp_vrt,wa_ctd_cf.
endloop .
clear : wa_ctd_c.
endloop.
sort it_ctd_i by process_p account_a.
*CLEAR ct_data.
"<~~~ it will populate ct_data as per required output i.e process wise cost
loop at it_ctd_i into wa_ctd_i.
clear : v_signeddata_c, v_account_c, v_account_s,v_busarea.
if wa_ctd_i-account_a eq c_as or wa_ctd_i-account_a eq c_uas .
move : c_afc to v_account_c,
c_te to v_account_s .
endif.

clear wa_ctd_c.
read table it_ctd_cf into wa_ctd_c with key account_a = v_account_c
busarea = wa_ctd_i-busarea
comp_code = wa_ctd_i-comp_code
time
= wa_ctd_i-time
category = wa_ctd_i-category
costcenter = wa_ctd_i-costcenter
datasrc = wa_ctd_i-datasrc
department = wa_ctd_i-department
flow
= wa_ctd_i-flow
pp1
= wa_ctd_i-vrt.
if sy-subrc is initial and wa_ctd_c-signeddata is not initial.
multiply wa_ctd_i-signeddata by wa_ctd_c-signeddata.
else.
clear wa_ctd_i-signeddata .

endif.
clear wa_ctd_c.
read table it_ctd_s into wa_ctd_s with key account_a = v_account_s
busarea = wa_ctd_s-busarea
comp_code = wa_ctd_s-comp_code
time
= wa_ctd_s-time
category = wa_ctd_s-category
costcenter = wa_ctd_s-costcenter
datasrc = wa_ctd_s-datasrc
department = wa_ctd_s-department
flow
= wa_ctd_s-flow
vrt
= wa_ctd_i-vrt.
if sy-subrc is initial and wa_ctd_s-signeddata is not initial.
divide wa_ctd_i-signeddata by wa_ctd_s-signeddata.
else.
clear :wa_ctd_i-signeddata.
endif.

if <fs_wa_ctd_a> is not assigned.


read table <fs_it_ctd_a> assigning <fs_wa_ctd_a> index 1.
clear <fs_wa_ctd_a>.
endif.
do 13 times.
v_loop = sy-index .
unassign <fs_value>.
assign component v_loop of structure <fs_wa_ctd_a> to <fs_value>.
check sy-subrc is initial.
if v_loop eq 1.
move v_account_c to <fs_value>.

elseif v_loop eq 2.
move wa_ctd_i-busarea to <fs_value>.
elseif v_loop eq 3.
move wa_ctd_i-category to <fs_value>.
elseif v_loop eq 4.
move wa_ctd_i-comp_code to <fs_value>.
elseif v_loop eq 5.
move wa_ctd_i-costcenter to <fs_value> .
elseif v_loop eq 6.
move wa_ctd_i-currency to <fs_value> .
elseif v_loop eq 7.
move wa_ctd_i-datasrc to <fs_value> .
elseif v_loop eq 8.
move wa_ctd_i-department to <fs_value>.
elseif v_loop eq 9.
move wa_ctd_i-flow to <fs_value>.
elseif v_loop eq 10.
move wa_ctd_i-measures to <fs_value>.
elseif v_loop eq 11.
move wa_ctd_i-process_p to <fs_value> .

elseif v_loop eq 12.


move wa_ctd_i-time to <fs_value>.
elseif v_loop eq 13.
move wa_ctd_i-signeddata to <fs_value>.

if <fs_p> is assigned .
clear <fs_p>.
endif.
read table ct_data assigning <fs_p> with key (c_account_a) = v_account_c
(c_busarea)
= wa_ctd_i-busarea
(c_category) = wa_ctd_i-category
(c_comp_code) = wa_ctd_i-comp_code
(c_cost_center) = wa_ctd_i-costcenter
(c_currency) = wa_ctd_i-currency
(c_datasrc)
= wa_ctd_i-datasrc
(c_department) = wa_ctd_i-department
(c_flow)
= wa_ctd_i-flow
(c_measures) = wa_ctd_i-measures
(c_process_p) = wa_ctd_i-process_p
(c_time)
= wa_ctd_i-time.
if sy-subrc is initial.
clear v_index.
v_index = sy-tabix.
delete ct_data[] index v_index.
endif.
if <fs_p> is assigned.
unassign <fs_p>.
endif.
append <fs_wa_ctd_a> to ct_data.

endif.
if <fs_value> is assigned .
unassign <fs_value>.
endif.
enddo.
endloop.
sort ct_data by (c_process_p).
unassign <fs_wa_ctd_a>.
try.
catch cx_uj_custom_logic .
endtry.

*$----- 'End Code : Addition : PwC : Hans : Dt : 06.06.2012 '-----$


endmethod.

Das könnte Ihnen auch gefallen