Oracle Dates & Working Days
Hi,
Is there an Oracle date function that ignores public bank holidays and calculates working days only?
On the Internet, there is something called 'Google'. It can be used by anyone.
I just used it for your request and got 569.000 hits.
Sybrand Bakker
Senior Oracle DBA
Similar Messages
-
Oracle date to days in a week. (plsql)
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
Report Builder 10.1.2.0.2
ORACLE Server Release 10.1.0.4.2
Oracle Procedure Builder 10.1.2.0.2
Oracle ORACLE PL/SQL V10.1.0.4.2 - Production
Oracle CORE 10.1.0.4.0 Production
Oracle Tools Integration Services 10.1.2.0.2
Oracle Tools Common Area 10.1.2.0.2
Oracle Toolkit 2 for Windows 32-bit platforms 10.1.2.0.2
Resource Object Store 10.1.2.0.2
Oracle Help 10.1.2.0.2
Oracle Sqlmgr 10.1.2.0.2
Oracle Query Builder 10.1.2.0.2 - Production
PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
Oracle ZRC 10.1.2.0.2
Oracle XML Developers Kit 10.1.0.4.2 - Production
Oracle Virtual Graphics System 10.1.2.0.2
Oracle Image 10.1.2.0.2
Oracle Multimedia Widget 10.1.2.0.2
Oracle Tools GUI Utilities 10.1.2.0.2
Select distinct ih.customer_id,patient_name,
sum(case when to_char(ih.invoice_date,'Mon')=to_char(to_date(:end_date,'DD-MON-YYYY'),'Mon') then id.order_qty else 0 end) curr_month,
from tab1 ih,
tab2 id,
tab4 ip,
tab3 vp
where id.invoice_number = ih.invoice_number
and id.item_id = vp.product_code
and id.item_id = ip.item_id
and ip.item_type in ('P')
and ih.customer_id = 'WAD-EX0128'
and ih.invoice_date between to_date('01-JAN-2015','DD-MON-YYYY') and to_date('31-MAR-2015','DD-MON-YYYY')
and vp.inv_product_type in ('RBC','LRBC','LPHER','PHER','FFP','FP24','CRYO')
group by ih.customer_id,patient_name
I need help in the case statement to distribute qty based on weeks of that month.
This query works fine. But now I need data by weeks, like
customer id patient name Week1 Week2
mon tue wed thu fri sat sun mon tue wed thu fri sat sun
We can just take sample data for 1 month as start date and 01-jan-2015 and end date as 31-jan-2015. having data for 4 weeks. Help is appreciated. I tried all the queries like
select to_char(sysdate,'IW'), to_char(sysdate,'Dy') from dual;
select to_char(sysdate,'Mon') || ' week' || to_char(sysdate,'W') from dual;
but not getting the data distributed by weeks. Please help me get data based on invoice_date by weeks and days.
Required Data per sample data ( Jan 2015) 1st week.Being 9i you might try to avoid Dynamic SQL concatenating daily counts to a single month_string (in the past Frank proposed it quite frequently), aligning the strings on weekdays (starting with sunday) and finally using substr to form columns.
select ym,customer_id,patient_name,
nullif(substr(month_string,1,instr(month_string,',') - 1),'~') sun_1,
nullif(substr(month_string,instr(month_string,',',1,1) + 1,instr(month_string,',',1,2) - instr(month_string,',',1,1) - 1),'~') mon_1,
nullif(substr(month_string,instr(month_string,',',1,2) + 1,instr(month_string,',',1,3) - instr(month_string,',',1,2) - 1),'~') tue_1,
nullif(substr(month_string,instr(month_string,',',1,3) + 1,instr(month_string,',',1,4) - instr(month_string,',',1,3) - 1),'~') wed_1,
nullif(substr(month_string,instr(month_string,',',1,4) + 1,instr(month_string,',',1,5) - instr(month_string,',',1,4) - 1),'~') thu_1,
nullif(substr(month_string,instr(month_string,',',1,5) + 1,instr(month_string,',',1,6) - instr(month_string,',',1,5) - 1),'~') fri_1,
nullif(substr(month_string,instr(month_string,',',1,6) + 1,instr(month_string,',',1,7) - instr(month_string,',',1,6) - 1),'~') sat_1,
substr(month_string,instr(month_string,',',1,7) + 1,instr(month_string,',',1,8) - instr(month_string,',',1,7) - 1) sun_2,
substr(month_string,instr(month_string,',',1,8) + 1,instr(month_string,',',1,9) - instr(month_string,',',1,8) - 1) mon_2,
substr(month_string,instr(month_string,',',1,9) + 1,instr(month_string,',',1,10) - instr(month_string,',',1,9) - 1) tue_2,
substr(month_string,instr(month_string,',',1,10) + 1,instr(month_string,',',1,11) - instr(month_string,',',1,10) - 1) wed_2,
substr(month_string,instr(month_string,',',1,11) + 1,instr(month_string,',',1,12) - instr(month_string,',',1,11) - 1) thu_2,
substr(month_string,instr(month_string,',',1,12) + 1,instr(month_string,',',1,13) - instr(month_string,',',1,12) - 1) fri_2,
substr(month_string,instr(month_string,',',1,13) + 1,instr(month_string,',',1,14) - instr(month_string,',',1,13) - 1) sat_2,
substr(month_string,instr(month_string,',',1,14) + 1,instr(month_string,',',1,15) - instr(month_string,',',1,14) - 1) sun_3,
substr(month_string,instr(month_string,',',1,15) + 1,instr(month_string,',',1,16) - instr(month_string,',',1,15) - 1) mon_3,
substr(month_string,instr(month_string,',',1,16) + 1,instr(month_string,',',1,17) - instr(month_string,',',1,16) - 1) tue_3,
substr(month_string,instr(month_string,',',1,17) + 1,instr(month_string,',',1,18) - instr(month_string,',',1,17) - 1) wed_3,
substr(month_string,instr(month_string,',',1,18) + 1,instr(month_string,',',1,19) - instr(month_string,',',1,18) - 1) thu_3,
substr(month_string,instr(month_string,',',1,19) + 1,instr(month_string,',',1,20) - instr(month_string,',',1,19) - 1) fri_3,
substr(month_string,instr(month_string,',',1,20) + 1,instr(month_string,',',1,21) - instr(month_string,',',1,20) - 1) sat_3,
substr(month_string,instr(month_string,',',1,21) + 1,instr(month_string,',',1,22) - instr(month_string,',',1,21) - 1) sun_4,
substr(month_string,instr(month_string,',',1,22) + 1,instr(month_string,',',1,23) - instr(month_string,',',1,22) - 1) mon_4,
substr(month_string,instr(month_string,',',1,23) + 1,instr(month_string,',',1,24) - instr(month_string,',',1,23) - 1) tue_4,
substr(month_string,instr(month_string,',',1,24) + 1,instr(month_string,',',1,25) - instr(month_string,',',1,24) - 1) wed_4,
substr(month_string,instr(month_string,',',1,25) + 1,instr(month_string,',',1,26) - instr(month_string,',',1,25) - 1) thu_4,
substr(month_string,instr(month_string,',',1,26) + 1,instr(month_string,',',1,27) - instr(month_string,',',1,26) - 1) fri_4,
substr(month_string,instr(month_string,',',1,27) + 1,instr(month_string,',',1,28) - instr(month_string,',',1,27) - 1) sat_4,
nullif(substr(month_string,instr(month_string,',',1,28) + 1,instr(month_string,',',1,29) - instr(month_string,',',1,28) - 1),'~') sun_5,
nullif(substr(month_string,instr(month_string,',',1,29) + 1,instr(month_string,',',1,30) - instr(month_string,',',1,29) - 1),'~') mon_5,
nullif(substr(month_string,instr(month_string,',',1,30) + 1,instr(month_string,',',1,31) - instr(month_string,',',1,30) - 1),'~') tue_5,
nullif(substr(month_string,instr(month_string,',',1,31) + 1,instr(month_string,',',1,32) - instr(month_string,',',1,31) - 1),'~') wed_5,
nullif(substr(month_string,instr(month_string,',',1,32) + 1,instr(month_string,',',1,33) - instr(month_string,',',1,32) - 1),'~') thu_5,
nullif(substr(month_string,instr(month_string,',',1,33) + 1,instr(month_string,',',1,34) - instr(month_string,',',1,33) - 1),'~') fri_5,
nullif(substr(month_string,instr(month_string,',',1,34) + 1,instr(month_string,',',1,35) - instr(month_string,',',1,34) - 1),'~') sat_5,
nullif(substr(month_string,instr(month_string,',',1,35) + 1,instr(month_string,',',1,36) - instr(month_string,',',1,35) - 1),'~') sun_6,
nullif(substr(month_string,instr(month_string,',',1,36) + 1,instr(month_string,',',1,37) - instr(month_string,',',1,36) - 1),'~') mon_6,
nullif(substr(month_string,instr(month_string,',',1,37) + 1,instr(month_string,',',1,38) - instr(month_string,',',1,37) - 1),'~') tue_6
from (select ym,customer_id,patient_name,
case when to_date(ym,'yyyymm') - trunc(to_date(ym,'yyyymm'),'iw') + 1 < 7
then rpad('~,',2 * (to_date(ym,'yyyymm') - trunc(to_date(ym,'yyyymm'),'iw') + 1),'~,')
end||
days_in_month||
rpad('~,',
2 * (length(replace(case when to_date(ym,'yyyymm') - trunc(to_date(ym,'yyyymm'),'iw') + 1 < 7
then rpad('~,',2 * (to_date(ym,'yyyymm') - trunc(to_date(ym,'yyyymm'),'iw') + 1),'~,')
end||days_in_month,
length(case when to_date(ym,'yyyymm') - trunc(to_date(ym,'yyyymm'),'iw') + 1 < 7
then rpad('~,',2 * (to_date(ym,'yyyymm') - trunc(to_date(ym,'yyyymm'),'iw') + 1),'~,')
end||days_in_month
) +
38
'~,'
) month_string
from (select to_char(trunc(ih.invoice_date,'mm'),'yyyymm') ym,
ih.customer_id,
patient_name,
to_char(count(case when to_char(ih.invoice_date,'dd') = '01' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '02' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '03' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '04' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '05' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '06' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '07' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '08' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '09' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '10' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '11' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '12' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '13' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '14' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '15' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '16' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '17' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '18' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '19' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '20' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '21' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '22' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '23' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '24' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '24' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '25' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '27' then 1 end))||','||
to_char(count(case when to_char(ih.invoice_date,'dd') = '28' then 1 end))||','||
case when to_char(last_day(trunc(ih.invoice_date,'mm')),'dd') >= '29'
then to_char(count(case when to_char(ih.invoice_date,'dd') = '29' then 1 end))
else '~'
end||','||
case when to_char(last_day(trunc(ih.invoice_date,'mm')),'dd') >= '30'
then to_char(count(case when to_char(ih.invoice_date,'dd') = '30' then 1 end))
else '~'
end||','||
case when to_char(last_day(trunc(ih.invoice_date,'mm')),'dd') >= '31'
then to_char(count(case when to_char(ih.invoice_date,'dd') = '31' then 1 end))
else '~'
end||',' days_in_month
from tab1 ih,
tab2 id,
tab4 ip,
tab3 vp
where id.invoice_number = ih.invoice_number
and id.item_id = vp.product_code
and id.item_id = ip.item_id
and ip.item_type in ('P')
and ih.customer_id = 'WAD-EX0128'
and ih.invoice_date between to_date(:date_from,'DD-MON-YYYY') and to_date(:date_to,'DD-MON-YYYY')
and vp.inv_product_type in ('RBC','LRBC','LPHER','PHER','FFP','FP24','CRYO')
group by ih.customer_id,patient_name,trunc(ih.invoice_date,'mm')
order by ym,customer_id,patient_name
YM
CUSTOMER_ID
PATIENT_NAME
SUN_1
MON_1
TUE_1
WED_1
THU_1
FRI_1
SAT_1
SUN_2
MON_2
TUE_2
WED_2
THU_2
FRI_2
SAT_2
SUN_3
MON_3
TUE_3
WED_3
THU_3
FRI_3
SAT_3
SUN_4
MON_4
TUE_4
WED_4
THU_4
FRI_4
SAT_4
SUN_5
MON_5
TUE_5
WED_5
THU_5
FRI_5
SAT_5
SUN_6
MON_6
TUE_6
WED_6
201501
WAD-EX0128
ALEXIAN BROTHERS MEDICAL CENTER
9
7
11
11
2
26
14
27
17
21
16
10
14
14
4
50
0
21
13
12
17
26
20
34
34
51
8
1
5
1
41
201502
WAD-EX0128
ALEXIAN BROTHERS MEDICAL CENTER
19
3
27
11
9
0
15
22
32
4
8
16
33
0
54
0
21
26
11
8
13
0
41
11
11
15
18
20
201503
WAD-EX0128
ALEXIAN BROTHERS MEDICAL CENTER
0
5
6
28
0
0
39
0
0 -
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 advancesmth 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? -
Oracle's 'Interval day to second' data type in Hibernate
Hi!
Has anyone implemented Hibernate access to a column in Oracle using 'Interval day to second' data type?
I've seen this link while searching Google.
http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/intervaldaytosec/intervaldaytosecond.html#how1
But I'm clueless about how to implement it using Hibernate.I guess this just worked:
<property name="sampleTime" type="oracle.sql.INTERVALDS">
<column name="acct_life_time" sql-type="interval_year_to_month" />
</property>Edit:
Uh oh. It works on an empty column. I got this error while trying to access one that's not:
INFO SerializableType:178 - could not read column value from result set: acct3_7_; could not deserialize
Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: could not deserialize; nested exception is org.hibernate.type.SerializationException: could not deserialize
Caused by: org.hibernate.type.SerializationException: could not deserialize -
Calculate the working days having the start and end dates only
Hi,
Can BIP be able to calculate the working days having the start and end dates only? It is like the NETWORKDAYS function in Excel. (i.e. excluding weekends and holidays).
Thanks.Not out of the box.
But You could extend your BIP functions
Look at here:
http://blogs.oracle.com/xmlpublisher/2009/05/bip_by_extension.html
Based on that what you need is similar to the following Java code:
http://objectlabkit.sourceforge.net/
regards
Jorge A. -
To find the no of working days b/w given date
Hi ABAP Experts,
Here i have one requirement .
table is tfacs
in this table i want to know the no of working days b/w the given date. Here i have attached my code .pls go through it and do me needful.
TABLES : tfacs,vbrk.
DATA: BEGIN OF ty_tfacs OCCURS 0,
ident TYPE tfacs-ident,
jahr TYPE tfacs-jahr,
mon01 TYPE tfacs-mon01,
mon02 TYPE tfacs-mon02,
mon03 TYPE tfacs-mon03,
mon04 TYPE tfacs-mon04,
mon05 TYPE tfacs-mon05,
mon06 TYPE tfacs-mon06,
mon07 TYPE tfacs-mon07,
mon08 TYPE tfacs-mon08,
mon09 TYPE tfacs-mon09,
mon10 TYPE tfacs-mon10,
mon11 TYPE tfacs-mon11,
mon12 TYPE tfacs-mon12,
basis TYPE tfacs-basis,
fenum TYPE tfacs-fenum,
wenum TYPE tfacs-wenum,
load TYPE tfacs-load,
string1(31) TYPE c,
string2(31) TYPE c,
string3(31) TYPE c,
string4(31) TYPE c,
string5(31) TYPE c,
string6(31) TYPE c,
string7(31) TYPE c,
string8(31) TYPE c,
string9(31) TYPE c,
string10(31) TYPE c,
string11(31) TYPE c,
string12(31) TYPE c,
uk(31) TYPE c,
total1 TYPE i,
total2 TYPE i,
total3 TYPE i,
total4 TYPE i,
total5 TYPE i,
total6 TYPE i,
total7 TYPE i,
total8 TYPE i,
total9 TYPE i,
total10 TYPE i,
total11 TYPE i,
total12 TYPE i,
END OF ty_tfacs.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_jahr FOR tfacs-jahr MODIF ID b1.
SELECT-OPTIONS : mon FOR tfacs-mon01 MODIF ID b1.
SELECT-OPTIONS : s_month FOR vbrk-erdat MODIF ID b2.
SELECTION-SCREEN : END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME.
PARAMETERS r1 RADIOBUTTON GROUP c DEFAULT 'X' USER-COMMAND flag .
PARAMETERS r2 RADIOBUTTON GROUP c .
SELECTION-SCREEN END OF BLOCK b.
INITIALIZATION
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
IF r1 NE space.
LOOP AT SCREEN.
IF screen-group1 EQ 'B2'.
screen-output = 1.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
IF screen-group1 EQ 'B1'.
screen-output = 1.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
start - of - selection
start-of-selection.
IF r1 = 'X'.
PERFORM get-data.
PERFORM display-data.
ENDIF.
& form get-data
text
--> p1 text
<-- p2 text
form get-data .
DATA : total1 TYPE i.
SELECT * FROM tfacs INTO TABLE ty_tfacs
WHERE ident EQ 'IN'
AND jahr IN s_jahr.
LOOP AT ty_tfacs WHERE ident = 'IN'.
IF sy-subrc EQ 0.
PERFORM get_string USING ty_tfacs-string1
ty_tfacs-mon01
ty_tfacs-total1.
PERFORM get_string USING ty_tfacs-string2
ty_tfacs-mon02
ty_tfacs-total2.
PERFORM get_string USING ty_tfacs-string3
ty_tfacs-mon03
ty_tfacs-total3.
PERFORM get_string USING ty_tfacs-string4
ty_tfacs-mon04
ty_tfacs-total4.
PERFORM get_string USING ty_tfacs-string5
ty_tfacs-mon05
ty_tfacs-total5.
PERFORM get_string USING ty_tfacs-string6
ty_tfacs-mon06
ty_tfacs-total6.
PERFORM get_string USING ty_tfacs-string7
ty_tfacs-mon07
ty_tfacs-total7.
PERFORM get_string USING ty_tfacs-string8
ty_tfacs-mon08
ty_tfacs-total8.
PERFORM get_string USING ty_tfacs-string9
ty_tfacs-mon09
ty_tfacs-total9.
PERFORM get_string USING ty_tfacs-string10
ty_tfacs-mon10
ty_tfacs-total10.
PERFORM get_string USING ty_tfacs-string11
ty_tfacs-mon11
ty_tfacs-total11.
PERFORM get_string USING ty_tfacs-string12
ty_tfacs-mon12
ty_tfacs-total12.
ENDIF.
ty_tfacs-uk = ty_tfacs-total1 + ty_tfacs-total2
+ ty_tfacs-total3 + ty_tfacs-total4
+ ty_tfacs-total5 + ty_tfacs-total6
+ ty_tfacs-total7 + ty_tfacs-total8
+ ty_tfacs-total9 + ty_tfacs-total10
+ ty_tfacs-total11 + ty_tfacs-total12.
MODIFY ty_tfacs TRANSPORTING total1 total2 total3
total4 total5 total6
total7 total8 total9
total10 total11 total12
uk.
ENDLOOP.
PERFORM write1-data USING 'COU' 'YEAR' 'MONTH01'
'MONTH02' 'MONTH03' 'MONTH04'
'MONTH05' 'MONTH06' 'MONTH07'
'MONTH08' 'MONTH09' 'MONTH10'
'MONTH11' 'MONTH12' 'TOTAL WDAYS' .
LOOP AT ty_tfacs.
PERFORM write1-data USING ty_tfacs-ident ty_tfacs-jahr
ty_tfacs-total1 ty_tfacs-total2
ty_tfacs-total3 ty_tfacs-total4
ty_tfacs-total5 ty_tfacs-total6
ty_tfacs-total7 ty_tfacs-total8
ty_tfacs-total9 ty_tfacs-total10
ty_tfacs-total11 ty_tfacs-total12
ty_tfacs-uk.
ENDLOOP.
ENDFORM. " get-data
TOP-OF-PAGE.
FORMAT COLOR 5 ON.
WRITE :/10 'COUNTRY',
20 'YEARS',
35 'MON01',
45 'MON02',
55 'MON03',
65 'MON04',
75 'MON05',
85 'MON06',
95 'MON07',
105 'MON08',
115 'MON09',
125 'MON10',
135 'MON11',
145 'MON12',
170 'total wdays'.
FORMAT COLOR OFF.
WRITE :/ SY-ULINE.
*& Form display-data
text
--> p1 text
<-- p2 text
FORM display-data .
LOOP AT ty_tfacs.
WRITE :/10 ty_tfacs-ident,
20 ty_tfacs-jahr,
30 ty_tfacs-total1,
40 ty_tfacs-total2,
50 ty_tfacs-total3,
60 ty_tfacs-total4,
70 ty_tfacs-total5,
80 ty_tfacs-total6,
90 ty_tfacs-total7,
100 ty_tfacs-total8,
110 ty_tfacs-total9,
120 ty_tfacs-total10,
130 ty_tfacs-total11,
140 ty_tfacs-total12,
150 ty_tfacs-uk.
ENDLOOP.
ENDFORM. " display-data
*& form get_string
text
-->p_0250 text
-->p_0251 text
-->p_0252 text
form get_string using p_0250 " month
p_0251 " string
p_0252. " total
p_0250 = p_0251. " move month to string
TRANSLATE p_0250 USING '0 ' . " translate
CONDENSE p_0250 NO-GAPS. " condense
p_0252 = STRLEN( p_0250 ). " pass length of string to total
ENDFORM. " get_string
***& Form write1-data
text
-->P_0306 text
-->P_0307 text
-->P_0308 text
-->P_0309 text
-->P_0310 text
-->P_0311 text
-->P_0312 text
-->P_0313 text
-->P_0314 text
-->P_0315 text
-->P_0316 text
-->P_0317 text
-->P_0318 text
-->P_0319 text
-->P_0320 text
*form write1-data using p_0306
p_0307
p_0308
p_0309
p_0310
p_0311
p_0312
p_0313
p_0314
p_0315
p_0316
p_0317
p_0318
p_0319
p_0320.
*WRITE :/ p_0306,
p_0307,
p_0308 left-justified,
p_0309 left-justified,
p_0310 left-justified,
p_0311 left-justified,
p_0312 left-justified,
p_0313 left-justified,
p_0314 left-justified,
p_0315 left-justified,
p_0316 left-justified,
p_0317 left-justified,
p_0318 left-justified,
p_0319 left-justified,
p_0320 left-justified.
*ENDFORM. " write1-data
from this report what i am getting is year and its 12 months but my requirement is i will give date using select options and i should get the total no of working days in b/w this date.Use the following code to find no of working days b/w given date. Use the correct factory_calendar_id in the function module. L_DAYS will display the required result:
PARAMETERS: p_date1 TYPE sydatum,
p_date2 TYPE sydatum.
DATA: date1 LIKE scal-date,
date2 LIKE scal-date,
correction LIKE scal-indicator,
calendar LIKE scal-fcalid,
factorydate1 LIKE scal-facdate,
workday1 LIKE scal-indicator,
factorydate2 LIKE scal-facdate,
workday2 LIKE scal-indicator,
l_days TYPE scal-facdate.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
date = p_date1
correct_option = '+'
factory_calendar_id = 'US'
IMPORTING
date = date1
factorydate = factorydate1
workingday_indicator = workday1
EXCEPTIONS
correct_option_invalid = 1
date_after_range = 2
date_before_range = 3
date_invalid = 4
factory_calendar_not_found = 5.
IF sy-subrc = 0.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
date = p_date2
correct_option = '+'
factory_calendar_id = 'US'
IMPORTING
date = date2
factorydate = factorydate2
workingday_indicator = workday2
EXCEPTIONS
correct_option_invalid = 1
date_after_range = 2
date_before_range = 3
date_invalid = 4
factory_calendar_not_found = 5.
IF sy-subrc = 0.
l_days = factorydate2 - factorydate1.
WRITE: / l_days.
ENDIF.
ENDIF. -
Working days between two date fields and Changing Factory Calendar
Hi,
I have to calculate working days between two date fields excluding the weekends and public holidays for Switzerland.
I have written the routine using factory calender and its working fine except for two problems now:
1. If any one of the date field is empty then teh rsult should be zero.
2. And the below code is working from 1996 but my cleints wants it to work for years before 1996 as well.
I also tried to change the Start date in SCAL for factory calendar but it says enter values between 1995 to 2020.
I am new to ABAP. Please help me how i can achieve these for below code.
DATA: IT_HOLIDAYS type TABLE OF ISCAL_DAY,
IS_HOLIDAYS TYPE ISCAL_DAY.
DATA: T_DATE TYPE SY-DATUM,
P_DATE TYPE SY-DATUM.
DATA : X_DATE(4) TYPE C.
DATA: CNT TYPE I.
REFRESH : IT_HOLIDAYS.
CLEAR : IT_HOLIDAYS.
T_DATE = SOURCE_FIELDS-/BIC/ZCCCHP812.
P_DATE = SOURCE_FIELDS-/BIC/ZCCCHP810.
CALL FUNCTION 'HOLIDAY_GET'
EXPORTING
HOLIDAY_CALENDAR = 'CH'
FACTORY_CALENDAR = 'CH'
DATE_FROM = P_DATE
DATE_TO = T_DATE
TABLES
HOLIDAYS = IT_HOLIDAYS
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 1
HOLIDAY_CALENDAR_NOT_FOUND = 2
DATE_HAS_INVALID_FORMAT = 3
DATE_INCONSISTENCY = 4
OTHERS = 5.
DESCRIBE TABLE IT_HOLIDAYS LINES CNT.
X_DATE = T_DATE - P_DATE - CNT.
RESULT = X_DATE.
Please help
Regards
Zabina
Edited by: Syed786 on Nov 2, 2011 9:15 AMHi Zabina,
Try this function module 'DURATION_DETERMINE'.
Give the factory calendar and unit as DAY
With regards,
Rajesh -
Sales order schedule date is a (working) day before Scheduled ship date
In MRP/MPS planning, the forecast consumption is occuring for all sales orders at a date (sales order schedule date) which is always a working day before the Scheduled Ship Date (SSD). What is the logic?
Time fences are not used.
E.g. Sales order is scheduled to ship (SSD) on 30th Nov, in forecast set > Forecast items > Consumptiion > Detail, the sales order schedule date is a day before SSD.Hi,
This is a complex issue; best solution is by using APO/GATP.
If not, then in ERP only, the second best is:
1) Work with assembly processing in SO, meaning that a production/planned order is automatically created in the customer order during order creation.
2) Then, after the order is created it is scheduled, and the delivery date proposal is based on that.
3) Now you can check in the order that there are no capacity overloads, and all capacity required to produce on the proposed date is available. If yes, you're done. If not, it gets a bit complex, since you actualy need to switch to capacity planning, do capacity leveling and dispatch (PP), and the you get a new feasible schedule proposal based on that.
APO/GATP could do all that automatically!
Regards,
Mario -
Working day to factory calendar date
Hello Experts,
I wish to get the factory calendar date, specific to a factory calendar, based on a working day.
Basically, if i pass say 4, then i want to get the date for the 4th working day based on a specific factory calendar.
Can someone throw some light on possible function module that i can use in BW ?
ThanksThat's what I was giving you, you give the working day and the factory calendar and you get the date, or you can use this function and you can do it the other way:
(Unless I'm completely missing your point here...)
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
CORRECT_OPTION = '+'
DATE = G_WORKAREA3-CREATEDON
FACTORY_CALENDAR_ID = L_S_PLANT-FACTCAL_ID
IMPORTING
* DATE =
FACTORYDATE = L_FCDATE
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.
ENDIF. -
Oracle Data Integrator 11.1.1.5 Work Schema - List of Privileges
Hi All,
Oracle Data Integrator 11.1.1.5.
Extracting data from Oracle DB for Oracle EBS 12.1.3.
Customer created read-only schema (XXAPPS) to extract the data from EBS.
For ODI Work schema we now created one schema 'XBOL_ODI_TEMP' on the source DB. We are now looking for appropriate privileges that needs to be granted to XXAPPS and 'XBOL_ODI_TEMP' so that we won’t face the any error messageS related to permissions when we run ODI scenario?
We are now facing the error message : ODI-1227: Task SrcSet0 (Loading) fails on the source ORACLE connection VTB_ORACLE_EBS_1213.
Caused By: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist.
Similar previliges can be granted to the work schema on target.
Venkati think it would be fine with only one schema(user) created at the source system which has got read access on the tables of the EBS DB. Now to resolve this error, assuming XXAPPS user is the one used,
in the topology --> data server(for EBS) --> physical schema the EBS schema name could be selected for Schema and XXAPPS as the work schema(for all ODI work related objects e.g. CDC)
Also, in the Data server the user XXAPPS needs to be used which has read access to EBS tables.
Now everytime ODI generates a query it will access a table lets say DUMMY as ,<EBS Schema>.DUMMY thus the reference is made.
Alternatively, you can create synonyms for EBS tables in XXAPPS schema. -
Calculation of no. of working days (per Factory Cal) between 2 date chars
This question could be considered to be in continuation of a previous post called "Working days of month with factory calendar"
I have two date Characteristics: say Date1 and Date2. I need to find the number of working days between them based on the factory calendar.
(And yes we have already defined the default factory calendar in IMG under 'General Reporting settings' ).
The previous post proposed the following:
1) Convert date1 into factorydate (standard functionmodule)
2) Convert date2 into factorydate (standard functionmodule)
Perform date1 - date2 to get number of working days.
I agree that there is a std function module to convert cal date to factory date called: 'DATE_CONVERT_TO_FACTORYDATE'
But what are the steps for calling the conversion? Should I create a new Formula variable of 'Customer Exit type' give it a name and define the Function module in CMOD? But then how do I attach the formula variable to the date characteristic. Note that my infoobjects are Chars so I cannot do date1- date2 in the query as is possible with keyfigures!
Please help! (my version is BW 3.0)
Thanks
NareshHi,
For the above scenario when you need to calculate date 1 - date 2. we can't build a new formulae or calculated KF directly because those are the chars.
So we need make chars to act as KF through Formulae with replacement path.
create a formulae variable on those 2 Date chars with Processing type as replaccement then those 2 Dates can be avilable to build a formulae as ur requirement.
Let me know if you need any more information.
Thanks,
Raju -
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
NaveenHello 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 -
How to set the payment Due date calculation as per working days.
how to make changes in the vendor Payment terms so that while calculating the Payment due date as per Payment terms, system calculates it based on Working Days & not the Calender days ?
Help is much appriciated.
Thank you,
AmitHi,
This is the standard settings by SAP, normally we couldn't change it to working day.
Good luck
Tao -
Payment terms should calculate Payment due date based on working days
Hi Experts,
As we know that standard SAP calculates Payment due date= base line date + number of days maintained in payment terms. In this payment days are considered as calendar days and not the working days.
Example: If base line date is Thursday, payment terms says 3 days then payment due date is calculated as Sunday ( which is not a working day as per the factory calendar I use). The requirement is that payment date should be calculated as following Tuesday considering Satuarday and Sunday are not working days as per the calendar.
Can you please suggest how can we achieve this?
Thanks,
RaviYou can not acheive from config pooint of view but you can use BADI and get the solution
use BAdI MRM_PAYMENT_TERMS to set terms of payment
You can use this Business Add-In to change the following fields for the
terms of payment in the invoice document header:
o ZFBDT: Base date for due date calculation
o ZBD1T: Discount days 1
o ZBD1P: Discount percentage 1
o ZBD2T: Discount days 2
o ZBD2P: Discount percentage 2
o ZBD3T: Deadline for net condition
o ZLSPR: Key for payment block -
I have a date, let's say 01.01.2007, and I want to postpone the date by 12 working days.
"working days" in my case shall mean only monday to friday, not saturday and sunday, and I do not case about public holidays.
Is there are function module or something like this to do this calculation?check this below link
Factory Calendar
u can also have a look into these links
Getting a date based on factory calendar
Function module to get the no.of working days between START and END dat
I want to find the No.of working days between the two dates
i think it is useful for u
SANTOSH..
Maybe you are looking for
-
Users gets stored in capital case
Hi, We have installed SAP Netweaver 2004s server (J2EE + ABAP) on AIX box . We have also installed the Enterprise portal. Now if i create a user say "testuser" form the Portal it gets stored as capital "TESTUSER" in the ABAP database. my question are
-
JSP precompilation through Ant on Weblogic 8.1problem
Hi, I updated the build.xml script such that it precompiles all JSPs. The environment is Ant and the server is weblogic 8.1. The Jsp classes get generated, but then all of a sudden at the end of compilation, during the resolving phase, I get the erro
-
HI folks, I created include in a program then when i want to delete the include it gives an error like this "Include cannot be deleted because references exist" waiting for ur reply, regards,
-
CCM - ability to search by Supplier Name characteristic
Have implemented CCM 2.0 with SRM 5.0 (both at the latest support pack levels) and have two issues when searching for products: 1. I have to prefix and suffix search term words with an asterisk for the search to find products I am interested in. Eg.
-
Nonlinear Curve Fit and using static data
I am trying to fit data to a 2D function using the Nonlinear Curve Fit VI in Labview 8.2.1, but I would like to also include 2 parameters that I don't want to be optimized. I cannot directly use constants since every time I run the fitting I need to