Home >> SAP BPC >> SAP BPC BADI – Quick Tutorial for Newbies

SAP BPC BADI – Quick Tutorial for Newbies

SAP BPC BADI - Quick Tutorial

When I jumped to learn BPC BADI ABAP  a year ago, I  struggled to find an easy tutorial to create a simple BADI which I can understand. I am certain that every consultant willing to embark on this journey had these challenges in the beginning.

Based on the above, I want to give you a quick tutorial on how you can create your first UJ_CUSTOM_LOGIC BPC BADI. If you want to learn BADIs, it is detrimental for the success to create a very simple one gradually increase the complexity.

While the post looks quite long, actually it has primarily screenshots and it shouldn’t take you more than 20-30 minutes make it work for you. The following steps will start with creating the backend components of the BADI and then it will move to the actual code in ABAP and the logic script call.

First, we need to create our BADI components and then jump to writing code. Open SAP Logon and login to Netweaver where BPC/BW is installed.

1. Go to SE19 or find the Implementation Menu

 

2. Type or select “UJ_CUSTOM_LOGIC” Enhancement spot and click on the “Create Impl.” button

 

3. Give a name and description the Enhancement Implementation

 

4. Create Object for the new enhancement implementation

Select Local Object to keep it simple. We will not transport this development.

 

5. Give again a name of the BADI implementation, Implementation class and select the BADI Definition

*Usually, classes start with ZCL*

 

6. Create Object for the new class

Again, for the sake of simplicity, use a local object to keep it simple as we are not going to transport them.

 

7. Click first on the “Filter Val.” and then on the “Combination” button

 

8. Double click on the question marks or use “Filt Val.” button

 

9. Give a name of the filter value (It is used in the Logic Script to call the BADI implementation)

 

10. Create implementation Method by going to “Implementation Class” and double click on the “Execute” method

 

Save the enhancement

 

 

Do the Same for INIT and CLEANUP classes to remove the warnings after that.

 

 

11. Activate everything created so far

 

12. Go back all the way to the main menu and start transaction SE80 or use the menu tree

 

13. Go to Execute Method and open it in edit mode

 

14. Copy and Paste the code below

  METHOD IF_UJ_CUSTOM_LOGIC~EXECUTE.


    DATA: LS_REC   TYPE REF TO DATA,
          LT_FINAL TYPE REF TO DATA,
          ORIG_AMOUNT TYPE UJ_SIGNEDDATA.


    FIELD-SYMBOLS:
          TYPE ANY, "Dimension
             TYPE ANY, "Dimension
       TYPE ANY, "Dimension - holding the value IT is Standard
             TYPE ANY,
           TYPE STANDARD TABLE.

    "Create the table  for collecting the new entries
    CREATE DATA LT_FINAL LIKE CT_DATA.
    ASSIGN LT_FINAL->* TO .

    "Creating the Line structure
    CREATE DATA LS_REC LIKE LINE OF CT_DATA.
    ASSIGN LS_REC->* TO .
    "Add your dimensions here
    ASSIGN COMPONENT 'ET_ACCOUNT' OF STRUCTURE  TO . "Dimension ET_ACCOUNT is the dimension creating the BPC Model
    ASSIGN COMPONENT 'ET_FLOW' OF STRUCTURE  TO . "Dimension ET_FLOW is the dimension creating the BPC Model
    ASSIGN COMPONENT 'SIGNEDDATA' OF STRUCTURE  TO . "Standard


    "Main loop where we generate two new records based on the Context (Either based on the default entry or based on the *XDIM_MEMBERSET
    "We are not using , but you can use it if you want
    LOOP AT CT_DATA INTO .

      ORIG_AMOUNT = . "Keeping the original amount

      IF  = 'PL4100'.    "Checking for specific member
         = 'PL7200'.     "Assining to a different member
         = ORIG_AMOUNT * '0.4'. "Changing the originating value
        APPEND  TO . "Creating a new record with the same value as the original amount
         = 'PL7300'.
         = ORIG_AMOUNT * '0.2'. "
        APPEND  TO .   "Creating a new record with differnt value and member
      ENDIF.

    ENDLOOP.

    CT_DATA = . "Assigning the new records to the BPC BADI Internal Table which will write them to the Database

  ENDMETHOD.

15. Change the dimensions and the members according to the model and account dimension you have

 

16. Check and activate the code, there shouldn’t be any errors

 

17. Go to BPC Web admin and place a *START_BADI/*END_BADI in DEFAULT

*START_BADI ZBPC_TESTBADI 
  QUERY = ON 
  WRITE = ON
*END_BADI

 

18. Test your Input Template with the code

In my case, I am entering 1400 on PL4100 which is in the IF statement and then create two records for accounts PL7200 and PL7300.

 

Recap

Topics worth covering after this tutorial are related to how to debug the BADI, read master data and read transaction data within the BADI itself. One of the best and straightforward exercises for a new learner is to create a logic for FX translation which involves reading master data (rate types) and reading transactional data from a rates model (FX rates).

I hope you enjoyed the post and by following it you have managed to create a working BPC BADI.  Keep in mind that while you can relatively easy start to create and write BADIs, it will take much longer to master it compared to Logic Script or VBA in SAP BPC for example. Please use the comments below and have fun while learning :).

About Emiliyan Tanev

Hello, My name is Emiliyan Tanev. I am SAP BPC Certified Application Associate with a good process understanding of FICO. I am also an experienced accountant and financial controller with 5+ years of diversified responsibilities. I am also a member of Management Accounting Body in the UK - CIMA and CGMA in the US. I love IT and Finance which impacted my career orientation towards SAP FICO and BPC. Follow me and get the latest tips, tricks, tutorials and career guides related to SAP BPC. More about me on My Story.

Check Also

Energy Efficient SAP HANA Server Build for Home

SAP HANA Home Server PC Build (Energy Efficient)

In my last post, I wrote about my intentions to build another PC Build which …

2 comments

  1. dear sir, can you mail me or post similar posts for sap fico consultant training

    thanks

Leave a Reply

Your email address will not be published. Required fields are marked *