2006 Jul 19 12:13 PM
Hi,
im looing for a FM which gives the difference in
Workingdays between date1 and date2 for a specific
Factory Calendar.
Thanks for Help
Regards, Dieter
2006 Jul 19 12:16 PM
report zrich_0002.
data: duration_in_days type i.
parameters: s_date type sy-datum,
e_date type sy-datum.
call function 'DURATION_DETERMINE'
exporting
factory_calendar = 'P6' <--your factory calendor like US etc..
importing
duration = duration_in_days
changing
start_date = s_date
end_date = e_date
exceptions
factory_calendar_not_found = 1
date_out_of_calendar_range = 2
date_not_valid = 3
unit_conversion_error = 4
si_unit_missing = 5
parameters_not_valid = 6
others = 7.
this code is copied from one of the SDN post.
didnt remember the url of that post. so i copied the code here.
Message was edited by: Srikanth Kidambi
added my comments
Message was edited by: Srikanth Kidambi
Hi,
im looing for a FM which gives the difference in
Workingdays between date1 and date2 for a specific
Factory Calendar.
Thanks for Help
Regards, Dieter
2006 Jul 19 12:16 PM
report zrich_0002.
data: duration_in_days type i.
parameters: s_date type sy-datum,
e_date type sy-datum.
call function 'DURATION_DETERMINE'
exporting
factory_calendar = 'P6' <--your factory calendor like US etc..
importing
duration = duration_in_days
changing
start_date = s_date
end_date = e_date
exceptions
factory_calendar_not_found = 1
date_out_of_calendar_range = 2
date_not_valid = 3
unit_conversion_error = 4
si_unit_missing = 5
parameters_not_valid = 6
others = 7.
this code is copied from one of the SDN post.
didnt remember the url of that post. so i copied the code here.
Message was edited by: Srikanth Kidambi
added my comments
Message was edited by: Srikanth Kidambi
2006 Jul 19 12:16 PM
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.
2006 Jul 19 12:17 PM
Hi dieter,
1. DATE_CHECK_WORKINGDAY
This is one useful FM
2. Try this code (just copy paste)
IT DOES EXACTLY WHAT U REQUIRE.
(It will list out all the working dates
between two given days)
REPORT abc.
data : num type i.
parameters : frdate type sy-datum default '20051216'.
parameters : todate type sy-datum default '20051221'.
perform getinfo using frdate todate changing num.
break-point.
&----
*& Form getinfo
&----
text
----
FORM getinfo USING fromdate todate CHANGING numofdays type i.
DATA : d TYPE sy-datum.
d = fromdate - 1.
DO.
d = d + 1.
IF d > todate.
EXIT.
endif.
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
date = d
factory_calendar_id = '01'
message_type = 'I'
EXCEPTIONS
date_after_range = 1
date_before_range = 2
date_invalid = 3
date_no_workingday = 4
factory_calendar_not_found = 5
message_type_invalid = 6
OTHERS = 7.
IF sy-subrc = 0.
numofdays = numofdays + 1.
write 😕 d.
ENDIF.
ENDDO.
ENDFORM. "getinfo
I hope it helps.
Regards,
Amit M.
2006 Jul 19 12:19 PM
hi
Check FM <b>'RKE_SELECT_FACTDAYS_FOR_PERIOD'</b>
call function 'RKE_SELECT_FACTDAYS_FOR_PERIOD'
exporting
i_datab = starting date
i_datbi = ending date
i_factid = 'US'
tables
eth_dats = it_eth_dats.else Use FM
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
date = d
factory_calendar_id = '01'
message_type = 'I'
EXCEPTIONS
date_after_range = 1
date_before_range = 2
date_invalid = 3
date_no_workingday = 4
factory_calendar_not_found = 5
message_type_invalid = 6
OTHERS = 7.
2006 Jul 19 12:19 PM
K_ABC_WORKDAYS_FOR_PERIODS_GET for a period.
RKE_SELECT_FACTDAYS_FOR_PERIOD for a a date range:
LOOP AT lt_se.
CALL FUNCTION 'RKE_SELECT_FACTDAYS_FOR_PERIOD'
EXPORTING
I_DATAB = lt_se-erdat
I_DATBI = lf_endat
I_FACTID = <FACT CAL ID>
TABLES
ETH_DATS = lt_fd
EXCEPTIONS
DATE_CONVERSION_ERROR = 1
OTHERS = 2.
Regards,
ravi
2006 Jul 19 12:19 PM
Please check whether this solves ur purpose
WEEK_GET_NR_OF_WORKDAYS
or
FIMA_DAYS_BETWEEN_TWO_DATES
regards,
Harish
2006 Jul 19 12:27 PM
2006 Jul 19 12:30 PM
Hai
Go through the following Code
PARAMETERS:
date1 LIKE sy-datum DEFAULT '20060701',
date2 LIKE sy-datum DEFAULT sy-datum.
DATA i .
DATA z TYPE p DECIMALS 0.
DATA cnt TYPE sy-dbcnt.
DATA cnt_su TYPE sy-dbcnt.
DATA cnt_sa TYPE sy-dbcnt.
data : work_days type i.
WRITE: date1, date2.
DATA: D TYPE I, M TYPE I, Y TYPE I.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM = DATE1
I_KEY_DAY_FROM =
I_DATE_TO = DATE2
I_KEY_DAY_TO =
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = D
E_MONTHS = M
E_YEARS = Y.
WHILE date1 LE date2.
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
datum = date1
IMPORTING
wotnr = z.
ADD 1 TO date1.
IF z = 6.
ADD 1 TO cnt_sa.
ELSEIF z = 7.
ADD 1 TO cnt_su.
ENDIF.
ENDWHILE.
*WRITE: / 'Sun:', cnt_su, 'Sat:', cnt_sa.
work_days = d - ( cnt_su + cnt_sa ) + 1.
skip.
write 😕 'No of Working Days :' , work_days.
Regards
Sreeni
2006 Jul 19 12:44 PM
Hi,
thanks for help.
FM 'RKE_SELECT_FACTDAYS_FOR_PERIOD' is the Solution.
LineCount of table eth_dats gives the count of Worgingdays.
Regards, Dieter