Skip to Content
This topic is about Bex Variable Exits. Variables are parameters of a query that are defined in the BEx Query Designer and that are filled with values when you execute the query. The processing type determines how a variable is filled with a value for the runtime of the query. The Exits are one of the ways in which the charactetistics value in a query can be restricted, using a variable. These exits are triggered or called on certain moments during the data processing. This can be explained by the use of one of requirement in our new product, SCPM (Supply Chain Performance Management).

The requirement is as follows: There is a Keyfigure value which is to be filled up using an Input Ready query for the first date of the month. Only the value for the calmonth will be provided by the user. For the sake of convenience, say the name of this key figure is Perfect Order Fulfillment (POF).

For this we created a Input Ready Query on a real time cube. This query was then used in a Bex Analyzer workbook, to input and further save the data into the cube. The Keyfigure in this query is POF and the characteristic is both calday and calmonth. The calmonth has been restricted with a variable which is of a Manual Entry type. The variable will be of type Value Range, which provides a higher and lower value for the calmonth. There were some requirement constraint, because of which, the calday had to be populated by the data that is entered for calmonth. It could not be directly provided by the user.

Once the query was ready, we proceeded as follows for the creation of the variable exit would be used for the characteristic restriction.

  • Go to the Filter Tab of the Query

  • Select the Characteristic for which the Exit Variable has to be developed. Select the option ‘Restrict’.

  • A screen for the variable restriction opens up.

/wp-content/uploads/2009/01/5_57391.jpg

  • Select ‘Variable’ from the ‘Show’ dropdown. Click on the Create Button
  • The Variable Editor Screen opens up.

/wp-content/uploads/2009/01/4_57392.jpg

  •  Provide a description and Technical Name (in this case its – 0SPM_VAR_CDAY) to the Variable Exit. In global setting provide the following information
  •  Type of Variable  – Characteristic Vale

  • Processing By – SAP Exit

  • Reference Characteristic – Calendar Day

 

  •  You can create it as a optional or mandatory parameter in the Details Tab, and then save it.
  • A function module containing the technical name of the variable then gets created. Go to the transaction for Function Builder (se37). Search the created function module using the technical name.

1.JPG

  • There are a few parameter in this exit which are explained below , like

    a.    I_VNAM = Input Parameter containing the technical name of the variable

    b.    I_STEP = Input Parameter, with values 1,2 or 3, which means as follows:

    I_STEP = 1 -Called prior to processing of variable pop-up and for each “customer exit” variables. Can be used to fill variable with default values.

    I_STEP = 2 -Called after the processing of the variable pop-up. Only for those variables that are not marked as “ready for input” or are set to “mandatory variable entry”.

    I_STEP = 3 -Called after all variable processing and gets called only once and not per variable. Here you can validate the user entries

    c.    I_THX_VAR = Input parameter, containing the value Range provided by the user.

    d.    E_T_RANGE = Changing parameter containing the value Range modified by the exit

 

  • The following code is then used to retrieve the first day of the month, with the user input data , for calmonth

         DATA:   l_s_range type rsr_s_rangesid,

              l_s_var type rrs0_s_var_range,

              l_r_var_range like line of i_thx_var,

              l_r_range type rrrangesid,

             zvalue_low type n length 6,

             zvalue_high type n length 6,

             zno_of_months type i,

             zlow type d,

             zhigh type d,

             zdays type table of casdayattr,

             zdays_wa like line of zdays.

    *When the Variable name is 0SPM_VAR_CAL_MNTH and the processing of the variable takes place after the pop up, get all the high and low range value for calmonth

      case i_vnam.

        when ‘0SPM_VAR_CDAY’.

          if i_step = 2.

     Read table i_thx_var with key vnam = ‘0SPM_VAR_CAL_MNTH’ into l_r_var_range transporting all fields.

            if sy-subrc eq 0.

              loop at l_r_var_range-range into l_r_range.

                zvalue_low = l_r_range-low.

                zvalue_high = l_r_range-high.

              endloop.

     

    *The function Module ‘DAY_ATTRIBUTES_GET’ is used for getting the days of a month

              concatenate zvalue_low ’01’ into zlow.

              concatenate zvalue_high ’01’ into zhigh.

              call function ‘DAY_ATTRIBUTES_GET’

                exporting

                  date_from      = zlow

                  date_to        = zhigh

                tables

                  day_attributes = zdays

                exceptions

                 factory_calendar_not_found       = 1

                 holiday_calendar_not_found       = 2

                 date_has_invalid_format          = 3

                 date_inconsistency               = 4

                 others                           = 5.

    *If a particular day is the first day of the month, then it is passed to the changing parameter

              if sy-subrc eq 0.

                loop at zdays into zdays_wa.

                  if zdays_wa-date+6(2) eq ’01’.

                    l_s_range-low = zdays_wa-date.

                    l_s_range-high = zdays_wa-date.

                    l_s_range-sign = ‘I’.

                    l_s_range-opt = ‘EQ’.

                    append l_s_range to e_t_range.

                  endif.

                endloop.

              endif.

            endif.

          endif.

      endcase.

    endfunction.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Pankaj Patil
    Hi,

    I know manual input variable is used for reading, but can a replacement path variable be read in i_step = 2 for getting the output to a customer exit variable?

    Thanks,
    Pankaj

    (0) 

Leave a Reply