Finding number of working days during query execution

Hi ,
We have a requirement to calculate number of working days during query execution. In the cube we got "received date", this will be used as a variable in the query. Based on the received date value entered, query needs to display number of products received from past 1, 2,3,4 days (working days should include weekends or public holidays).
1day     2 days     3 days     4 days   5 days 
10         12            20            15          20
to me it appears as I need to create virtual key figures.
Regards,
Ramz

Hi ramesh,
First try to create formula variables for start data and end date to calculate the no of working days.
Create a Variable ZSTDT --of type replacement path.
Type of Variable = Formula
Variable Name = ZSTDT
Characteristic = <info object>
For Intervals Use = Select From Value
Offset Start = 0000 Offset Length = 0000
Replacement var with : key
use the same steps to create one more formula variable to get end date.
Now create a formula to get the No of days.
once after getting no of days you can create buckets as per your need.
for more info check the below links
http://www.sd-solutions.com/SAP-HCM-BW-Replacement-Path-Variables.html
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/30f15839-0cf1-2b10-c6a7-ebe68cc87cdc?quicklink=index&overridelayout=true

Similar Messages

  • Determine Partition usage during query execution

    InfoCube is partitioned using 0CALMONTH from 2003 to 2011- (34 partitions, 4 partitions/year). However during query execution variable prompts are used for Fiscal year and posting period.
    1) Is there a way to find out 0CALMONTH partition is used in this case ?
    2) Is it possible to display or capture the number of partitions used during query execution ?

    InfoCube is partitioned using 0CALMONTH from 2003 to 2011- (34 partitions, 4 partitions/year). However during query execution variable prompts are used for Fiscal year and posting period.
    1) Is there a way to find out 0CALMONTH partition is used in this case ?
    2) Is it possible to display or capture the number of partitions used during query execution ?

  • Invisible index getting accessed during query execution

    Hello Guys,
    There is a strange problem , I am encountering . I am working on tuning the performance of one of the concurrent request in our 11i ERP System having database 11.1.0.7
    I had enabled oradebug trace for the request and generated tkprof out of it. For below query which is taking time , I found that , in the trace generated , wait event is "db file sequential read" on an PO_LINES_N10 index but in the generated tkprof , for the same below query , the full table scan for PO_LINES_ALL is happening , as that table is 600 MB in size.
    Below is the query ,
    ===============
    UPDATE PO_LINES_ALL A
    SET A.VENDOR_PRODUCT_NUM = (SELECT SUPPLIER_ITEM FROM APPS.IRPO_IN_BPAUPDATE_TMP C WHERE BATCH_ID = :B1 AND PROCESSED_FLAG = 'P' AND ACTION = 'UPDATE' AND C.LINE_ID =A.PO_LINE_ID AND ROWNUM = 1 AND SUPPLIER_ITEM IS NOT NULL),
    LAST_UPDATE_DATE = SYSDATE
    ===============
    Index PO_LINES_N10 is on the column LAST_UPDATE_DATE , logically for such query , index should not have got used as that indexed column is not in select / where clause.
    Also, why there is discrepancy between tkprof and trace generated for the same query .
    So , I decided to INVISIBLE the index PO_LINES_N10 but still that index is getting accessed in the trace file .
    I have also checked the below parameter , which is false so optimizer should not make use of invisible indexes during query execution.
    SQL> show parameter invisible
    NAME TYPE VALUE
    optimizer_use_invisible_indexes boolean FALSE
    Any clue regarding this .
    Thanks and Regards,
    Prasad
    Edited by: Prasad on Jun 15, 2011 4:39 AM

    Hi Dom,
    Sorry for the late reply , but yes , an update statement is trying to update that index even if it's invisible.
    Also, it seems performance issue started appearing when this index got created , so now I have dropped that index in test environment and ran the concurrent program again with oradebug level 12 trace enabled and found bit improvement in the results .
    With index dropped -> 24 records/min got processed
    With index -> 14 records/min got processed
    so , I am looking forward without this index in the production too but before that, I have concerns regarding tkprof output. Can we further improve the performance of this query.
    Please find the below tkprof with and without index .
    ====================
    Sql statement
    ====================
    UPDATE PO_LINES_ALL A SET A.VENDOR_PRODUCT_NUM = (SELECT SUPPLIER_ITEM FROM
    APPS.IRPO_IN_BPAUPDATE_TMP C
    WHERE
    BATCH_ID = :B1 AND PROCESSED_FLAG = 'P' AND ACTION = 'UPDATE' AND C.LINE_ID =
    A.PO_LINE_ID AND ROWNUM = 1 AND SUPPLIER_ITEM IS NOT NULL),
    LAST_UPDATE_DATE = SYSDATE
    =========================
    TKPROF with Index for the above query ( processed 643 records )
    =========================
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 2499.64 2511.99 98158 645561632 13105579 1812777
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 2499.64 2511.99 98158 645561632 13105579 1812777
    =============================
    TKPROF without Index for the above query ( processed 4452 records )
    =============================
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 10746.96 10544.13 84125 3079376156 1870058 1816289
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 10746.96 10544.13 84125 3079376156 1870058 1816289
    =============================
    Explain plan which is same in both the cases
    =============================
    Rows Row Source Operation
    0 UPDATE PO_LINES_ALL (cr=3079377095 pr=84127 pw=0 time=0 us)
    1816289 TABLE ACCESS FULL PO_LINES_ALL (cr=83175 pr=83026 pw=0 time=117690 us cost=11151 size=29060624 card=1816289)
    0 COUNT STOPKEY (cr=3079292918 pr=20 pw=0 time=0 us)
    0 TABLE ACCESS BY INDEX ROWID IRPO_IN_BPAUPDATE_TMP (cr=3079292918 pr=20 pw=0 time=0 us cost=4 size=22 card=1)
    180368800 INDEX RANGE SCAN IRPO_IN_BPAUPDATE_N1 (cr=51539155 pr=3 pw=0 time=16090005 us cost=3 size=0 card=1)(object id 372721)
    There is a lot increase in the CPU ,so I would like to further tune this query. I have run SQL Tuning task but didn't get any recommendations for the same.
    Since in the trace , I have got db scattered read wait event for the table "PO_LINES_ALL" but disk reads are not much , so am not sure the performance improvement even if I pin this table (620 MB in size and is it feasible to pin , SGA is 5GB with sga_target set ) in the shared pool .
    I have already gathers stats for the concerned tables and rebuilt the indexes .
    Is there any other thing that can be performed to tune this query further and bring down CPU, time taken to execute.
    Thanks a lot for your reply.
    Thanks and Regards,
    Prasad
    Edited by: Prasad on Jun 28, 2011 3:52 AM
    Edited by: Prasad on Jun 28, 2011 3:54 AM
    Edited by: Prasad on Jun 28, 2011 3:56 AM

  • Get the number of working days based on factory calendr for a range of mont

    Dear all,
    We are using BI7.00 . In one of our reports we have the following requirement.
    The range of months will be given in the selection screen for example 01.2008 to 11.2008, when the query is executed, i want system to calculate the number of working days for each month of the year (for what values provided in the selection field ) and display the same. i.e., as mentioned below.
    Month                         days.
    01.2008                        22
    02.2008                        18
    03.2008                        25  etc., Kinldy provide steps for adopting the same. If it can be adopted only through customer exit also provide the code and parameters that has to be used.
    Regards,
    M.M

    hi,
    Try the following logic to find out the no.of working days in a month based on your calendar.
    parameters : mny(6).    " input format should be  yyyymm
    data : d1 like sy-datum,
           d2 like sy-datum,
           d3 like sy-datum,
           v_nds type i.
    concatenate  mny '01' into d1.
    CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
      EXPORTING
        DAY_IN            = d1
      IMPORTING
        LAST_DAY_OF_MONTH = d2
      EXCEPTIONS
        DAY_IN_NOT_VALID  = 1
        OTHERS            = 2.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    do 30 times.
      CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
        EXPORTING
          CORRECT_OPTION      = '+'
          DATE                = d1
          FACTORY_CALENDAR_ID = ' A'    " your factory calendar ID
        IMPORTING
          DATE                = d3.
      if d1 = d3.
        d1 = d1 + 1.
        v_nds = v_nds + 1.
      else.
        d1 = d3.
      endif.
      if d3 ge d2.
        exit.
      endif.
    enddo.
    write : 'No of working days ', v_nds.
    hope it helps...
    regards,
    raju

  • ABAP - Function module to get the number of working days between 2 days

    Hi gentlemen,
    I have been asked to produce a report that gives the number of working days between 2 days, based on a calendar.
    I didn't find anything...
    Has any of you already written a function module to get this ?
    A great thanks in advance.
    Jacques Lagrif

    Hi ,
    you can try this ,
    when you require the number of working days between D1 and D2
    Total No of Days will be
    D2 - D1
    No of holidays between D1 and D2 , use the FM HOLIDAY_GET
    Pass the From date , to date , and the factory calendar to get the of Holidays
    Total no of days - Number of Holidays will your Working days
    Regards,
    Sathya

  • How can i get a number of working days in a month PL/SQL

    How can i get a number of working days in a month(excluding Saturday and Sunday) in a query in PL/SQL ?

    Please do a search before posting
    sql>
    select count(*)
    from(
    select trunc(sysdate,'month')+rownum-1 dy
    from all_objects
    where rownum <= last_day(sysdate) - trunc(sysdate,'month')+1)
    where to_char(dy,'fmday') not in ('sunday','saturday');
    COUNT(*) 
    23
    Message was edited by:
            jeneesh
    Please try yourself to change the query to one that doesn't use a subquery..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Calculating Number of Working Days

    Hi All,
    I'm creating a crystal report where I have to calculate the Number of Working Days between a date range, this should exclude the Weekends(done) but also exclude the public holidays which have defined in Holidays Calender.
    I'm not using procedure , Operating directly with tables.
    Any help would be appreciated.
    Regards

    Hello Pari,
    Check Exclude Holidays and weekends from Last7Day function link for function to exclude weekends.
    and How to query the number of working days between two dates to get holidays defined in holiday calander.
    Thanks,
    Neetu

  • Add number of working days

    I have to subtract a number of 'working days' of a date field in my message mapping.
    I wrote a user defined function. I used cal.add(Calendar.DATE, -3); on the instance cal of the class Calendar. It subtracts 3 days, but I have to subtract 3 'working days'.
    Has anyone a suggestion how to achieve this?
    Kind regards
    Frank

    Frank,
        Since you said that there is FM available in R/3 DATE_CHECK_WORKINGDAY. I would suggest you to do RFC Lookup and get the response if it not working day, then subtract 1 from the current day, and again do lookup to check whether its working day or not. Finally if you get the response as Working day, then subtract 3 from the day(not from the current date, instead the subtracted date , in my previous step).
    But  it will not solve your issue. The above I said is an approach. Because, consider the below example.
    Current day is Saturday, you r doing RFC lookup and getting response as not-working day. Hence on subtracting 1 you will get Friday, now again you are doing RFC look up , this time you will get response as working day , immediately you will subtract 3 from friday, Finally you will get the result as tuesday!!!!
    Do you think its correct? Yah sometimes, because while subtracting 3 from friday we have to make sure that thursday & wednesday must not be holiday. I think you got my example, If I'm wrong , please reply me back.
    Hope it clears.
    The above is an approach, its not the solution. If you look its good we have to apply logic to ahieve the result.
    Best Regards,
    raj.

  • 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

  • Number of working days in customer exit?

    Hi, this is actually an extension to the following thread.
    How to calculate number of working days
    I have very similar requirement. Determine the number of working days (excluding weekends and holidays) from 2 given dates. But the <b>difference here</b> is that, one of the date in the calculation is the<b> current date.</b>
    1: Creation Date - this is present as infoobject in the ODS.
    2: Current Date - this is 'today''s date.
    And, No. of Working days(Zworkdays)  = Current Date - Creation Date.
    So, as mentioned in the thread 305257 speaks about including the logic in the update rules, I can use system variable sy-datum to get the current date in update routine. But if the load is not scheduled for every day (say,once in 2 days), then when i report this infoobject Zworkdays on Day2, then it will hold Day1 calc rite?
    PLease correct me if I am wrong.
    Could you please help me with other approachs I can follow. One I can think is Customer Exit in Bex for the same.... but I am not sure how to do the same (i am new to Bex and Customer exit). Could any one of you please guide me how to achieve the same. I Have 0CalDate in the ODS also. 
    Any other ideas/inputs is greatly appreciated.
    Thanks in advance
    Ramya

    Hi,
    search for virtual key figures.
    Rgds.
    Juergen
    P.S. Thanks for assigning points
    Message was edited by:
            Jürgen Hemelt

  • FM to calculate Number of working days adjusted for an employee -ABAP HR

    I have one requirement in which i have to Calculate "Number of working days adjusted" for an employee for a disability program.
    In this context i wanna know, if just get difference between two dates (i.e the duration for which employee was compensated ) based on Holiday calender...Will this give give me "Number of working days adjusted"  for an employee or i have to consider work schedule for an employee? If yes , Then please let me know sm FM to calculate number of working days between two dates speific to an employee.

    check
    HR_PERSONAL_WORK_SCHEDULE
    HR_GET_QUOTA_DATA

  • How to calculate number of working days

    Hi experts,
    I need to determine the number of working days from two given dates. Below is my example.
    1. Posting Date
    2. Clearing Date
    3. Processing Time in Days
    The formula is:
    Processing Time in Days = Posting Date - Clearing Date
    However, the above result should exclude non-working days such as Public Holidays, Saturdays and Sundays.
    This is to be done in my Transfer Rule.
    Can someone help me with this.
    Points will be assigned as usual.
    Thanks!

    Hi,
    With referece to  Florin Wach Reply in the following link:
    Re: FM to get number of working days in a date range for a calender
    Use the update rule(routine) for <i>Processing Time in Days</i> as below:
      DATA: date_begin         TYPE sy-datum,
             date_end           TYPE sy-datum,
             current_date       TYPE sy-datum,
             working_indicator  TYPE SCAL-INDICATOR,
             workdays           TYPE I,
             factory_calendar   TYPE SCAL-FCALID.
       date_begin       = DATA_PACKAGE-PSTNG_DATE.
       date_end         = DATA_PACKAGE-CLEAR_DATE.
       factory_calendar = '01'.
       current_date = date_begin.
       DO.
          IF current_date > date_end.
             EXIT.
          ENDIF.
         CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
              EXPORTING  DATE                 = current_date
                         FACTORY_CALENDAR_ID  = factory_calendar
              IMPORTING
                         WORKINGDAY_INDICATOR = working_indicator
              EXCEPTIONS
                   CALENDAR_BUFFER_NOT_LOADABLE = 1
                   CORRECT_OPTION_INVALID       = 2
                   DATE_AFTER_RANGE             = 3
                   DATE_BEFORE_RANGE            = 4
                   DATE_INVALID                 = 5
                   FACTORY_CALENDAR_NOT_FOUND   = 6
                   OTHERS                       = 7.
         IF SY-SUBRC <> 0.
            workdays = 0.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            EXIT.
         ENDIF.
         IF working_indicator IS INITIAL.
            ADD 1 TO workdays.
         ENDIF.
         ADD 1 TO current_date.
      ENDDO.   
    Result  = workdays.
    With rgds,
    Anil Kumar Sharma .P

  • F4 Help in Variable Screen during Query Execution

    Hi All,
    We are executing queries through WAD. The F4 help in the variable screen during query execution is taking a lot of time.
    SAP note 661251 suggests changing the F4 mode to M. We need to change the booked value parameter.
    I looked into the standard WAD web template but i'm not seeing any options/ooked value parameter.
    Please suggest where I need to go to change the parameter. Thanks.
    Regards,
    Vivek

    Not much experience in WAD but I think there should be a query in BEx Query Designer.
    There you can choose that characteristics which takes time. Select "Advanced" tab from right hand side.
    Under "Filter Value Selection During Query Execution"  you will get 4 options.
    BTW if you have a query on DSO then creating index ( secondary) on the affected characteristics would also resolve your problem
    Regards
    Anindya

  • Change of Row Property during query execution possible?

    Hello Experts,
    is it possible to change the row property during query execution?
    In the case an input ready IP query can be executed for different customers. Depending on the customer class (attribute of customer), a certain row (containing account data) should be input ready or only be shown, but not input ready.
    How can this be achieved?
    Thank you!
    Angie

    Hi Angie,
      To determine the input readiness at  Run time based on the master data value of a particular characteristic value (In your case Customer),
    you can create data slice of type exit .
    The data slice is based on an exit class. In the exit class, you can implement a customer-specific logic to protect data records.
    Please refer to http://help.sap.com/saphelp_nw2004s/helpdata/en/43/0c033316cd2bc4e10000000a114cbd/frameset.htm
    for more information.
    By using this, the required rows will be shown but not input ready ( As per your requirement)
    Hope this info helps. Or do let us know !!
    Best regards,
    Akshata

  • Calculate number of working days in a month

    Hi All,
    I am trying to build a report to calculate the performance of a sales rep for the current month. This report has to exclude the holidays (saturday, sunday and one extra day in each month) in order get the exact performance. Could anyone suggest me on how to go about writing a Case statement which would get me the number of working days in a month excluding holidays.
    Thanks

    Hi,
    There are no direct oracle function that could be used to get the desired results.
    However you could try using something like
    SELECT COUNT( *)
    FROM
    (SELECT ROWNUM RNUM
    FROM ALL_OBJECTS
    WHERE ROWNUM <= TO_DATE('&1') - TO_DATE('&2') + 1
    WHERE TO_CHAR(TO_DATE('&2') + RNUM - 1, 'DY') NOT IN('SAT', 'SUN');
    Give the two date ranges that you want to look for with the highiest one first. i.e say for example - 01-FEB-2011 to 31-DEC-2010 would give the working days in JAN. However note that you might have to check for holidays related to that country/region (which could be added as a seperate table).
    If you need to get an extra day in addition to the weekends, please give the dates accordingly
    SQL> SELECT COUNT( *)
    2 FROM
    3 (SELECT ROWNUM RNUM
    4 FROM ALL_OBJECTS
    5 WHERE ROWNUM <= TO_DATE('01-FEB-2011') - TO_DATE('01-JAN-2011') + 1
    6 )
    7 WHERE TO_CHAR(TO_DATE('01-JAN-2011') + RNUM - 1, 'DY') NOT IN('SAT', 'SUN');
    COUNT(*)
    22

Maybe you are looking for