Thursday, April 25, 2013

Use of customer exit Variables in BI


By Venkat Suman B, IBM India
Scenario: The selection screen variable Month/year should be optional and if user inputs any value the Query should run for that selection condition else if user doesn’t input any values it should pick the dates as high = (current calmonth)  and low = (current calmonth – 3 months)
Solution: create two customer exit variables one having properties not ready for input & other as ready for input. The code is written for I_STEP = 2 for not ready for input variable but calling other variable in this code.
Let’s Consider a TEST Query.
Changes to be done in Query designer
Open the query in query designer
ZVBICALL is a customer exit variable with not ready for input.
ZVBICALM  is a customer exit variable with ready for input.
Save the changes.
Creation of Customer exit variables & ABAP devlopment
Go to Tcode CMOD in BI system and specify the Project name
It should consist of following enhancements
In the Components tab goto exit EXIT_SAPLRRS0_001 and INCLUDE ZXRSRU01.code should be written in this Custom Include only.
Code in Include ZXRSRU01
TRY.

    
DATA : l_name TYPE seoclsname.

    
IF i_step <> 3 .
      l_name = i_vnam.
    
ELSE.
      l_name = i_s_rkb1d-compid.
    
ENDIF.

    
CALL METHOD (l_name)=>Z_IF_REPORT_VARIABLE~execute
      
EXPORTING
        i_vnam        = i_vnam
        i_vartyp      = i_vartyp
        i_iobjnm      = i_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
      
IMPORTING
        e_t_range     = e_t_range
        e_meeht       = e_meeht
        e_mefac       = e_mefac
        e_waers       = e_waers
        e_whfac       = e_whfac
      
CHANGING
        c_s_customer  = c_s_customer
      
EXCEPTIONS
        again         = 
1
        
OTHERS        = 2.

    
IF sy-subrc = 1 .
      
RAISE again .
    
ENDIF.
  
CATCH cx_sy_dyn_call_error .ENDTRY.  
Here Z_IF_REPORT_VARIABLE is an Interface which has got a method Execute
During the runtime we get variable name into l_name & step value in i_step.
So we should be creating a class same as Variable name i.e value we get in l_name.
This is the declaration of Interface Z_IF_REPORT_VARIABLE in se24 Transaction
Create class ZVBICALL in Tcode SE24
Create class ZVBICALL giving the interface name in interface tab
Automatically the method is created, now click on CODE icon to write the code.

method Z_IF_REPORT_VARIABLE~EXECUTE.

 
CONSTANTS: c_zvbicalM  TYPE char8 VALUE 'ZVBICALM',
            c_zvbicall  
TYPE char8 VALUE 'ZVBICALL',
            cn3       
TYPE tfmatage VALUE -3,
            c_sign_i 
Type char1 value 'I',
            c_range_opt_bt 
type char2 value 'BT'.
DATA: l_year         TYPE n LENGTH 4"Holds Year
      l_month        
TYPE n LENGTH 2"Holds month
      l_s_range      
TYPE rsr_s_rangesid, "Range Table of type E_T_RANGE
      l_date      
TYPE sy-datum,          "Holds the date
      wa_t_range 
type RRRANGEEXIT.

 
IF I_STEP = 2.
    
CASE i_vnam.
    
WHEN c_zvbicall.
READ TABLE I_T_VAR_RANGE WITH KEY VNAM = c_zvbicalm TRANSPORTING NO FIELDS.

     
if sy-subrc NE 0.
        
CLEAR   l_s_range.

        l_year  = sy-datum(
4).
        l_month = sy-datum+
4(2).* this fm is going to give back the previous3thmonth

        
CALL FUNCTION 'FIMA_END_OF_PERIOD_DETERMINE'
          
EXPORTING
            i_date               = sy-datum
            i_months             = cn3
          
IMPORTING
            e_date_end_of_period = l_date.

        
CONCATENATE  l_date(4) l_date+4(2)   INTO   l_s_range-low.
        
CONCATENATE  l_year    l_month       INTO   l_s_range-high.
           l_s_range-
sign       = c_sign_i.
           l_s_range-opt        = c_range_opt_bt.
*         l_s_var_range-VNAM       = c_zvbicalm.
*         l_s_var_range-IOBJNM     = c_z_tec0_m.
          
APPEND l_s_range TO e_t_range.
   
endif.
    
endcase.endif.
 
endmethod.
There is no need to create ZVBICALM class. This is just a dummy variable for display purpose.
Executing the Query
Click on execute button
Here (*) implies mandatory fields, give values for those.
As u can see there are no values given for Variable Month/year
This is the output we get for these selection criteria.
Click on Info tab to get our selection criteria values.
The period value for TECO Month has come from variable ZVBICALL (customer exit variable) as you can see below even though Month/Year variable is empty.
 ZVBICALL-low = 11.2010((current month- 3months) and ZVBICALL-high = 02.2011(current month)
 
Here I try to give the values same as we get from our exit variable to check if we get same output in both cases.
Since we input the values for Month/Year in selection screen we get value directly into TECO month from Month/Year variable. Check selection criteria values in Info tab

No comments:

Post a Comment