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
Similar Messages
-
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 LagrifHi ,
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 -
To get the Number of workign days in a period
Hi All.....I have a requirements where in I need to get the number of working days in a period and also the dates with it. Say there are 28 days in a period ...then the working days would be 20 say...I need to get all the working dates......I know there is a FM "RKE_FACTORY_SELECT_DAYS" which does not exist in my systm.....So whats the other alternative for this......Please reply soon....
Thank you.
Madhukar.Have the code that is inside the FM.
DATA: L_V_AKTDAT LIKE SCAL-DATE.
DATA: L_V_INDICATOR LIKE SCAL-INDICATOR.
CLEAR : ETH_DATS.
REFRESH: ETH_DATS.
L_V_AKTDAT = I_DATAB.
* do it for all days in space of time
WHILE L_V_AKTDAT <= I_DATBI.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
DATE = L_V_AKTDAT
FACTORY_CALENDAR_ID = I_FACTID
IMPORTING
WORKINGDAY_INDICATOR = L_V_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 NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RAISING DATE_CONVERSION_ERROR.
ENDIF.
* indicator is space if actual day is a working day
* if indicator is not space the actual day isn't a working day
IF L_V_INDICATOR EQ SPACE.
CLEAR ETH_DATS.
ETH_DATS-PERIODAT = L_V_AKTDAT.
APPEND ETH_DATS.
ENDIF.
L_V_AKTDAT = L_V_AKTDAT + 1.
ENDWHILE. -
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.. -
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
SurupaHi,
call transaction PT64.
Best Regards
Bernd -
To get the list of working days-3 to working days+10 of every month
Hi,
I am looking for a query,which will give me the list of working days in a column (except Saturday and Sunday)ranging from
[Working day- 3] to [Working day +10]of each month from (April 2014 ) till 2016 December.Could you please help me in achiving it.
Note :Working day -3 means ,When the first working day of a month is [ 1st April ,Monday].
So it has to result as March 27,28 and 29 as my last working days.
Same logic applies for Working day +10(it needs to give total 10 dates,which excludes Saturday and Sunday)
Regards,
RameshDECLARE @monthDate datetime
SET @MonthDate = '20140401'
SELECT [Date]
FROM
SELECT [Date],ROW_NUMBER() OVER (PARTITION BY DATEDIFF(mm,0,[Date]) ORDER BY [Date]) AS Seq,
ROW_NUMBER() OVER (PARTITION BY DATEDIFF(mm,0,[Date]) ORDER BY [Date] DESC) AS BSeq
FROM dbo.CalendarTable(DATEADD(dd,- 10,@MonthDate),DATEADD(yy,2,@MonthDate),1,0)
)t
WHERE (Seq BETWEEN 2 AND 11 AND [DATE] > @MonthDate)
OR BSeq BETWEEN 1 AND 3
ORDER BY [Date]
CalendarTable can be found here
http://visakhm.blogspot.in/2010/02/generating-calendar-table.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to query the number of working days between two dates
I'm looking for a solution to calculate the number of <i>working</i> days between two dates that I can use in a formated search.
Calculating the total number of days is pretty straight forward but does anyone know how to take into account the settings in the HLD1 (Holiday Dates) table?Hi Eric,
If you are purely looking to exclude holidays defined in the HLD1 table, then you should be able to do it with the following query
NOTE: The following query is an example using OINV table and the fields DOCDATE and DOCDUEDATE for a Particular DOCNUM 'xxx'
If you planning to use within the SAP module then replace DOCDATE and DOCDUEDATE with dynamic field references $[$x.x.x]
SELECT DATEDIFF(DAY,T0.DOCDATE,T0.DOCDUEDATE)-
(SELECT COUNT(STRDATE) FROM HLD1 WHERE STRDATE >= T0.DOCDATE AND STRDATE <= T0.DOCDUEDATE)
FROM OINV T0
WHERE T0.DOCNUM = xxx
Best Wishes
Suda -
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
FrankFrank,
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. -
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
RamyaHi,
search for virtual key figures.
Rgds.
Juergen
P.S. Thanks for assigning points
Message was edited by:
Jürgen Hemelt -
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 -
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.
ThanksHi,
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 -
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.
RegardsHello 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 -
I cant get the number pad on the right side of my wired keyboard to work
i cant get the number pad on the right side of my wired keyboard to work. when i puch a key, my computer will either freeze or it will do nothing. Plz help me. My mac is an Intel-based mac, Running off of Mac OS X 10.4.10, not the one made out of aluminum. what should i do?
Hi, it's the old favorites - Repair Permissions, Run OnyX Maintenance App. Reboot, reset Keyboard/ Mouse settings, run Tech Tool. Try another usb keyboard on the mac or try your k/b on another computer (laptop or desk) - If have AppleCare - Call Apple. You can get a new KensingtonMac USB K/B for around $30.00 online..L
-
How to get the number of days in a month?
hi all
is there any way to get the number of days in a given month with a given year? for instance, if year is 2004 and the month is July or February, how can i get the number of days? thanks.Gee, I don't know ... Maybe this:
Calendar cal = Calendar.newInstance();
cal.set(Calendar.YEAR, 2004);
cal.set(Calendar.MONTH, Calendar.FEBUARY);
System.out.println("max days in month: " + cal.getActualMaximum(Calendar.DAY_OF_MONTH));
Do you not bother reading what people have already posted? Read the API docs on the Calendar class. -
How to get the number of days of February.....
Hi ,
how can I get the number of days (28 or 29) of February of the current year or the next...????
Or is there any other way to find that a year is a leap or not (i mean the year has 365 or 366 days).??
Thanks
Simonselect add_months(to_date('&v_year', 'YYYY'), 12) -
to_date('&v_year', 'YYYY') from dual;Jens, it seems we have made the same mistake, trunc usage seems mandatory :
SQL> ed
Wrote file afiedt.buf
1* select add_months(to_date('2007', 'YYYY'), 12) - to_date('2007', 'YYYY') from dual
SQL> /
ADD_MONTHS(TO_DATE('2007','YYYY'),12)-TO_DATE('2007','YYYY')
366
SQL> ed
Wrote file afiedt.buf
1* select add_months(trunc(to_date('2007', 'YYYY'), 'YYYY'), 12) - trunc(to_date('2007', 'YYYY'), 'YYYY') from dual
SQL> /
ADD_MONTHS(TRUNC(TO_DATE('2007','YYYY'),'YYYY'),12)-TRUNC(TO_DATE('2007','YYYY')
365
SQL> Just to clarify my past doubt.
Nicolas.
Maybe you are looking for
-
Hello all, i am referring following link to create connector for connection between mysql and sqldeveloper, while installing jar file for mysql J conncetor its telling unable to launch jar file. This is the latest OS and they have java preferences fr
-
My iPhone 5 won't update/install apps !! Any idea why ?
I own an iPhone 5, an iPhone 4s and an iPad 2. They are all not jailbroken and are all running on ios 6.0.1 While my iPhone 4s and iPad 2 have no problem updating existing apps or installing new apps, my iPhone 5 won't update/install apps all !! To b
-
Can anyone tell me how to get my desk top IMac to return to my home page after leaving the internet? Now it returns to the last page viewed, I hate that!
-
Executing Pro*C/C++ generate code in Oracle 10g Express
Hi, I had developed my application using Pro*C/C++ in Oracle 10g Enterprise Edition Release 2 to generate the code to execute my SQL statements from the application program. Problem 1: Now, as I am trying to migrate my database to the Oracle 10g Expr
-
Mapping Dimension with a composite primary key in AWM
Hi, I have a dimension with 3 levels in a snowflake scheme. The Primary key (PK) of one of them is a composite pk. Let's say: table1 (code_t1 (pk), desc_t1), table2 (code_t2 (pk), code_t1 (pk+fk), desc_t2)) and table3 (code_t3 (pk), code_t2 (fk), cod