Customer exit code for fiscalyear period based on system date

Hi Experts,
Please provide customer exit code for fiscalyear period derive based sy-datum. Fiscal year period derivie current to previous 12 periods and current to fast 12 periods.
Thanks,
Subbaraju

Hi Subbaraju,
Please use below customer exit code for your solution. Please define declarations as per requirement.
When 'ZFPERIOD'.
IF I_STEP = 2.
ztoday = sy-datum.
zfast = sy-datum + 365.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
  EXPORTING
    i_date               =  ztoday
    i_periv              = 'K4'
IMPORTING
   E_BUPER              = PERIOD2
   E_GJAHR              = YEAR2.
CONCATENATE YEAR2 PERIOD2 INTO FISCPERLOW.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
  EXPORTING
    i_date               =  zfast
    i_periv              = 'K4'
IMPORTING
   E_BUPER              = PERIOD2
   E_GJAHR              = YEAR2.
CONCATENATE YEAR2 PERIOD2 INTO FISCPERHI.
L_S_RANGE-LOW = FISCPERLOW.
L_S_RANGE-HIGH = FISCPERHI.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.
ENDIF.
Similar code user for your previous periods also.
Thanks,
Chandra

Similar Messages

  • Customer exit - code for variable

    Hi Friends,
    I have created a variable "CUST_EXIT_YEST" and defined the processing type as customer exit. Now would like to add code in CMOD.
    Requirement: The variable should allow take yesterday's date. Please help me with the code.
    Already there are some codes defined for other customer exit variables in CMOD. Can I add my code below that. If so please explain.
    Regards,
    Surjit

    If i'm not wrong you want to show previous day in the variable.
    At the bottom of the existing code before EndCase, u can write the below code
    Data: loc_var_range      LIKE rrrangeexit, (must be there this kind of declaration in ur existing code)
    WHEN 'CUST_EXIT_YEST'.
        IF I_STEP = '1'.
          Read Table I_T_VAR_RANGE into LOC_VAR_RANGE WITH KEY VNAM = 'CUST_EXIT_YEST'.
          myrange-SIGN = 'I'.
          myrange-OPT = 'EQ'.
          myrange-LOW = sy-datum - 1.
          APPEND myrange TO e_t_range.
        ENDIF.

  • Stock report for a period (based on posting date)

    Hi Experts,
    We have a requirement as under:
    1) We want a report for a period say from 01.04.2011 to 30.09.2011 (closed period for both MM and FI postings). Report is being taken on a later date say 01.12.2011.
    2) The report should say the status of stock as of 30.09.2011 only even of being taken in the month of December
    3) I tried to take the desired report through MB5B for the period 30.09.2011 to 30.09.2011 (selection date fields) on 20th december, 2011 and noticed that if same report with the same selection criteria is taken at two different times, output data is not the same whereas MM and FI posting periods are already closed.
    Can anybody suggest alternative SAP standard report where output will remain the same if report with same selection criteria is taken at different intervals ELSE in case of change we should be able to see the documents posted in between if back dated entries have been posted after opening MM /FI period.
    thanks

    sure it speaks the same, but it mentions as well the reasons (1) and has much more information (2)  and a solution.(3)
    1)
    user starts transaction MB5B for a very large number of materials or for all materials in a plant
    During the runtime of transaction MB5B, goods movements are posted in parallel:
               - The results of transaction MB5B are incorrect.
               - Each run of transaction MB5B returns different results for the same combination of "material + plant".
    Example: Transaction MB5B should process 100 materials with 10,000 MM documents each. The system takes approximately 1 second to read the material master data  and it takes approximately 1 hour to read the MM and FI documents. A goods movement for a material to be processed is posted approximately 10 minutes after you start transaction MB5B. The stock for this material before this posting has already been determined. The new MM document is also read, however. The stock read before the posting is used as the basis for calculating the stocks for the start and end date.
    Even for an old and closed period, MB5B starts today and calculates backwards  any movement to finally get the stock for  the time your specified in your selection.
    2)
    The SAP standard release does not include a solution
    so you have to understand that there is no real alternative transaction in SAP
    3) and then they provide a large section with a workaround that can be developed by an experienced programmer within 3 to 5 days.
    So how shall anyone here be able to tell you an alternative report?
    if someone does, then it is an owndeveloped z-report which is not available in your sap system.
    if you know that people want lookup period closing stocks at any time in future, then either schedule MB52 at month end and store the list somewhere (and do not allow backposting)
    or have an Abaper create a stock report based on the history tables MARDH, MCHBH, MBEWH etc.
    And even here you may encounter an issue at some day, if you start archving special stocks or material masters, because then the stock figures from the historic tables are gone and you cannot rebuilt a reliable stock report .

  • Customer exit code to calculate  Average YTD.

    Hi Experts,
    I want to create new column ( AVGYTD TRGT) in Bex report for folling data .( Which is FF data).
    I have created one formula variable(zfmvavgytd) of type customer exit. and strucked at coding part.
    so that, anybody provide customer exit code for required column(avgytd trgt). and details are as follows.
    0CALMONTH  ENO  ENAME  PERDAY_ TRGT  
    04.2011             1     ABC             100                     
    04.2011             2     BCD             200
    05.2011             1     ABC             200 
    05.2011             2     BCD             200 
    06.2011             1     ABC             300 
    06.2011             2     BCD             200 
    07.2011             1     ABC             200
    07.2011             2     BCD             200 
    till  03.2012        
    Now I want to display the column for ( AVG YTD_TRGT)   based on "0calmonth " & " ENo  "   as below
    AVG YTD_TRGT
    100           
    200
    150
    200
    200
    200
    200
    200
    calculation behind this is...
    for 04 .2011   --empno(1)  ---100/1
    for 04 .2011   --empno(2)  ---200/1
    for 05 .2011   --empno(1)  ---200+100/2
    for 05 .2011   --empno(1)  ---200+200/2
    for 06 .2011   --empno(1)  ---300200100/3
    for 06 .2011   --empno(1)  ---200200200/3
    for 07 .2011   --empno(1)  ---200300200+100/4
    for 07 .2011   --empno(1)  ---200200200+200/4

    First you need to calcualte the YTD and then Average YTD.
    Year to Date (YTD) u2013 From the 1st to entered u201CKey Dateu201D for the current year.
    Average Year to Date - YTD divided by the u201CNo of Daysu201D in year till u201CKey Dateu201D for current year.
    Check the below code for getting Previous YTD....next create a Selection restrict the KF with YTD varaible
    Below is sample code for reference.
    to calculate "Previous year to date" (User input Calday u2013 key date)
    WHEN 'ZDAYPYR'.
    IF I_STEP = 2. "after the popup
    LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WHERE VNAM = 'ZPDATE'.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW = LOC_VAR_RANGE-LOW.
    L_S_RANGE-LOW(4) = L_S_RANGE-LOW(4) - 1. "low value previos year
    v_loc_date = L_S_RANGE-LOW. "take input value in another variable
    L_S_RANGE-LOW+4(4) = '0101'.
    L_S_RANGE-HIGH = v_loc_date. "high value = input, taken into another variable
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'BT'.
    APPEND L_S_RANGE TO E_T_RANGE.
    EXIT.
    ENDLOOP.
    ENDIF.

  • Customer Exit Code Error

    Hi All,
    i have an issue while executing customer exit code for a query.
    Its giving the following error
    WValue "07.2010" is too long for variable Z_RAPMONTHS
    EValue "07.201" for user-exit variable Z_RAPMONTHS is invalid
    EVariables contain invalid values.
    I>> Row: 82 Inc: LRRMSU13 Prog: SAPLRRMS
    ASystem error in program CL_RSR_OLAP_VAR and form INIT-02- (see long text)
    Requiremnt is: variable value should corresponds to last six months including current month (six months in total), e.g.  if we execute the report today (December month) the desired value should be 07.2010 - 12.2010.
    code which i have written is:
    when 'abc'.
        DATA: curr_month(2) TYPE n,
              calc_month(2) TYPE n,
              curr_year(4) TYPE n,
              prev_year(4) TYPE n.
        CLEAR:curr_month,curr_year,prev_year.
        if i_step eq 1.
          curr_month = sy-datum+4(2).
          curr_year = sy-datum+0(4).
          if curr_month = '01'.
            calc_month = curr_month + 7.
            prev_year = curr_year - 1.
           CONCATENATE calc_month '.' prev_year INTO l_s_range-low.
          else.
            calc_month = curr_month - 5.
          CONCATENATE calc_month '.' curr_year INTO l_s_range-low.
         else.
         l_s_range-low = lv_zp0003_year.
            ENDIF.
      CONCATENATE curr_month '.' curr_year INTO l_s_range-high.
          IF l_s_range-low = l_s_range-high.
              l_s_range-opt = 'EQ'.
            ELSEIF l_s_range-high IS INITIAL.
              l_s_range-opt = 'EQ'.
            ELSEIF l_s_range-low LT l_s_range-high.
              l_s_range-opt = 'BT'.
            ENDIF.
            l_s_range-sign = 'I'.
            APPEND l_s_range TO e_t_range.
    Can any one please let me where i am doing the mistake.
    Thanks & Regards.
    AKG

    remove the '.' from the below concatenate statements.
    CONCATENATE calc_month '.' curr_year INTO l_s_range-low.
    CONCATENATE curr_month '.' curr_year INTO l_s_range-high.
    use the code as
    CONCATENATE calc_month curr_year INTO l_s_range-low.
    CONCATENATE curr_month curr_year INTO l_s_range-high.

  • 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

  • Customer exit code to populate three month's fiscal period

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

    Dear,
    Thank u for all replies.
    My requirement is simple.
    Rows:
    Fiscal Year
    Columns
    GR Value
    Filters
    Material Number
    Input Paramters:
    Material No.
    Fiscal Year
    Using customer exit if we populate current fiscal year in the selection screen output be like this....
    FISCAL YEAR    GR Value(in crores)
    2009                     4000
    2008                     3000
    2007                     2000
    2006                     1000
    The cube name Custom Cube ZBBP_C03.
    But I dont have time char 0FISCYEAR in my Cube.In my cube avaiable chars are Calender Year,Calender Year/Month,Calender Year/Quarter,Fiscal Period
    Please let me know if you need any information.
    Waiting for replies,
    Thanks & Regards,
    Praveen.K

  • Customer Exit IMRC0001 for condition based preventive maintenance

    Dear Experts,
    I am using customer Exit IMRC0001 for creating maintenance order if my measuring point reading exeeds the thresold value or it is  out of the upper and lower limit range , which i have set for that particular Measuring point.
    This scenario is working fine if i am creating measuring point with unit *C (Degree centigrade-Temp).
    But it is not working fine for measuring point having unit other then *C
    Like : Kg/Cmsq, Bar, Run Hr, Vaccum, voltage, current, consumption etc
    The Reason for this i have found out.The logic return in the program only considers the *C unit
    Say if i set 50c as my target value in Measuring point*
    In Table IMPTT the value is getting stored as 50 + 273.15 = 323.15
    But if i enter 5 Ohm as my target value in Measring point
    In Table IMPTT the value is getting stored as 5 only.
    Target Value field name is DESIR
    So i want to know why for some units the same value is getting stored and why for some units value with some formula getting stored.
    Regards,
    Amar Jadhav

    does your characteristic allow decimals??
    also why not use deg K instead of deg C
    ignore above
    see note 525948
    Symptom
    When you change the target value of a measuring point, it seems as if the system updates incorrect values for the 'Target value' field in the change documents.
    Other terms
    IK02, IK03, IMPT
    Solution
    The internal display of field 'Measuring Point Target Value' has the SI unit belonging to the unit of measurement.
    Example:
    For temperatures, the target value can be displayed in the user interface (RIMR0-DESIC) in the units of measurement Celsius, Fahrenheit or Kelvin. However, the database display in field IMPTT-DESIR always refers to the respective SI unit Kelvin.
    As the change documents always refer to the database display, they also refer to the SI unit.
    Edited by: Virendra Pal on Oct 1, 2008 2:34 PM

  • Find SAP Exit code for Variable '0CMONTH '

    I am trying to fnd the SAP exit code for variable 0CMONTH so I can create a customer copy and make the variable 'ready for input'. Any ideas where I can find the code or a simple way to effectviely copy the delivered variable.
    I have tried looking in SE37 and then RSVAREXIT* but cannot seem to find the specific code I need.
    Thanks
    Steve

    Hi,
    Search the technical name for the variable in metadata repository and try to find the program where it is declared.  Then i hope u can go the code where it is written.
    Cheers.
    Ranga.

  • How to write customer exit code to get current user as default in variable

    Hi guys,
           I design a query which has a variable called var_employee , I also set some default values for this variable in query designer. But I would like to set the current user account who logon on (who execute the query) in the dropdownlist as default user when the variable selection screen appear. of course after that he can choose other avaiable value.
          I look up some related threads, all says that this need some customer exit code, and they mention to use CMOD to create the customer exit , but I don't know the detail process, as I am pretty new on this.
         The attribute of the var_employee  variable is :  employee(defined info object by myself) characterstic value, customer exit.
         Can somebody show me the process to create the customer exit, and the apap code in detail if possbile. then I can try.
          Thanks a lot in advance.
    Best Regards,
    Ben

    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

  • Explain the customer exit code?

    Hi,
    Any one explain this customer Exit written for a variable.
    When 'Zabcdefg'.
          clear: beg_fiscper, end_fiscper.
          call function 'DATE_TO_PERIOD_CONVERT'
            exporting
              i_date               = sy-datum
          I_MONMIT             = 00
              i_periv              = 'S1'
           importing
             e_buper              = period
             e_gjahr              = year
           exceptions
             input_false          = 1
             t009_notfound        = 2
             t009b_notfound       = 3
             others               = 4.
          if sy-subrc eq 0.
          Period = Period - 1.
            concatenate year period
                         into beg_fiscper.
            concatenate year period
                         into end_fiscper.
          endif.
          clear: l_s_range.
          l_s_range-sign   = 'I'.
          l_s_range-opt = 'BT'.
          l_s_range-low    = beg_fiscper.
          l_s_range-high   = end_fiscper.
          append l_s_range to e_t_range.
    Points will be definitely assigend.
    Vasu

    When 'Zabcdefg'.
    clear: beg_fiscper, end_fiscper.
    bold A fucntion module whcih converts the given date into the period
    call function 'DATE_TO_PERIOD_CONVERT'
    exporting
    i_date = sy-datum
    bold The date passed is the system date.
    boldThe other variable values are passed below
    I_MONMIT = 00
    i_periv = 'S1'
    importing
    e_buper = period
    e_gjahr = year
    exceptions
    bold Exceptions in case of not found values
    input_false = 1
    t009_notfound = 2
    t009b_notfound = 3
    others = 4.
    bold checking whether the execution is true and if true, the period is geting a period less minus one which is output from the function module.
    if sy-subrc eq 0.
    Period = Period - 1.
    bold joining the period and year
    concatenate year period
    into beg_fiscper.
    concatenate year period
    into end_fiscper.
    endif.
    bold passing output to the variable in the report.
    clear: l_s_range.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    l_s_range-low = beg_fiscper.
    l_s_range-high = end_fiscper.
    append l_s_range to e_t_range.

  • Customer exit code  not  fetching exact value.

    Dear All,
    My requirement is as per the user entry date
    for that date in one column   for that month in one column    for that finacial year in one column
    fo that date it is coming fine
    even for month  when i give 14/06/2010 a user entry data has to come up to 14th of that month in year also from financial year starting to  14/o6/2010.
    for tha i created three varaibles on calday
    as below
    zv_sn_dat  user entry varaible  ready for input
    zv_mtd_dat---- customer exit not ready for input
    zv_ytd_dat----- customer exit not ready for input
    and written the code as below
    for fetching the current date data
        WHEN 'ZV_SN_DAT'.
       IF i_step = 1 .
         CLEAR l_s_range.
         l_s_range-low = sy-datum.
         l_s_range-opt = 'EQ'.
         l_s_range-sign = 'I'.
         APPEND l_s_range TO e_t_range.
       ENDIF.
    For fetchin month to date ( current date)
    WHEN 'ZV_MTD_DAT'.
       DATA : month(2) TYPE n ,
              year(4) TYPE n .
       IF i_step = 2.
         CLEAR : loc_var_range,month,year.
         LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZV_SN_DAT'.
           IF sy-subrc = 0.
             CLEAR l_s_range.
             l_s_range-high = loc_var_range-low.
             year = loc_var_range-low(4).
             month = loc_var_range-low+4(2).
             CONCATENATE year month '01' INTO l_s_range-low.
             l_s_range-sign = 'I'.
             l_s_range-opt = 'BT'.
             APPEND l_s_range TO e_t_range.
           ENDIF.
         ENDLOOP.
       ENDIF.
    *(financial year starts from october first)
       For fetching the Year to Data ( Current Date)
    WHEN 'ZV_YTD_DT'.
       IF i_step = 2.
         CLEAR : loc_var_range,month,year.
         LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZV_SN_DAT'.
           IF sy-subrc = 0.
             CLEAR l_s_range.
             year = loc_var_range-low(4).
             month = loc_var_range-low+4(2).
             l_s_range-high = loc_var_range-low.
             IF month NE '01' OR month NE '02' OR month NE '03' OR MONTH NE '04' OR MONTH NE '05' OR MONTH NE '06' OR
               MONTH NE '07' OR MONTH NE '08' OR MONTH NE '09'.
               CONCATENATE year '10' '01' INTO l_s_range-low.
             ELSE.
               year = year - 1.
               CONCATENATE year '10' '01' INTO l_s_range-low.
             ENDIF.
             l_s_range-sign = 'I'.
             l_s_range-opt = 'BT'.
             APPEND l_s_range TO e_t_range.
           ENDIF.
         ENDLOOP.
       ENDIF.
    But the month to date even though iam executing from july 1st but for month to date the data is coming is JUne data
    for year also up to may there is no data , but it is showing June data.
    where the code is wrong ,
    please can anybody suggets where i was gone wrong in code.
    or  may be i was gone wrong to create varaibles all te varaibles onot on the calday?
    Thansk & Regarsd,
    sathish
    *ENDCASE.

    In debugging you can check what are the values being assigned to low and high.
    Place check points at places where you assing the high and low values.
    Double click on them during debugging, you can then find out where the logic is not fine.
    Try by commenting out the code where you are initializing the system date to variable.
    Also this would be fine for IF MONTH LT 10 instead of
    IF month NE '01' OR month NE '02' OR month NE '03' OR MONTH NE '04' OR MONTH NE '05' OR MONTH NE '06' OR
    MONTH NE '07' OR MONTH NE '08' OR MONTH NE '09'.
    -Neelesh
    Edited by: Neelesh Jain on Jul 3, 2010 6:57 PM

  • T CODE FOR OPEN PERIOD.

    Dear all Guru's
                                    I know that for closing period the T.CODE is MMPV , Pl tell
    me that wat is the code for opening period . & also suggest wat is to enter when using MMPV & ( T CODE for opening period.
    rewarded if helps.
    rc

    Dear RC,
    This T-code for opening period to company.
    it means to plant reports will take every month.so we need to close plant transactions in every month ending.then only we will see the reports of every month of plant.
    in MMPV we have to give company code and opening month name and press execute button.
    this is the main uses and functions or MMPV.
    Hope this will helps you
    Prem.

  • How to make BEX Customer Exit Variable inactive through Customer Exit Code

    Hi,
    I had created two variables VAR1 and VAR2 as Customer Exit variables
    If VAR1 is entered then it should automatically make the VAR2 as NO Entry Variable.
    vice versa also required.
    can u help me with any code in CMOD so that we can make it inactive through Customer Exit Code.
    Thanks in Advance.
    Sunil.

    What i want is not commenting the code
    I want to make the BEX Variable as inactive by using the Customer Exit Code
    EX : If value in VAR1 is entered  then VAR2 should become automatically inactive.
           If value in VAR2 is entered  then VAR1 should become automatically inactive.
    how can this be done
    Thanks in advance.
    Sunil

  • Return Custom Exit Code

    Hello Experts,
    We are using Wise Script Wrappers to run Microsoft Updates (KB). Wise Script has Exit Installation Command through which we can control the Custom Exit codes return by the setup (Wrapper) .
    Case 1
    In our case when we use shutdown.exe at the end  after installation of KB's to reboot the machine the exit code reflected in sccm is 0 though we set Exit code 100 in Wrapper.
    Case 2
    When we dont reboot at the end of installation that is we dont use Shutdown.exe the Exit code return is 100.
    We cannot use Config manager restarts computer due to our business needs
    So Any help will be appreciated on how we can  control the custom exit codes
    Thanks,
    Apppack

    So the real question is why are you using non-standard exit codes?If you do non-standard things, you will get non-standard results.
    As Jérémy pointed out 3010 means "The requested operation is successful. Changes will not be effective until the system is rebooted." There are actually other standard error codes that indicate a pending reboot also but 3010 is the most common. A complete
    list of standard error codes is available at http://msdn.microsoft.com/en-us/library/cc231199.aspx.
    Jason | http://blog.configmgrftw.com

Maybe you are looking for