Custom BADI Using Function Module UJQ_RUN_AXIS_QUERY Applies to: SAP Business Planning and Consolidation for NetWeaver 7.0. Summary This Guide covers how to use Custom BADI and the functionality of the Function module UJO_RUN_AXIS_QUERY. Author: Sakthi Jaganathan Company: Infosys Technologies Limited Created on: 22 April 2010 Author Bio Sakthi Jaganathan has been working for Infosys Technologies Limited for the past 2.3 years and has experience in SAP BI 7.0 and SAP BPC MS and NW Versions. 2010 SAP AG 1
Table of Contents Introduction... 3 Scenario... 3 Step by Step Procedure... 4 Appset Creation and Data upload... 4 Custom BADI implementation... 4 Process Chain Creation... 6 Calling the BADI from BPC... 6 Creation of New Package in BPC... 7 Execution of BADI through Data Manager in BPC... 8 Validation of Data in Reports... 11 Appendix... 12 Sample BADI Code:... 12 Disclaimer and Liability Notice... 15 2010 SAP AG 2
Introduction Custom BADI will be used to implement our own logic through the ABAP programming. For example reading data from one application and updating the same application with the modified data or reading data from one application and updating another application within the modified data etc. To read the cube (i.e. application), we can use different Function Modules like UJQ_RUN_RSDRI_QUERY, UJQ_RUN_AXIS_QUERYetc. To know the list of Function modules used for reading the cube data, go to SE37 tcode and by giving input as UJQ*, Press F4. This document will describe the functionality of the Function Module UJQ_RUN_AXIS_QUERY.This will be used to fetch the data from the cube for the Base members. This is very useful when to find the total value of a particular Parent member. Instead of adding each value of the base member, if we pass the required parent Member, this function module adds up all the base members of that Parent Member. Scenario To find the Savings for a particular month based on Personal Costs which is a parent member, then it will be easy to use this function module UJQ_RUN_AXIS_QUERY in the custom BADI, to get the corresponding BASE members data. From the above Screenshot, Total Personal costs i.e. CE0004000 = CE0004010+CE0004020+CE0004030 Total Personal Costs will get from the Planning Application by FM UJQ_RUN_AXIS_QUERY and then we will get the Budget Value for that Month from the user. Savings Amount will get from the calculations on total Personal costs and Budget value for the month which is entered by user. 2010 SAP AG 3
Step by Step Procedure The procedure for creation of Custom BADI, Cube data access, data update in cube will be described in the below steps. Appset Creation and Data upload Create an Appset with the required Applications. To load the Planning Application i.e Cube, through the Data Manager, we will be using Standard Package Import Transaction data. Sample File to be uploaded:- After successful running of the Package, the data in the Cube:- Custom BADI implementation In SE19, Create an Implementation for the BADI UJ_CUSTOM_LOGIC. 2010 SAP AG 4
Once done with the creation of Implementation Class, create a filter to call a Custom BADI from BPC.In the below screenshots, a filter keyword Value_1 is created. Once Filter is created, go the implementation class ->IF_UJ_CUSTOM_LOGIC~EXECUTE, to write our logic. A sample code is written to fetch the data for the Parent Member i.e. CE0004000. The output of the function module will be the aggregation of the base members (CE0004010, CE0004020, CE0004030) corresponding to the parent member, which is the Total Personal Costs. From the user entered Budget value, we will find the savings by subtracting the total personal costs from the budget value. If there is any Savings for that Month, it will create a new account Savings for that month. The code for the above logic is attached in the Appendix. Once done with the code, activate the BADI. 2010 SAP AG 5
Process Chain Creation In RSPC, Create a Process chain ZBPC_BUDGET to run the Custom BADI through the Data manager in BPC. Calling the BADI from BPC After activation of BADI, call the BADI from BPC using the keyword created in the Filter section. To pass any parameters from the BPC to the BADI, we can use the *START_BADI command, otherwise, we can use the *CALL_CUSTOM_LOGIC Command. Create a new Logic file BUDGET.LGF to call the BADI in BPC Admin.We can call from DEFAULT.LGF also. 2010 SAP AG 6
Creation of New Package in BPC In BPC EXCEL, Create a new Package BUDGETPACKAGE for the Process chain ZBPC_BUDGET which is created in Step3.3. Once the above Package is created, Modify the Package in the Advance Tab as below. Add the below code in the Advance Tab. 2010 SAP AG 7
The above code will prompt the user for Member selection, Logic File selection and Budget value. In addition, it will pass the Runtime Parameters like Appset name, Application name etc. to the Process Chain. Save the Package at last. Execution of BADI through Data Manager in BPC Run the Package which is created in the above step. It will prompt for the Logic File name and Members selection. 2010 SAP AG 8
By confirming the above, it will execute the Process Chain with the below message. 2010 SAP AG 9
Check the status of the Package: Now the data in Cube: A new Record is added in the cube with the Account CE071000-Savings. Total Personal costs = 4000+25000+2500 = 31500 Budget Value = 40000 p.m. (Which is hardcoded in the BADI, else we can pass this value through the Parameter to the BADI by prompting the user) Savings = 40000-31500 = 8500 2010 SAP AG 10
Validation of Data in Reports Before executing the BADI, the report:- After executing Custom BADI, the report looks like: 2010 SAP AG 11
Appendix Sample BADI Code: METHOD if_uj_custom_logic~execute. " Structure for Internal table for cube data TYPES: BEGIN OF cube_data, brand(20) TYPE c, category(20) TYPE c, entity(20) TYPE c, p_acct(20) TYPE c, time(20) TYPE c, signeddata TYPE /b28/oisdata, END OF cube_data. " internal table and workarea declarations DATA : it_cube_data TYPE STANDARD TABLE OF cube_data, wa_cube_data TYPE cube_data, wa_cube_data1 TYPE cube_data, it_axis TYPE ujq_t_query_dim, wa_axis TYPE ujq_s_query_dim, wa_member TYPE ujq_s_dim_member, wa_param TYPE ujk_s_script_logic_hashentry. *" declaration of the budget value variable. DATA : v_budget TYPE i. " for population internal table to pass the RUN_AXSIS query " Personal costs for the Jan month wa_axis-dimension = 'P_ACCT'. wa_member-dimension = 'P_ACCT'. wa_member-member_name = 'CE0004000'. APPEND wa_member TO wa_axis-member_list. APPEND wa_axis TO it_axis. wa_axis-dimension = 'TIME'. wa_member-dimension = 'TIME'. wa_member-member_name = '2009.JAN'. APPEND wa_member TO wa_axis-member_list. APPEND wa_axis TO it_axis. wa_axis-dimension = 'ENTITY'. wa_member-dimension = 'ENTITY'. wa_member-member_name = 'E_H1'. APPEND wa_member TO wa_axis-member_list. APPEND wa_axis TO it_axis. wa_axis-dimension = 'BRAND'. wa_member-dimension = 'BRAND'. wa_member-member_name = 'BRAND_ALL'. APPEND wa_member TO wa_axis-member_list. 2010 SAP AG 12
APPEND wa_axis TO it_axis. wa_axis-dimension = 'CATEGORY'. wa_member-dimension = 'CATEGORY'. wa_member-member_name = 'ACTUAL'. APPEND wa_member TO wa_axis-member_list. APPEND wa_axis TO it_axis. " To get the Overall Personal Costs parent member value CALL FUNCTION 'UJQ_RUN_AXIS_QUERY' EXPORTING i_appset_id = 'ZAPP_BADI' i_appl_id = 'PLANNING' it_axis = it_axis if_check_member_failed = space IMPORTING et_data = it_cube_data. " reading the Budget value entered by user. READ TABLE it_param WITH KEY hashkey = 'BUDGET' INTO wa_param. IF sy-subrc EQ 0. v_budget = wa_param-hashvalue. ENDIF. *"if the overall personal costs less than the budget value for Jan month, *" then add to the SAvings account. LOOP AT it_cube_data INTO wa_cube_data. IF wa_cube_data-signeddata LT v_budget. ENDIF. ENDLOOP. ENDMETHOD. wa_cube_data1-p_acct = 'CE071000'. wa_cube_data1-time = '2009.JAN'. wa_cube_data1-entity = 'E_H1'. wa_cube_data1-category = 'ACTUAL'. wa_cube_data1-brand = 'Brand'. wa_cube_data1-signeddata = v_budget - wa_cube_data-signeddata. APPEND wa_cube_data1 TO ct_data. 2010 SAP AG 13
Related Contents: How to Pass Parameters to Custom Logic BADI http://help.sap.com/saphelp_bpc70sp02/helpdata/en/66/ac5f7e0e174c848b0ecffe5a1d7730/frameset.htm Enterprise Performance Management homepage 2010 SAP AG 14
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. 2010 SAP AG 15