Customer exit in BEx to derive Cal month

hey all,
i need to write  a customer exit, to derive  prev Cal Month value from the given Calday. I have written the code but it derives the current cal month instead of previous. any suggestions ?
case I_VNAM.
  when 'ZCU_CMTH' .
    if i_step = 2.
      loop at i_t_var_range into l_s_var
              where vnam = 'ZCCCD'.
        CMTH_YR = l_s_var-low.
        l_s_range-low = CMTH_YR(6).
        CMTH = CMTH_YR+4(2).
        CMTH = CMTH - 1.
        L_S_RANGE-LOW+4(2) = CMTH.
        l_s_range-sign = 'I'.
        l_s_range-opt  = 'EQ'.
        write :/ l_s_var.
        append l_s_range to e_t_range.
      endloop.
    endif.
       clear l_s_range.
endcase.
thanks
Laura.

Hi,
Try the following logic to get the previous year month based on calday:
data :CMTH_YR (4),
         cmth_mn(2).
case I_VNAM.
when 'ZCU_CMTH' .
if i_step = 2.
loop at i_t_var_range into l_s_var
where vnam = 'ZCCCD'.
if l_s_var-low+4(2) eq '01'.
  CMTH_YR = l_s_var-low+0(4) - 1 .
  concatenate CMTH_YR  '12' into L_S_RANGE-LOW.
else.
  cmth_mn =  l_s_var-low+4(2) - 1 .
  concatenate l_s_var-low+0(4)  cmth_mn into L_S_RANGE-LOW.
endif.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
append l_s_range to e_t_range.
endloop.
endif.
clear l_s_range.
endcase.
hope it works...
regards,r
raju

Similar Messages

  • Customer exits in Bex

    Hello BW Experts,
    Could any one give me some pointers / web sites / materials / oss notes for Customer exits in Bex.
    Any help is highly appreciated.
    Thanks,

    Check Out service.sap.com/bw ... See under "SAP BW InfoIndex" there you find a section called "Exit".
    Let me warn you about Custome Exits usage in BEx ... be carefull about performances!
    Hope it helps
    GFV

  • Customer Exit to get last day of month from Year/month

    Hi Experts,
    I need to create a customer exit to get the last day of month from Cal Year month input variable.
    Examples
    1)
    User input period: 12.2008
    I need from the customer exit: 31.12.2008
    2)
    User input period: 02.2009
    I need from the customer exit: 28.02.2009
    Can someone help me with the ABAP code to achieve this with a customer exit?
    Help will be appreciated.

    Hi,
    Please use the following code,
    Second one is the suitable solution for you, I can understand that, if it leafe year then you have the problem so use the secon one.
    First one is using Period i.e. 010.2008 (December 2008).
    Secodn one is based on Date/Month.
    Note: Insted of SY-DATUm, you give your variable name
    *******To get the Last day of the Fy Period entered by User in ZFYP***
        WHEN 'ZLDAY_FI'.
          LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZFYP'.
            zbdatj = loc_var_range-low+0(4).
            zbuper = loc_var_range-low+4(3).
            CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
              EXPORTING
                i_gjahr = zbdatj
                i_periv = 'V3'
                i_poper = zbuper
              IMPORTING
                e_date  = zzdate.
            CLEAR: l_s_range.
            l_s_range-low = zzdate.
            l_s_range-sign = 'I'.
            l_s_range-opt = 'EQ'.
            APPEND l_s_range TO e_t_range.
          ENDLOOP.
    Note: in the below code I given SY-DATUM, so you change to your Month Variable like using  
    LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'XXXX'.
    ** Last Day of Current Calendar month
          zzdate = sy-datum.
          CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
            EXPORTING
              iv_date = zzdate
            IMPORTING
              ev_days = znum.
          CLEAR: l_s_range.
          l_s_range-low+6(2) = znum.
          l_s_range-low+0(4) = sy-datum+0(4).
          l_s_range-low+4(2) = sy-datum+4(2).
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO e_t_range.
    Thanks
    Reddy
    Edited by: Surendra Reddy on Jan 27, 2009 2:47 PM
    Edited by: Surendra Reddy on Jan 28, 2009 6:12 AM

  • How to get data for current week and previous week using customer exit in Bex.

    Hi everyone,
    I have a scenario in which I need to display data for current week and previous week (based on "sy_datum" the program has to calculate current week and previous week) in Bex using  Customer exit. I have created one variable in Bex Query Designer and I have written code for the variable in CMOD. But it is not working fine, (I know that we can do the same by using offset value in Bex). Can some one guide me how to achieve my requirement using customer exit.
    Thanks in Advance,
    G S Ramanjaneyulu.

    Hi krishna,
    Thanks for your quick reply, can you have a look at my code,
    case i_vnam.
    WHEN 'ZPWK_CWK'.
    ranges : pre_week for sy-datum.
    data : start_date type DATS,
           end_date TYPE dats .
    ************FM TO GET FIRST DATE OF CURRENT WEEK ************************
    CALL FUNCTION 'BWSO_DATE_GET_FIRST_WEEKDAY'
      EXPORTING
        DATE_IN  = sy-datum
      IMPORTING
        DATE_OUT = start_date.   " WEEK FIRST DATE
    end_date = START_DATE + 6.   " WEEK LAST DATE
    END_DATE   = START_DATE - 1.   " PREVIOUS WEEK END DATE
    START_DATE = START_DATE - 7.   " PREVIOUS WEEK START  DATE
    **********PREVIOUS WEEK DATES IN PRE_WEEK******************
    pre_week-SIGN   = 'I'.
    pre_week-option = 'BT'.
    pre_week-LOW    = START_DATE.
    pre_week-HIGH   = END_DATE.
    APPEND  pre_week.
    CLEAR : START_DATE,END_DATE.
    endcase.
    Regards,
    G S Ramanjaneyulu.

  • Search instring value of Variable in customer exit of bex report

    Hello experts-
    I have a situation where I need to search the records based on value  of a variable input in selection screen of bex report and according to that i need to show the results in report.
    Ex- if we have a material characteristics on selection screen,or material number has 10 digits(eg 1234567809). so the user will only type 2-3 digit(i.e 12) on selection screen, In this case I want only those records to be displyed, for which material has these 2 digits in it .
    Eg would be:
    1234567809,
    3451267809,
    9807654312.
    Could you please suggest ABAP logic for the above. Properties of variable and how many variable we have to create.
    Regards,
    Yatendra

    Hello Vineet,
    we have tried putting  ' * ' i n place of '=' in drop down screen.
    we have also tried customer exit code, please check below.
       WHEN 'ZSEARCH'.
         data: lv_string type string.
         data: wa_test type ZTEST_TOOLING.
    if I_STEP = 2.
         LOOP AT i_t_var_range INTO loc_var_range
                   WHERE vnam = 'ZTSEARCH'.
              CONCATENATE '' loc_var_range-low '' INTO L_S_RANGE-LOW.
              L_S_RANGE-SIGN = 'I'.
              L_S_RANGE-OPT = 'CP'.
              APPEND L_S_RANGE TO E_T_RANGE.
         ENDLOOP.
      endif.
    In  this code we have created two variables 1st 'ZSEARCH' which is type of 'customer exit' , and the second one 'ZTSEARCH' type of "user entry/ default value" .
    As we need the value provided by user in  ZTSEARCH (user entry), we loop at  i_t_var_range where vnam = 'ZTSEARCH'.
    But i_t_var_range doesn't contain  ZTSEARCH variable.
    Can you please suggest in customer exit code as well as in selection option.
    Thanks
    yatendra

  • Why customer exit variable to grab the current month value doesn't work?

    In CMOD, input the following code to grab the current month value from the system date:
    Grab the month value with System Date
    WHEN 'CURMONTH'.
        CLEAR l_s_range.
        l_s_range-low = SY-DATUM+4(2).
        l_s_range-sign = 'I'.
        l_s_range-opt = 'EQ'.
        APPEND l_s_range TO e_t_range.
    In Query Designer, create a formula variable CURMONTH processed by customer exit and the dimension under the Currency/Unit tab is "Number".  Put the formular variable in the column as a KF.  When running the query, the column with the formular variable shows values of "2,0000000" other than just "2" I want for the current month.  If  the dimension under the Currency/Unit tab is "date", the column with the formular variable shows values of "00/00/0000".  Any idea?  How to grab the correct current month value which is 2 from the system date.
    Thanks!

    Oh ok , try the below options, As such I dont see any errors in our code .
    Not sure if you have ABAPER's in your team, just check with them once on the FM we are trying to see .
    Next , do you hvae 0CALDAY available in your report ? If so try to restrict that field with variable "0DAT" and write the same code you have written for your formula variable , but instead change the variable name to "0DAT" and try if this gets the month . let me know if I'm not clear .

  • Customer exit in BEx Query

    Hi,
    I've created a BEx query and added a variable MCE9004 in field Ref.org.unit and this variable is mapped to a customer exit code via CMOD step 2 (post_popup).
    Basically how I want it to work is, I will select an org.unit value e.g. org.unit = A1 in tcode RSRT variable selection screen and this value will be passed in the customer exit code as shown below and retrieve the look up values and pass it to the field ref.org.unit via e_t_range.
    CASE i_vnam.
         WHEN 'MCE9004'.
    ****      IF i_step = 2.
           READ TABLE i_t_var_range INTO LS_T_VAR_RANGE
           WITH KEY IOBJNM = '0CALMONTH'.
           l_date = LS_T_VAR_RANGE-low.
           IF l_date IS NOT INITIAL.
             CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
               EXPORTING
                 day_in            = l_date
               IMPORTING
                 last_day_of_month = ld_last_day
               EXCEPTIONS
                 day_in_not_valid  = 1
                 OTHERS            = 2.
           ENDIF.
           READ TABLE i_t_var_range INTO LS_T_VAR_RANGE
           WITH KEY IOBJNM = '0ORGUNIT'.
           SELECT /BIC/ORGUNT_PR FROM /BIC/AMPA5AX0000 INTO lv_org "l_s_range
             WHERE ORGUNIT = LS_T_VAR_RANGE-low
             AND DATETO LE ld_last_day.
             l_s_range-SIGN = 'I'.
             l_s_range-OPT = 'EQ'.
             l_s_range-LOW = lv_org.
    *          l_s_range-HIGH =
             APPEND l_s_range TO e_t_range.
           ENDSELECT.
    ***** To clear value of org.unit field
    ****      READ TABLE i_t_var_range INTO LS_T_VAR_RANGE
    ****      WITH KEY IOBJNM = '0ORGUNIT'.
    ****      IF sy-subrc EQ 0.
    *****        CLEAR LS_T_VAR_RANGE-low.
    ****        DELETE i_t_var_range index sy-tabix.
    ****      ENDIF.
       ENDCASE.
    ENDFUNCTION.
    Once this code has been executed it goes back to the selection screen and there is still an org.unit value on the screen even though I have removed it in my code in red above in i_t_var_range.
    Therefore when I execute the query, the value for org.unit field is not emptied.
    Can you please teach me how to clear that value of org.unit field?
    Let me know if you need further details.
    Thanks,
    Rebekah

    hi thomas,
    yes i get your point but the thing is i need to modify a value in the import table. coz the export table is not for the org.unit field but the ref.org.unit field.
    Basically i pass in org.unit = A1 and e_t_range will have the lookup values to be passed in ref.org.unit field which is B2 and C3.
    Then when i click execute, i want my filter only to have the values B2 and C3 and A1 shud be removed.
    is there any way i could do that?
    please advice.
    Thanks,
    Rebekah

  • Migrating Customer exit  for BEX variables to BADI's

    Hi All,
    I am new to ABAP In the context of BW.
    I am  using exit RSR00001 to populate variables in BEX reports.
    I want to migrate this customer exit RSR00001 to BADI.
    Can any one please tell me how to migrate the same and how it will fire in place of exit?
    Thanks In Advance
    Dhananjay

    Hi,
    Please have a look at:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f1a7e790-0201-0010-0a8d-f08a4662562d
    Krzys

  • Regarding Customer Exit in Bex

    Hello Expers.
    Here is my scenario: I have variable which accepts the key date from the user. The requirement is to get the calmonth from the date entered by the user. According to my point of view, Writing customer exit is a best option but i do not know is it possible for me to pass the date, entered by the user, to exit? If Yes than please let me know how?
    Help required Urgently

    use the parameter I_STEP which specifies when the enhancement is called.
    The following values are valid for I_STEP:
    ·        I_STEP = 1
    Call takes place directly before variable entry
    ·        I_STEP = 2
    Call takes place directly after variable entry. This step is only started up when the same variable is not input ready and could not be filled at I_STEP=1.
    ·        I_STEP = 3
    In this call, you can check the values of the variables. Triggering an exception (RAISE) causes the variable screen to appear once more. Afterwards, I_STEP=2 is also called again.
    ·        I_STEP = 0
    The enhancement is not called from the variable screen. The call can come from the authorization check or from the Monitor.
    sample code : user enter value of date in say variable ZDATE
    l_s_range TYPE rsr_s_rangesid,
    l_t_var_range TYPE rsr0_s_var_range.
    WHEN 'ZCALM' .
    if i_step=2.
    read table i_t_var_range into l_t_var_range with key vnam = 'ZDATE' .
    if sy-subrc = 0.
    l_s_range-low = l_t_var_range+0(6).
    l_s_range-high = l_t_var_range+0(6).
    l_s_range-opt = 'EQ'.
    l_s_range-sign = 'I'.
    append l_s_range to e_t_range.
    endif.
    endif.

  • Variable with Customer Exit  on BEX

    Hi Experts,
    I have a query with a key figure 0CALDAY, restricted by the variable ZSCAL7 (Acumulated Period). This variable is defined as 'customer exit'.
    How can I see with is the exit that apply?

    Go to CMOD tcode and select project for enhancement RSR00001.
    In the Function module EXIT_SAPLRRS0_001 create click oninclude ZXRSRU01  and there find your variable.
    Hope it helps.
    Regards

  • Implenting BADI in place of customer exit in BEX reports in BW

    Hi all,
    I am new to implemrnting BADIS in to BW.
    We have already used user exit  RSR00001.
    We want to use BADI's in place of exit 'RSR00001' .
    Can any one tell me how to migrate the existing exit to BADI using tcode SAPU.
    OR any one can help me regarding implementing BADI's in place of 'RSR00001'  exit.
    Thanks'
    Dhananjay

    I am afraid there is no such BADI template in the place of RSR00001

  • Customer exit in BEx

    Dear all,
    I do not have the clear picture regarding where we write the ABAP coding in
    BEx.
    Thanks
    V.G.VG

    HI,
    In CMOD, you ned to look [or create] for project that contains enhancement RSR00001, where u can find the function module "EXIT_SAPLRRS0_001".
    try to follow some steps in 'how to' doc related to this, and sample code may useful for you
    https://websmp206.sap-ag.de/~sapdownload/011000358700002762582003E/HowToDeriveVariableValue.pdf
    https://websmp206.sap-ag.de/~sapdownload/011000358700002765042003E/HowToVerifyVariableInput.pdf
    Regards,
    DST

  • Customer exit code to populate fiscal period for prior three months

    Dear frns,
    I need an ABAP customer exit code to populate prior three month's fiscal period.
    Please update on this...thanks
    Cheers! Shana

    Hi
    Here is the code that will satisfies ur condition.
    CASE I_VNAM.
    IF I_STEP = 2.
    WHEN 'ZVAR1'.
    DATA DATE1 TYPE D.
    DATA PERIOD1 TYPE N.
    DATE1 = SY-DATUM.
    CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'.
    exporting
    l_date = date1
    l_periv = 'v3'
    importing
    E_BUPER = PERIOD2
    E_GJAHR = YEAR2.
    DATA PER3 TYPE N.
    PER3 = PERIOD2 + 1.
    CONCATENATE YEAR2 PERIOD2 INTO FPERLOW.
    DATA LDATE TYPE D.
    LDATE = SY-DATUM + 365.
    CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'.
    exporting
    l_date = LDATE
    l_periv = 'v3'
    importing
    E_BUPER = PERIOD2
    E_GJAHR = YEAR2.
    CONCATENATE YEAR2 PERIOD2 INTO FPERHIGH.
    DATA WA1 LIKE LINE OF E_T_RANGE.
    WA1-LOW = FPERLOW.
    WA1-HIGH = FPERHIGH.
    WA1-SIGN = 'I'.
    WA1-OPT = 'BT'.
    APPEND WA1 TO E_T_RANGE.
    ENDIF.
    Hope u gotit,
    Regard,
    RaviChandra

  • Bex Odata Services with Customer Exit

    Hi All,
    Im using Bex as Odata Services in order to export the result set , everything works fine until i tried to use Customer Exit in Bex...in that moment the Odata Service goes down an shows a few errors.
    Does anybody know how can i manage this?
    Thanks a lot.

    Hi Marcos,
    Can you please explain your scenario and what you have done so far (e.g. share the coding in the user exit)?
    I understand that you get a few error messages. Please share them too and display the error messages on the lowest level (with details on the error).
    Last but not least, on which BW release and SP level are you working?
    Thanks,
    Sander

  • Using variable values form parametrized URL in Customer Exit in i_step = 1

    Hello BW experts,
    I call a parametrized URL to a Web Template that has a Query with the variable VAR1:
    http://XXX?...&CMD=LDOC&template_id=TEMP1&VAR_NAME_1=VAR1&VAR_VALUE_EXT_1=2006
    Then I try to access the value of VAR1 in i_step = 1 in the Customer Exit for BEx variables in order to determine the value for a customer exit variable VAR2:
    WHEN 'VAR2'.
        IF i_step = 1.
          READ TABLE i_t_var_range INTO var_range
            WITH KEY vnam = 'VAR1'.
          fl_var_range-sign = 'I'.
          fl_var_range-opt = 'EQ'.
          fl_var_range-low = *some operation with var_range
          APPEND fl_var_range TO e_t_range.
        ENDIF.
    The problem is that VAR1 contains either the default values (if the variable is set to have default variables) or is empty (if there are no default variables defined). It does not retrieve the value in the URL in the Customer Exit, but displays it correctly in the variable screen.
    Is there any way I can acces the URL parameter in the Customer Exit?
    Thanks for any answers in advance.
    Michael

    Gili,
    thanks for your answer. The problem was, though, that the first value determines the behavior of the variable screen by setting the value of a customer exit variable.
    My goal was to have two variable screens. In the first a date is chosen and in the second a node of a time-dependant hierarchy is chosen. If one enters the date in the same screen as the hierarchy, the valid hierarchy for the date is not displayed.
    I solved the problem now in following way:
    <b>1. Saving the value in SAP Memory as a parameter.</b> The parameter has to be defined in SE80. A Dummy Web Template with a query on the same Infoprovider with just the two InfoObjects (Year/Month) displays a variable screen for Month/Year. In addition there is a Dummy Customer Exit variable that is needed in order to pass the variable values (month/year) into SAP Memory. Using JavaScript in the Dummy WebTemplate the second Web Template with the actual query is called without displaying anything else than the variable screen.
    WHEN 'DUMMY_CUSTOMEREXIT_VAR'.
        data: w_date like sy-datum
        IF i_step = 2.
          READ TABLE i_t_var_range INTO var_range
            WITH KEY vnam = 'VAR1'.
        do your peration
        i.e.  w_date(4)+2 = var_range-low.
                 w_date(6)+2 = var_range-high.
          SET PARAMETER ID 'ZBW_PARA1' FIELD w_date.
        ENDIF.
    <b>2. Retrieving the value from SAP Memory</b> Before displaying the variable screen, the chosen date is retrieved from SAP Memory and used to set the date for a customer exit variable for the hierarchy validity date.
    WHEN 'VAR2'.
        IF i_step = 1.
          GET PARAMETER ID 'ZBW_PARA1' FIELD w_date.
        do some operation with     
          APPEND fl_var_range TO e_t_range.
        ENDIF.
    It is quite a comlex construct, but it works....

Maybe you are looking for

  • Windows RDS - configuring a default connection & desktop

    I'm looking at remote desktop options and used terminal services in the past.  I'm configuring remote desktop services on a Windows 2008 R2 server.  The goal is to allow users to go to a web page, pull up a remote desktop and access apps & server sha

  • Can't get my iPhone (iPad or iPod touch) to connect to wifi

    I cannot get my iPhone 4s to connect to wifi in my home since the last two updates. It sees my network but says unable to connect. This not only happens to my iPhone 4s but to my iPad 2 and my iPod touch. Idk what else to do to get it to connect. My

  • Keyboard lights on envy m6?

    r there anykeyboard lights on envy m6 notebook 4 night use? thankyou. cheryl_k

  • Bank Reference Field

    Good Day I want to change the vendor master data and maintain the reference details for a vendor/customer. And I would like to know the following : 1. What is the function of the reference field. 2. When I maintain the reference field will the refere

  • Need help on extending my TEMP tablespace (Ora ver - 8.1.7.0.0)

    Hi I am having problem in executing the SQL query with certain parameters in the WHERE clause. ORA-01114: IO error writing block to file 4 (block # 524242) ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file OSD-04026: Invalid paramet