I found the common date functions provided by SAP for one afternoon and did not find the functions that suit my needs. If I did, I wrote one myself. Which of the following heroes found and told the younger brother that it would not be so troublesome to write on his own next time. The written Function Code is as follows:
Function zposo_get_work_days.
*"----------------------------------------------------------------------
* "*" Local interface:
* "Importing
* "Value (B _date) type SY-DATUM
* "Value (e_date) type SY-DATUM
* "Exporting
* "Reference (days) Type I
*"----------------------------------------------------------------------
Data: Work (1 ),
P_date like sy-datum.
Call function 'fima _ days_and_months_and_years'
Exporting
I _date_from = B _date
I _date_to = e_date
Importing
E_days = days. "Get the number of days between two dates. leave is not excluded.
P_date = B _date.
Do days times. "increment the date and convert it to the factory calendar to determine if it is a holiday
Clear work.
Call function 'rp _ calc_date_in_interval'
Exporting
Date = p_date
Days = '01'
Months = '00'
Years = '00'
Importing
Calc_date = p_date.
Call function 'date _ convert_to_factorydate'
Exporting
Date = p_date
Factory_calendar_id = 'ps'
Importing
Workingday_indicator = work.
If work ne ''.
Days = days-1.
Endif.
Enddo.
Clear work.
Call function 'date _ convert_to_factorydate' "is converted to a factory calendar to determine whether the start date is a holiday.
Exporting
Date = B _date
Factory_calendar_id = 'ps'
Importing
Workingday_indicator = work.
If work ne ''.
Days = days-1.
Endif.
If e_date ne p_date.
Clear work.
Call function 'date _ convert_to_factorydate' "to determine whether the end date is a holiday
Exporting
Date = e_date
Factory_calendar_id = 'ps'
Importing
Workingday_indicator = work.
If work ne ''.
Days = days-1.
Endif.
Endif.
Days = days + 1.
Endfunction.