· 

BW/4HANA: Customer Exit Variable with dynamic assignment

You have different ways to store the logic of your customer exit variables in SAP BW/4HANA. After my last post about Customer Exit Variables with an own enhancement spot I want to share another solution with you. In this blog post I want to show you how you can implement a BAdI implementation with a Z-Table (Customer Table). In this table you find the assignment between the BEx variable and the corresponding class for the customer exit. This is how the table will look like:

SAP BW/4HANA Customer Table with assignment between variable and class
Customer Table with assignment between variable and class

We use this table to determine the corresponding class for our variable. The table structure is very simple. Just create this table in the transaction SE11. As you see the table has only two fields.

SAP BW/4HANA Customer Table Structure
Customer Table Structure

After we have created the customer table in the transaction SE11 we go to the TA SE18 and open our own enhancement spot we created in "BW/4HANA 2.0 Customer Exit Variables with own enhancement spot".

SAP BW/4HANA Enhancement Spot
Enhancement Spot

There we create a new BAdI Implementation we will use for our dynamic assignment.

SAP BW/4HANA Create BAdI Implementation
Create BAdI Implementation

In my case I give the name ZEI_UEXIT_VAR as Enhancement Implementation, ZBI_UEXIT_VAR as BAdI Implementation and ZCL_UEXIT_VAR as class.

SAP BW/4HANA Enhancement Implementation ZEI_UEXIT_VAR with BAdI Implementation
Enhancement Implementation ZEI_UEXIT_VAR with BAdI Implementation

After we created the Enhancement Implementation, BAdI and class we now go to the transaction SE80 or to the Eclipse ADT and open our class. And add an attribute to the class.

SAP BW/4HANA Add an attribute to our class
Add an attribute to our class

We add the attribute GV_VARIABLES_EXIT with the default value IF_RSROA_VARIABLES_EXIT_BADI to our class. After we have done this, we now implement the following code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  DATA: lr_class_info TYPE REF TO cl_oo_class,
        lr_exit_class TYPE REF TO object,
        ls_var_range LIKE LINE OF i_t_var_range,
        lt_interfaces TYPE seo_relkeys.


  IF i_step = 1 OR i_step = 2.

    SELECT SINGLE * FROM zbit_uexit_var INTO @DATA(ls_uexit_var) WHERE vnam = @i_vnam.

    IF sy-subrc = 0.
      TRY.
        CREATE OBJECT lr_class_info
          EXPORTING
            clsname = ls_uexit_var-class.

        lt_interfaces = lr_class_info->get_implemented_interfaces( ).
        IF NOT line_exists( lt_interfaces[ refclsname = gv_variables_exit ] ).
          RETURN. "Interface not exists.
        ENDIF.

      CATCH cx_root.
      ENDTRY.

      TRY.
        CREATE OBJECT lr_exit_class TYPE (ls_uexit_var-class).

        CALL METHOD lr_exit_class->('IF_RSROA_VARIABLES_EXIT_BADI~PROCESS')
          EXPORTING
            i_vnam        = i_vnam
            i_vartyp      = i_vartyp
            i_iobjnm      = ls_var_range-iobjnm
            i_s_cob_pro   = i_s_cob_pro
            i_s_rkb1d     = i_s_rkb1d
            i_periv       = i_periv
            i_t_var_range = i_t_var_range
            i_step        = i_step
          CHANGING
            c_t_range = c_t_range
            c_no_screen = c_no_screen
            c_check_again = c_check_again
            c_s_customer = c_s_customer.
      CATCH cx_rs_error INTO DATA(oref).
        RAISE EXCEPTION TYPE cx_rs_error.
      ENDTRY.
    ENDIF.
  ENDIF.

After we have added the following code to our class and activate all stuff, we now can implement our logic for the two Customer Exit Variables I mentioned in the table above.

 

I hope this gives you an idea how you can implement Customer Exit Variables. If there are any questions feel free to ask.

author.


Hi,

I am Tobias, I write this blog since 2014, you can find me on twitter, facebook and youtube. I work as a Senior Business Warehouse Consultant. In 2016, I wrote the first edition of Analysis Office - The Comprehensive Guide. If you want you can leave me a paypal coffee donation. You can also contact me directly if you want.


Subscribe


  • In my newsletter you get informed about new topics
  • You learn how to use Analysis Office
  • You get tips and tricks about SAP BI topics
  • You get the first 3 chapters of my e-book Analysis Office - The Comprehensive Guide for free
* indicates required

You want to know SAP Analysis Office in a perfect detail?
You want to know how to build an Excel Dashboard with your Query in Analysis Office? 
You want to know how functions in SAP Analysis Office works?

 

Then you have to take a look into Analysis Office  - The Comprehensive Guide. Either as a video course or as an e-book.


Write a comment

Comments: 0