Calculating Planning month

Hello,
If i want to calculate planning month from a given date, using function module "week_get_first_day".
my logic is same as we see in SM37, in the job start condition.
if the days in the week are more than 4 the whole seven days are included in current month in not then in previous month.
Seeking advice and solutions.
thankyou in advance.

Hi Abhishek ,
Please use following code and use spaces and brackets in same way as given to avoid syntax errors.
DATA:  V_INPUT_DATE LIKE SY-DATUM ,
            V_OUTPUT_DATE LIKE SY-DATUM,
            V_WEEK(6) TYPE N,
            V_PLANMONTH(2) TYPE N.
***CALCULATE WEEK IN WHICH YOUR INPUT DATE COMES
CALL FUNCTION 'DATE_GET_WEEK'
  EXPORTING
    DATE               = V_INPUT_DATE
IMPORTING
   WEEK               = V_WEEK
EXCEPTIONS
   DATE_INVALID       = 1 .
***CALCULATE FIRST DAY OF THAT WEEK
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
  EXPORTING
    week =  V_WEEK                   
  IMPORTING
    date =   V_OUTPUT_DATE           
  EXCEPTIONS
    WEEK_INVALID = 1  .        
***IF INPUT DATE AND FIRST DAY OF WEEK ARE IN SAME MONTH AND WEEK HAS 4 OR MORE DAYS LIES IN CURRENT MONTH
***OR
***IF FIRST DAY OF WEEK IS NOT IN CURRENT MONTH BUT STILL THAT WEEK HAS 4 OR MORE DAYS IN CURRENT MONTH
IF ( (  V_INPUT_DATE4(2)  =  V_OUTPUT_DATE4(2)  )  AND  (  V_INPUT_DATE6(2)  -  V_OUTPUT_DATE6(2) GE '04'  )  )  OR  (  V_INPUT_DATE+6(2)  GE  '04'  ) .
     V_PLANMONTH  =  V_INPUT_DATE+4(2).
ELSE.
***PLANNING MONTH IS LAST MONTHOTHERWISE
     V_PLANMONTH  =  (  V_INPUT_DATE+4(2)  -  1  ) .
ENDIF.
let me know if you have any other help required .I think this will fulfill your requirement.
Regards,
Jaya

Similar Messages

  • Planned Monthly Depreciation

    Hi
    I need help understanding how the system has calculated the planned monthly depreciation for specific asset..
    The asset has a Acq value of £5739.35, the useful life is 6 years. The first years depreciation is £1028.35 which ok. But its the way SAP has split by period that I need help understanding:
    Period 8 = 685.35-
    Period 9 = 86.00-
    Period 10 = 85.00-
    Period 11=86.00-
    Period 12= 86.00-
    I would have expected the total depreciation of 1028.35 to be split by the 12 periods therefore Period 8 should be 685.56- and the remaining £342.79 to be spit across the 4 remaining periods at £85.70 each.  I checked transaction OAYO and company rounding is set to "arithmetic".
    thanks for your help.

    Thanks for your input, I understand the system is calculating tax for the current year but I need to understand what process the system is following to determine each monthly amount,  for example the total depreciation for periods 9-12 is £343 I would have expected this to be split equally between the 4 periods but this is not the case, that's why I want see the calculation process behind these figures.
    thanks

  • Function module for calculating planned and actual cost of production order

    Hi ,
    Do we have any standard function module for calculating planned and actual cost for production order?
    i need to implement this in a Z-report.
    Thanks
    Srini

    Hi,
    try below function module
    CRMCO_GET_PLAN_ACTUAL_COSTS
    CO_IH_GET_PLANNED_COSTS_TOTAL
    Regards,
    Sankaran

  • Calculating prior months using off-set and crossing to prev year

    Gurus,
    I am getting current month period based on user entered value and calculating prior month by off-setting current month by 1.
    it works fine when current month value is greater than 1. If it is 1, prior month does get evaluated as 12 of previous year.
    Example...
    If Current period is - Feb, 2008 (02/2008). previous period comes fine as Jan, 2008.
    If current period is Jan, 2008 (01/2008) perious period is unknown. (I want it to be 12/2007).
    is there way to handle this without too much coding etc?
    Regards,
    -SM

    Mayank,
    What is SAP variable for Fical Year/Period, which will have both month and year value? (I guess I need to Fiscal posting period rather than Cal month?)
    Also what is SAP variable for Quarter/Year? I need to off-set of quarter also.
    Thanks, -SM

  • I have monthly subscription app how can i know about who cancel subscription ? and how i can calculed the monthly revenue ?

    i have monthly subscription app how can i know about who cancel subscription ? and how i can calculed the monthly revenue ?

    Apple20141 wrote:
    Or open sim tray and find out the carrier ring the carrier and give them numbers on sim
    The carrier will not give out information about the owner of the phone.

  • KP26 changing planned monthly amounts after using LTP

    Dear all,
    We used LTP to receive the planned quantities and calculate the planned prices in KP26.
    Following steps were executed:
    KSPP copy quantities from LTP to scheduled quantities. These are currently not correct in the distribution per month and cannot be adapted in LTP
    KPSI copy scheduled quantities to planned quantities : total amounts on planned quantities are correct so via KP26 we changed the planned quantities to equal quantities per month with a total = scheduled quatitiy but per month we can have a big differences
    KP06 planning on cost centers
    KSUB assessement planning
    KSS4 plan splitting
    KSPI = quit a lot of error messages as month planned quantity <> quit a lot from scheduled quantities --> error message KP236.
    In het settings of KSPI I used a tolerance of 100% and 'post anyway' but SAP used the scheduled quantities if this error arise which does not empty all the cost centers nor does it calculate the price correctly.
    Any sollutions know please?
    Can the scheduled amoutns be deleted so that it does not look at it anymore? I saw in other communications to use KP06, but this screen does not have the scheduled quantities nor can you change anything on secondary accounts like activity.
    Kind regards, Hilde

    Hi Hilde,
    The below is taken from SAP Note 597159 - Price calculation seems to calculate incorrect values :
    7. In the case of a plan that is not reconciled, the plan price is calculated on the basis of the scheduled activity.
    A plan is reconciled if the scheduled activity for each activity type is the same as the plan activity. You receive a scheduled plan with the plan reconciliation (Transaction KPSI). In this case, the prices are calculated based on the price indicator of the activity type:
    Price indicator 01:
    Fixed price : Fixed planned costs / planned activity
    Variable price: Variable planned costs / planned activity
    Total price: Fixed price + variable price
    Price indicator 02:
    Fixed price: Fixed planned costs / capacity
    Variable price: Variable planned costs / planned activity
    Total price: Fixed price + variable price
                    In the price calculation, a plan that is not reconciled can sometimes lead to prices that are meaningless. In particular, the cost center is not fully credited. You must distinguish between the following two cases: 
    Planned activity > scheduled activity:
    The calculation occurs as in the described reconciled case. In the list of results of the price calculation, this is indicated in the column "PL<>DL" (the same applies for capacity instead of scheduled activity).
    Planned activity < scheduled activity:
    The calculation occurs with the scheduled activity instead of the planned activity or capacity. In the list of results, the system issues error message KP236. The results are not updated, unless the "still post" indicator is set in the settings for the price determination. See the long text of message KP 236 for further information (the same applies for capacity instead of scheduled activity)."
    I'm afraid system response can't be changed here.
    Why in your case LTP can't pass correct quantities per period?
    Regards,
    Szymon

  • APO Demand plan monthly data is not assigned correctly after replication to HANA

    Hi All,
    We are replicating the APO live-cache toHANA using a APO Data Replication Model. Replication of Planning Data - SAP HANA Live for SAP SCM -
    Replication of the Planning Book to HANA is working for weekly data. Weeks in HANA reconcile correctly back to the APO Planning Book. However months are not being correctly assigned to the data. All data for each week is being assigned to only one month in HANA.
    When tested by extraction to a BW cube/DSO first then DSO replicated to HANA the data is correctly assigned to months and weeks. There is something different which is happening in the replication of the APO Replication Model that is not correctly assigning the months.
    Has anyone had this problem before?
    Thanks,
    Steve.

    Reading that, it has not improved and its May 2014.
    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

  • Calculating Previous Month(s) From Current Date

    Greeting JavaScripting Gurus!
    I would like to ask for some assistance on Date Calculation.
    Here is my current scenario:
    The user inputs a date mm/dd/yyyy ("DateField")
    The powers that be over here are asking for the "DateField" to then calculate these items:
    "DateField" minus(-) 12 months = mm/yyyy ("12MonthsAgoDateField")
    "DateField" minus(-) 18months = mm/yyyy ("18MonthsAgoDateField")
    "DateField" minus(-) 36 months = mm/yyyy ("36MonthsAgoDateField")
    and so on...
    I've read some of the Date Calculation posts, but could no seem to find anything that fit this scenario.
    I freely confess my javascripting ability is very minor.
    I would greatly appreciate any help in scripting this.
    Thank you!

    Unfortunately the numbers of days in a month or year are not the same for all months or years, so the get and set date methods might not work. Fortunately there are the getMonth() and setFullYear() methods for getting or setting the month or year for a given date.
    For the "On Blur" action for the "DateField" you can use:
    function GetField(cName) {
    // get a field object with error catching;
    var oField = this.getField(cName);
    if(oField ==  null) app.alert("Error accessing field named: " + cName, 0, 0);
    return oField;
    } // end GetField function;
    function AddMonths(oDate, nMonths) {
    // add nMonths to oDate object;
    oDate.setMonth(oDate.getMonth() + nMonths);
    return oDate; // return adjusted date object;
    } // end AddMonths;
    function Scand(cFormat, cDate) {
    var oDate = util.scand(cDateFormat, event.value);
    if(oDate == null) app.alert("Error converting " + oDate.valueAsString + " with format: " + cDateFormat, 0, 0);
    return oDate;
    } // end Scand functon;
    var cDateFormat = "mm/dd/yyyy"; // format for date strings;
    // event value is the start date string;
    // 12 months ago;
    var o12MonthsAgo = GetField("12MothsAgoDateField")
    var oDate = Scand(cDateFormat, event.value);
    oDate = AddMonths(oDate, -12) // subtract 12 months;
    o12MonthsAgo.value = util.printd(cDateFormat,oDate);
    // 18 months ago;
    var o18MonthsAgo = GetField("18MothsAgoDateField")
    oDate = Scand(cDateFormat, event.value);
    oDate = AddMonths(oDate, -18) // subtract 18 months;
    o18MonthsAgo.value = util.printd(cDateFormat, oDate);
    // 36 months ago;
    var o36MonthsAgo = GetField("36MothsAgoDateField")
    oDate = Scand(cDateFormat, event.value);
    oDate = AddMonths(oDate, -36); // subtract 36 months;
    o36MonthsAgo.value = util.printd(cDateFormat, oDate);
    // and so on;
    Since getting a field object, converting a date string to a date object and adjusting the date object using the getMonth and setMonth methods are repeated several times I have used functions so the repeated code could be reused.

  • Year to Date Value to be Calculated from Month Numbers

    We have an IP Application running.  We are using a copy of the standard ECCS Transaction Data Cube to do the Planning by Consolidation Item (Profit & Loss and Balance Sheet).
    We have two key figures - Month Value and YTD Value.
    On the planning layout when the user enters the for the month value we need the key figure for the month to be updated as well as the YTD value to be updated based on the entries in the for the month key figure from Jan of the year to the month of entry.
    Is this possible either on the layout or through a FOX function.
    Thanks a lot for your help in advance.

    Would you be able to share some sample code if you have any?
    Thanks

  • Installment Plan monthly charges

    Hi, I saw there is an option to spread the charges on all months.  But the monthly charge remains the same. 
    Is there a way to calculate for variable monthly charges based on certain formula and add that amount to the expected monthly installment amount? 
    Follow up question if its possible, is it also possible to display the 2 amounts (monthly installment amount and monthly charge) as 2 separate items in the customer's invoice?
    Thanks and kind regards.

    Hi ,
    First of all there is no formula based insatllment charges in FICA in standard SAP .
    It is either a one time or frequency based as per the installment type configuration .
    IF you want a formula based then you will have to go for event 3032 where in you can change the installment charges .
    Secondly , as you are talking of segregation then , in installment plans the Sub transaction for charges are diffrent as that of installments .
    0080 - Main 0010 - sub = Installments .
    0080 - Main 0020 and 0030 = Installment charges .
    Hope this suffices .
    Regards ,
    Dewang T

  • Calculating next month for December month

    Hi,
    I am able to get the value for a measures in which one measure calculates value for month selected through prompt and another measure calculates values based on next month.
    So I have restriced measure 1 like this in where condition
    MONTH_V.MONTH_IN_YEAR_NUM=@Prompt('2. Month :','A','Prompt\Month',Mono,Constrained)
    Second measure I have restricted like this
    MONTH_V.MONTH_IN_YEAR_NUM=(to_number(Substr(@Prompt('2. Month :','A','Prompt\Month',Mono,Constrained),1,2))+1)
    This works perfectly alright.
    I have prompt for year also. So when I select December - 08 then the calculation goes wrong, since MONTH_IN_YEAR_NUM=13 and there is no corresponding record for 13.
    So my question here is can I use CASE statement for this.
    MONTH_V.MONTH_IN_YEAR_NUM=
    (CASE WHEN (to_number(Substr(@Prompt('2. Month :','A','Prompt\Month',Mono,Constrained),1,2))<>12 THEN
    (to_number(Substr(@Prompt('2. Month :','A','Prompt\Month',Mono,Constrained),1,2))+1)
    ELSE 1
    AND
    MONTH_V.MONTH_YEAR=
    CASE WHEN (to_number(Substr(@Prompt('2. Month :','A','Prompt\Month',Mono,Constrained),1,2))<>12 THEN
    (@Prompt('3. Year :','N','Prompt\Year', mono ,constrained)
    ELSE
    (to_number(@Prompt('3. Year :','N','Prompt\Year', mono ,constrained)+1)

    Hi,
    Create 2 condition objects with prompt in universe. one for current month and another for next month from current month.
    In report take data from 2 data providers. One for current month and one for next month and apply the corresponding conditions and also take the corresponding measures.
    Hope this will help you.
    Regards,
    Rakesh K

  • Calculating MoM (Month-over-Month)

    I wrote the following script, but I am unable to validate it. I get the following error message; Error: 1012016 Cannot calculate dimension member [MoM] with restricted member [M01]. When I remove the Year Total from the Fix, then I'm getting another error message.
    //ESS_LOCALE English_UnitedStates.Latin1@Binary
    SET UPDATECALC OFF;
    SET AGGMISSG ON;
    /************* Calculate MoM, QoQ *************/
         FIX(&PriorYr, &CurYr, @RELATIVE("Year Total",0),
    @RELATIVE("Function Code",0), @RELATIVE("Entity",0), @RELATIVE("Line of Business",0),
    @RELATIVE("Local 1",0), @RELATIVE("Local 2",0), @RELATIVE("Scenario",0))
    "Mom"(
    IF (@ISMBR("M01"))
    "MoM" = (&CurMth) - (@MDSHIFT("M12",-1,Years,));
    ELSE
    "MoM" = @VAR(&CurMth, &PriorMth);
    ENDIF)
    ENDFIX

    OK, so in the Period dimension you are FIXing on the level-zero descendants of 'YearTotal' (which does not include MoM) and then attempting to calculate a member in the Period dimension that does not fall within that FIX. As the Error Message Reference says re the code you're getting:
    "The calculation script contained a calculation that tried to calculate a member after restricting the calculation to a different member in the same dimension."But regardless of why you're getting this specific error, I can't see how what I think you're trying to do is ever going to work with 'MoM' (your month-on-month movement) in the same dimension as the Periods. Think about what an Essbase retrieve looks like - how would you query 'MoM' for a specific Period? They're both members in the same dimension - any one cell in your retrieve can only relate to either 'MoM' or a specific period.
    Generally this type of functionality is achieved with a separate 'Analytic Dimension' that contains the variance members, often dynamically calculated.

  • Calculating Planned Prices

    Hi,
    Can any one pls explain what is the exact function of T Codes KP06 and KP26 and KSPI.
    I have planned quantities for the cost elements and activity wise, after that I have entered the price for that particular activity in KP26, and then I calculated the planned price using the TCode KSPI, and then I have run the KP96 ( activate integrated planning) to transfer the planned values to the cost centers.
    Is this the right path?, please guide me. How does the price will be calculated in KSPI and please explain me what is "Total Value in report currency" and "Total Fixed and variable quantity"
    regards,
    Aman

    Dear,
    1) KP26-Activity Planning
    2) KP06-Cost element Planning
    3) KSPI- Price calculation
    In KP06 we are planning input based on primary cost element. Sametime in KP26 we are planning the capacity based on secondary cost element.
    The activity rate will be calculated only based on your secondary element. While creating an Activity type you will be assigning a secondary cost element in the master data, which will capture the cost during confirmation of order. Hence the planning cost by logic will also captured from the secondary cost elements only.
    In KP06 u have to give ur COST ELEMENT and COST CENTER, in KP26 we have to give Activity Type rate for perticural time period say year  and  they are assign to the COST CENTER 
    KSPI is use to get average of planned price
    Hope it will help you.
    Regards,
    R.Brhmankar

  • Calculating years,months & days

    Hi,
    i have to calculate the time duration in years,months and days between contract_start_date and contract_end_date
    eg: Contract_Start_Date = '17-nov-2006' and Contract_End_Date = '21-jan-2008'

    Rehman wrote:
    Hi,
    i have to calculate the time duration in years,months and days between contract_start_date and contract_end_date
    eg: Contract_Start_Date = '17-nov-2006' and Contract_End_Date = '21-jan-2008'It's not the simplest of things to work out.
    If you use the intervals it will, like any other calculation, struggle with the fact that there are different number of days in the month and leap years to take account of.
    Whilst it's simple enough to determine how many whole years have passed and how many months difference there is, the moment you start to take account of the days you become stuck because days in conjunction with months cause the day calculation to be a little more indeterminate...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
      2             select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
      3             select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
      4             )
      5  -- end of test data
      6  select c_start_date, c_end_date,
      7         to_char(c_end_date,'YYYY')-to_char(c_start_date,'YYYY')
      8        -(case when to_date(to_char(c_end_date,'DD-MM')||'-1900','DD-MM-YYYY') <
      9                    to_date(to_char(c_start_date,'DD-MM')||'-1900','DD-MM-YYYY') then 1 else 0 end) as years_between
    10        ,case when to_date(to_char(c_end_date,'DD-MM')||'-1900','DD-MM-YYYY') <
    11                    to_date(to_char(c_start_date,'DD-MM')||'-1900','DD-MM-YYYY') then
    12                    12+(to_char(c_end_date,'MM')-to_char(c_start_date,'MM'))
    13         else (to_char(c_end_date,'MM')-to_char(c_start_date,'MM'))
    14         end -
    15        (case when to_date(to_char(c_end_date,'DD')||'-01-1900','DD-MM-YYYY') <
    16                   to_date(to_char(c_start_date,'DD')||'-01-1900','DD-MM-YYYY') then 1 else 0 end)
    17         as months_between
    18        ,case when to_date(to_char(c_end_date,'DD')||'-01-1900','DD-MM-YYYY') >
    19                   to_date(to_char(c_start_date,'DD')||'-01-1900','DD-MM-YYYY') then
    20              (to_char(c_end_date,'DD')-to_char(c_start_date,'DD'))
    21         else 31-(to_char(c_start_date,'DD')-to_char(c_end_date,'DD'))
    22         end as days_between_approx
    23        ,(c_end_date-c_start_date) year(4) to month as interval_yyyy_mm
    24* from t
    SQL> /
    C_START_D C_END_DAT YEARS_BETWEEN MONTHS_BETWEEN DAYS_BETWEEN_APPROX INTERVAL_YYYY_MM
    17-NOV-06 21-JAN-08             1              2                   4 +0001-02
    21-NOV-06 17-FEB-08             1              2                  27 +0001-03
    21-JUN-06 17-JUL-08             2              0                  27 +0002-01
    SQL>This example shows that a manual calculation can determine the number of years and months ok, but the days have to be approximated; and the interval answer isn't giving the same result for the months as the manual calculation because it can't take account of the days at the same time.

  • Macro Logic - Historical Inventory Calculation weekly - monthly

    Hi All,
    I am trying to design a macro that allows us to view only the last weeks inventory value from a weekly data view in a monthly data view. I have tried a number of different settings such as Calculation Types and different Time Based Diaggregation settings in the planing area but without success.
    It would look something like this:
    W1...W2....W3....W4 - (these weeks are all in M1)
    10....20......32......43
    M1 - the last week (W4) is the only one we want to see in M1
    43
    Any suggestions would be appreaciated.
    Paul

    Hi Paul,
    Have you considerde using Time based Disaggregation type "L"
    L- Read: Value from last period; Write: No allocation
    When you aggregate from shorter time buckets to larger, for instance weeks to months, the system take the value from the last period and copies it to the larger time bucket. In the reverse case, the value is written to all the smaller time buckets.
    You can see the same at:
    http://help.sap.com/saphelp_scm41/helpdata/en/8f/9d6937089c2556e10000009b38f889/frameset.htm
    Hope this helps.
    Cheers!
    Abhi

Maybe you are looking for

  • Conncting my PB 12' to a TV

    I am trying to connect my pb to my tv through the mini-dvi to Video Adapter, but the display preferences don't give NTSC/PAL Display (like they should) but rather, VGA Display. What's wrong? I'd appreciate if someone help me Thanx

  • 6-month old 30G iPod clicks, but does not play, not recognized by iTunes

    help!!!

  • CCM 2.0

    Hi, We are using SRM 5.0 SP 7, CCM 2.0 SP 7 and SAP_ABA 7.0 SP10 We are trying to transfer product master data from SRM to CCM. The data is getting successfully transferred from SRM to XI and SMXB_MONI in XI server shows successfully message but we a

  • Disk upgrade to Apple TV, Any News

    Well, my Apple TV is full and no I do not want to selectively choose which music, photo's or movies that I do not have access to. So how is Apple going to satisfy the customers whom have jumped in feet first to the Apple TV promise with either a box

  • How to get music from someone else's itunes library onto your

    How to get music from someone else's itunes library onto your