ABAP HR- calculation of workind days (excluding weekend) for an employee

Hi,
I need to get number of working days between two dates excluding weekends for an employee. Please let me know below questions in this regard:
1. I have to use Factory calender or holiday calender for this purpose?
2. Will FM RKE_SELECT_FACTDAYS_FOR_PERIOD solve this purpose ?
Regards,
Aleria

Hi Aleria,
Use the FM DAY_ATTRIBUTES_GET in this FM pass the holiday and factory calendar of the employee along with the period. In the output structure if free day is set then it is SAT/SUN and if holiday is set then it is Public holiday marked in the calendar.
Regards
Bala

Similar Messages

  • ICal custom repeat every x days EXCLUDING weekends?

    I have an event I would like to repeat every x number of days excluding weekends (so only counting M-F as "counted" days). Is there a way to do this?

    You can exclude Sat/Sun, but they will still be counted - so an occurrence on those days is dropped, and you will get fewer occurrences than you should.
    AK

  • Calculating days excluding weekends

    Msy you please show me how to calculate the number of days in between 2 dates excluding weekends.

    Hi!
    Check out these FM-s:
    K_ABC_WORKDAYS_FOR_PERIODS_GET
    WEEK_GET_NR_OF_WORKDAYS      
    WLB3_GET_NUMBER_OF_WORKDAYS  
    There are some calendar relevant FM-s also. If there's set a production calendar in your SAP, you can check it also.
    SE37 transaction, and search for CALENDAR fm.
    Regards
    Tamá

  • Fucntion to Calculate business days (exclude weekends & holidays) between two days

    Hello,
    I need to be able to calculate business days between two dates excluding weekends and holidays. I do have a date dimension and also flags which denote weekday, holiday. Would really appreciate help in building a udf for the business days calculation.
    Thanks,

    Hi, Please take a look and tweak accordingly. Best of luck.
    --Assuming data dimension table something like the following
    --tblDateDim (DT date primary key,
    flagHoliday bit,
    flagWeekday bit
    CREATE FUNCTION fnBusinessDays (
    @StartDate DATE,
    @EndDate DATE
    RETURNS INT
    AS
    BEGIN
    DECLARE @Days INT ;
    SELECT @Days = count(*)
    FROM tblDateDim --// date dimension
    WHERE
    ( DT BETWEEN @StartDate AND @EndDate) --// dt is date column in the table.
    AND --// also flags which denote weekday, holiday
    flagHoliday = 0 --// flagHoliday= 1--Holiday;= 0 --workingday/businessday
    AND
    flagWeekday = 1 --// FlagWeekday = 1--businessday ; =0 --weekend (Saturday and Sunday)
    RETURN (@Days)
    END
    GO

  • How to calculate number of days excluding weekends

    I have the following <u>key figures</u> in my InfoCube:
    Date Released to Vendors key figure - ZRELDT
    Date Awarded to a Vendor key figure - ZAWRDT
    In my BEx query, I need to calculate the difference between these two key figures but the weekends should be excluded.  For example, if the value of ZRELDT is 08/10/2007 (which is a Friday) and the value of ZAWRDT is 08/13/2007, the result should just be 1 day and not 3 days since the other days pertain to a Saturday and a Sunday.
    How do I address this in the formula when creating the Query?
    thanks.

    Hi,
    Use func module HOLIDAY_GET need to pass the Holiday Cal the company use
    and also 
    FM: DATE_CONVERT_TO_FACTORYDATE.
    One way to use this:
    Assuming:
    - You have the start & end dates in variables.
    - Keep a few counters
    Logic:
    - Pass start date to DATE_CONVERT_TO_FACTORY_DATE with the parameter +
    - If this date is not a factory date, the next date which is a factory day is returned. (I.e. passed Sunday as param, got a Monday date returned). If the day passed to the function is the same as the date returned, this is a factory day (working day)
    - If the date passed to the function is not the same as the returned day then this day was not a factory day, meaning not a work date. Add 1 to a counter
    - Pass the first day + 1 (use another counter for + N)
    - Stop loop when passed parameter is equal to stop date.
    You can replicate the factory calendar from R/3, CRM etc in your source system in RSA1 (transfer globals). In your function call, you specify which factory calendar to use
    hope this help

  • Calculating number of days without weekend and holidays

    Hallo all,
    can someone help me with a formular to calculate the number of days with Crystal Reports 2008 between two dates without weekends and holidays
    eg.
    date one = 03/24/2010
    date two = 03/29/2010
    Result should be 4 days as 03/27 and 03/28 will be a weekend.
    Plus how to exclude holidays ?
    Thank you very much
    Gerald

    As Doug mentioned, Holidays are very location specific, and are you talking about "corporate holidays" where the company is closed, or "public holidays" where banks (<g>) are closed?
    I'd suggest setting up a calendar table (if you don't have one already), one record per date.  You could make it work-days only, days-off only, or all dates with a flag to indicate if it is a work date.  You could then use that to count the number of work days.  By using a table, you wouldn't have to change any code to (a) extend your calendar to the following year, or (b) change holiday dates if the holidays change.  (I'm thinking corporate holidays, where the company might be closed Friday 12/24/10 in observation of Christmas, but would usually only close on the 25th.)
    HTH,
    Carl

  • Delivery Date should propose only working days (Excluding weekends and holidays

    Hello All
    I have one requirement here, where delivery dates should propose only working days and it should not allow to add weekends and holidays during the creation of sales order.
    I would like to know if there are any standard settings to be done in plant or shiping point?
    Kindly need all your input on this
    Thanks
    Naveen

    Hello All
    Same calendar has already been assigned in shipping point,plant and sales org and also in the calendar holidays been maintained, even though when we create a sales order it will accept weekends and holidays
    Thanks

  • Finding the number of days excluding weekends

    Dear All,
    I want to find the date difference between the working days,
    ex, take 2 dates, today - Monday 11th and Monday 18th,
    So, I want a function module which will calculate the difference between working days, means from 18th to 11th, it should calculate the difference as 5 working days.
    Please let me know the function module which will show the number of difference in working days.
    Thanks in Advance,
    Ramana

    Hi,
    Check the following code:
    REPORT ZDATEDIFF.
    DATA: EDAYS   LIKE VTBBEWE-ATAGE,
          EMONTHS LIKE VTBBEWE-ATAGE,
          EYEARS  LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
                TODATE   LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
    call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
      exporting
        i_date_from          = FROMDATE
        i_date_to            = TODATE
      I_FLG_SEPARATE       = ' '
      IMPORTING
        E_DAYS               = EDAYS
        E_MONTHS             = EMONTHS
        E_YEARS              = EYEARS.
    WRITE:/ 'Difference in Days   ', EDAYS.
    WRITE:/ 'Difference in Months ', EMONTHS.
    WRITE:/ 'Difference in Years  ', EYEARS.
    INITIALIZATION.
    FROMDATE = SY-DATUM - 60.
    Regards,
    Bhaskar

  • To see the number of working days and leave of an employee for year

    HI SAP GURUS,
    I want to see the the number of working days and leave of all employees of the organisation for a year. Please tell me is there any report or any transaction code in sap to see the working days and leave for all employees.
    Thanks & Regards
    Surupa

    Hi,
    call transaction PT64.
    Best Regards
    Bernd

  • Confused - How to Calculate Number of Days Between Dates but Exclude Weekend Dates If There Hasn't Been a Weekend Update

    Hello -
    I've been tearing my hair out over this problem i'm trying to solve, probably just been staring at it too long which is making it worse -
    I have a series of open support tickets which are supposed to be updated on a daily basis, the problem is that they aren't always being updated daily.  So, the business wants to know the number of days from when a ticket was last updated and today's
    date.  I have this basic calculation and it's working fine, however now the business wants to exclude weekends from the calculation.  The other problem is that some reps DO go in on weekends and update their tickets, so sometimes there will be updates
    made on weekend dates.
    To give an example -
    Today's date is 2014-02-10 (Monday).  A ticket was last updated last Thursday, 2014-01-30.  The difference between the two dates is 11, so it's been 11 days since the ticket was last updated.  Now, if I exclude Saturdays and Sundays, then
    it's actually been 7 days since the ticket was last updated.  I'm not sure how to do this in T-SQL.
    Now, to further complicate the problem, sometimes a ticket IS updated on a Saturday or Sunday.  So, if a ticket was updated on 2014-02-02 (Sunday), then it should be counted.  Again i'm not sure how to do this. 
    What gets me is that this is probably fairly simple and i've just been staring at it too long.  In the meantime, can someone offer some guidance?
    Thanks!!

    I've adapted this from a function on my blog. you will need to add set the YourTicketTable to where ever your tickets are stored.
    CREATE
    FUNCTION [dbo].[CalcWorkDaysBetween](@StartDate
    As DateTime,@EndDate
    AS DateTime)
    RETURNS
    INT AS
    BEGIN
    SET @EndDate
    =DATEADD(DAY,1,@EndDate)
    DECLARE @Count
    AS Int= 0
    DECLARE @Date
    As Date=@StartDate
    WHILE @Date
    < @EndDate
    BEGIN
    IF (DATEPART(WEEKDAY,@Date)IN(1,7)
    OR (SELECT
    Count(*)
    FROM YourTicketTable WHERE TicketDate=@Date)=1)
    BEGIN
    SELECT @Count = @Count
    + 1
    END
    SELECT @Date=DATEADD(Day,
    1,@Date)
    END
    RETURN
    DATEDIFF(DAY,@StartDate,@EndDate)- @Count
    END
    Regards,

  • Add working days to a date excluding weekends and holidays

    Hi there,
    I need to write a function that will take a specified date and number of days to add as input parameters, and return the working day based on the number of days to add parameter, excluding weekends and any holidays held in a holiday table.
    Here is my function so far -
    CREATE OR REPLACE FUNCTION f_add_work_days(pd_date IN DATE
    ,pn_add_days IN PLS_INTEGER) RETURN DATE IS
    pd_in_date DATE := pd_date;
    ld_next_holiday DATE;
    ln_days_left PLS_INTEGER := pn_add_days;
    CURSOR cu_holiday(pn_date IN ge740.holdte%TYPE) IS
    SELECT pck_utility.f_dtcnv(g.holdte)
    FROM ge740 g
    WHERE g.holdte >= pn_date
    AND g.maint <> 'D'
    ORDER BY g.holdte ASC;
    BEGIN
    OPEN cu_holiday(pck_utility.f_dtcnv(pd_in_date));
    FETCH cu_holiday
    INTO ld_next_holiday;
    CLOSE cu_holiday;
    LOOP
    IF ln_days_left = 0 THEN
    EXIT;
    END IF;
    pd_in_date := pd_in_date + 1;
    IF pd_in_date > ld_next_holiday THEN
    OPEN cu_holiday(pck_utility.f_dtcnv(pd_in_date));
    FETCH cu_holiday
    INTO ld_next_holiday;
    CLOSE cu_holiday;
    END IF;
    CASE
    WHEN TO_CHAR(pd_in_date
    ,'fmDAY') = 'SATURDAY' THEN
    pd_in_date := pd_in_date + 2;
    ln_days_left := ln_days_left - 1;
    WHEN TO_CHAR(pd_in_date
    ,'fmDAY') = 'SUNDAY' THEN
    pd_in_date := pd_in_date + 1;
    ln_days_left := ln_days_left - 1;
    WHEN pd_in_date = ld_next_holiday THEN
    pd_in_date := pd_in_date + 1;
    ln_days_left := ln_days_left - 1;
    ELSE
    ln_days_left := ln_days_left - 1;
    END CASE;
    END LOOP;
    RETURN(pd_in_date);
    END f_add_work_days;
    I think there is something wrong/missing in the logic as I can't get it to cater for say a double bank holiday(25/26th Dec - if the input parameters are 24/12/2007 and 2, which should return the 28th but returns the 26th!!).
    I'm relatively new to PL/SQL and Oracle, so any help, advice, ideas would be greatly appreciated!
    thanks in advance

    smth like
    SQL> with holidays as (select to_date('10.06.2007','dd.mm.yyyy') h_dt from dual),
      2       par as (select to_date('08.06.2007','dd.mm.yyyy') dt, 2 add_days from dual)
      3  --
      4  select min(dt) needed_date
      5    from (select p.*,
      6                 h.*,
      7                 mod(to_char(dt, 'j'), 7),
      8                 sum(decode(mod(to_char(dt, 'j'), 7), 5, 0, 6, 0, 1)+--get rid of sat and sun
      9                     nvl2(h_dt, -1, 0)--check if the day is holiday
    10                     ) over(order by dt) s
    11            from (select dt + level dt, add_days
    12                    from par
    13                  connect by level <= 100) p,
    14                 holidays h
    15           where h_dt(+) = dt
    16           order by 1)
    17   where add_days = s
    18  /
    NEEDED_DATE
    13.06.2007
    SQL> ?
    Message was edited by:
    Volder
    PS What Oracle version are you on?

  • Working day formula that excludes weekends and holidays in WEBI

    Hi Guys,
    Can we calculate a working day formula that excludes weekends and holidays in WEBI OR in Universe?
    The universe I am working on is using stored procedures, so there are no joins or modelling done. Although there is a workday stored proc  that I can bring in the universe.
    I am just thinking if there is no modelling or joins done in the universe how will this help me in webi?
    Your suggestions will be very helpful.
    Thanks,
    Jitan

    One more suggestion I need from you  -
    I have a Work_Calendar_VW that has the following columns -
    Calendar_Date - 5/1/2014
    Calendar_Year - 2014
    Calendar_Month - 5
    Calendar_Day - 1
    Work_Day - 1
    Day_Type - WD (Work Day)  For Weekends this will be displayed as WE
    The columns have all dates for current year in SQL Server.
    I am going to pull this into the universe and create 2 derived tables to calculate MTD Day counts.
    Derived Table 1  - Calculate Yest Work Day... this will remove all the weekends and holidays and give me the last working day. This includes couple of case statments to check each day if it's a working day or weekend.
    For Work Day the above code will be 1 and for weekend 0
    Derived Table 2  - This will give me the count of working days in current month using the above view and Derived table 1 Below is the code  -
    SELECT COUNT(*)
    FROM Work_Calendar_VW
    WHERE [Work_Day] = 1 AND
       (Calendar_Date BETWEEN CAST(CONVERT(VARCHAR(25),MONTH(LastWoringkday()),101) + '/01/'
       + CONVERT(VARCHAR(25),YEAR(LastWoringkday()),101) AS DATE)
      AND LastWoringkday()).
    I cannot do joins because this universe has been built using stored proc and would like to implement this in BO universe.
    let me know if this is the right approach.
    Thanks,
    Jitan

  • How to get difference in days between 2 dates excluding weekends

    Hi all,
    i have a requirement, to calculate the difference between 2 dates, in days.
    eg: 01/08/2007 and 05/08/2007.
         Difference = 4 days.
    But here my actual requirement is i have to calculate this difference excluding weekends (saturday n sundays).
    eg: 01/08/2007 -
    Thursday
         05/08/2007 -
    Monday
    so now Difference = 2 days.
    Please help me regarding this.
    Points will be rewarded for helpfull answers.
    Thanks in Advance.
    Regards,
    Vineel

    see these codes of rich
    report zrich_0003.
    data: begin of itab occurs 0,
          datum type sy-datum,
          end of itab.
    data: weekday like dtresr-weekday.
    data: number_lines type i.
    parameters: p_sdatum type sy-datum,
                p_edatum type sy-datum.
    itab-datum = p_sdatum.
    append itab.
    do.
      if itab-datum = p_edatum.
        exit.
      endif.
      itab-datum = itab-datum + 1.
      call function 'DATE_TO_DAY'
           exporting
                date    = itab-datum
           importing
                weekday = weekday.
      if weekday = 'Sat.'
        or weekday = 'Sunday'.
        continue.
      endif.
      append itab.
    enddo.
    describe table itab lines number_lines.
    write:/ 'Number of days between dates is', number_lines.
    and
    report zrich_0001.
    parameters: p_start type sy-datum,
                p_end   type sy-datum.
    data: idays type table of   rke_dat with header line.
    data: workingdays type i.
    call function 'RKE_SELECT_FACTDAYS_FOR_PERIOD'
         exporting
              i_datab               = p_start
              i_datbi               = p_end
              i_factid              = 'P8'  " Fact Calender ID
         tables
              eth_dats              = idays
         exceptions
              date_conversion_error = 1
              others                = 2.
    describe table idays lines workingdays.
    write:/ workingdays.
    I want to find the No.of working days between the two dates
    regards,
    srinivas

  • Time between dates excluding Weekends and Holidays

    I am fairly new to Power Pivot and I am having trouble with this formula.  I need my Cycle Time Days column to capture the days between CreatedDataTime and ClosedDateTime excluding Weekends and Holidays.  I have a tab that has the holidays but
    I can't get the formula correctly?   Jill
    CreatdDateTime        ClosedDateTime     Cycle Time Days
    12/1/2014                    12/10/2014

    first of all you need a separate time table which holds all possible dates for your model
    there should be no gaps, it should contain full years and a column of datatype DateTime as unique key
    once you have this in place add a calculated column to this table as 
    =IF(INT(FORMAT([Date], "w")) >= 6, "Weekend", "Workday")
    then go back to your original table and add the following calculation for your [Cycle Time Days]-column:
    =COUNTROWS(
    FILTER(
        'Dates',
        Dates[Date] >= DateRanges[DateFrom]
        && Dates[Date] <= DateRanges[DateTo]
        && 'Dates'[IsWeekend] = "Workday"
    Holidays are a bit more tricky but you can follow the same pattern but you need to get the holidays from somewhere
    hth,
    -gerhard
    Gerhard Brueckl
    blogging @ http://blog.gbrueckl.at
    working @ http://www.pmOne.com

  • Calculate the Difference Between two dates excluding weekends and Holidays

    Hi,
    We need to calculate the difference between the two dates by excluding the Local public holidays (It is global and varies across countries) and weekends should not be included in calculation for a business day in OBIEE.
    We have two dates: Open date and close date when ever close date is null we are calculating age based on taking the current timestamp and need to exclude the weekends and Holidays when ever the close date is null.
    Ex:
    Col1 col2 Total
    11/9/2010 2:46:38 PM Null 13
    11/2/2010 8:06:26 PM 11/3/2010 5:37:03 PM 1
    (In the Total we shouldn't include the weekends,holidays)
    Please let me know how to calculate the difference between two dates by excluding the weekends and holidays.
    Thanks
    Edited by: user10441472 on Nov 22, 2010 3:14 PM

    You already asked this question and I answered it...
    Re: calculation of Business day in OBIEE

Maybe you are looking for

  • Best way to restore game app data to iPad after rebuild

    I rebuilt my UMBP over the weekend. Before doing so I took a copy of my documents, movies etc, and the entire iTunes library folder and placed it onto an external HDD. This was not a Time Machine backup, but a straight copy. After rebuilding, reinsta

  • Is my hl-dt-st bddvdrw gbc-h20l capable of burning Blu Ray discs (BD-R)?

    Hello. I have a HP Pavilion Elite m9470 Desktop PC with an  hl-dt-st bddvdrw gbc-h20l drive running Windows 7 Ultimate (the pc came originally with Vista). For the first time I tried to burn a Blu Ray disc BD-R in fact. When I loaded the disc into tr

  • Can't view PDFs created in Captivate 8

    Hi, We use PDFs for SME review. However, when trying to open the PDFs  via Adobe Reader X1 (11.0.10) , get the message "To view the Flash technology content in this PDF file, plese install the requied version of Flash Player'.  Any ideas? Many thanks

  • C++ coding (void) how to use it in Xcode .

    hi . im not a developer. i just a student. im trying to compile my coding in c++ via Xcode in my #MAC . but my coding got stucked . this :: >>      void setData(int value); BubbleSort (dataType[], int listSize) the error appear [Expected '.' after to

  • How can i split my catalog into two

    I am using PSE 11 would like to take 31,000 files from the main catalog and put them in a separate catalog.  The files are all in a directory tree called Digital Scrapbooking which has 1,728 folders and 31,000 files. Is there a simple way of doing th