Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP function

Former Member
0 Likes
713

Hi experts,

Can someone guide me how to calculate business days (factory calendar days) no holidays or weekends between two dates. There is a function called 'DATE_CONVERT_TO_FACTORYDATE' but I need to calculate late shipment days between two dates (business days only) without holidays or weekends. Is there another function which can achieve this. Any help is appreciated. Thanks.

KV

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
635

Can you use the function module DURATION_DETERMINE.

Regards,

Rich Heilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
636

Can you use the function module DURATION_DETERMINE.

Regards,

Rich Heilman

Read only

0 Likes
635

Here is a sample....



data: xt001w type t001w.
data: duration type i.
data: sdate type sy-datum.
data: edate type sy-datum.

* Get the factory calendar for specific plant
select single * from t001w into xt001w
                   where werks = '0004'.   " Use your plant

* Set start/end dates
sdate = sy-datum.
edate = '20050731'.

call function 'DURATION_DETERMINE'
 exporting
   factory_calendar                 = xt001w-fabkl
 importing
   duration                         = duration     " In days
 changing
   start_date                       = sdate
   end_date                         = edate
 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.

write:/ duration.

Regards,

Rich Heilman

Read only

0 Likes
635

Mr. Helman,

Thanks so much for your help.

Regards,

KV

Read only

FredericGirod
Active Contributor
0 Likes
635

Don't understand what you don't understand.

Your function give you the number of the day for a date.

You use two times to have two number and you make diff between this two number. This diff is the diff of working day.

Is it not easy ?

Frédéric