85 lines
3.4 KiB
Markdown
85 lines
3.4 KiB
Markdown
# 1. Goal
|
|
Calculate delivery dates for sales orders. A delivery date must be a working day.
|
|
Weekends and plant holidays are not working days. A planner uses the class before
|
|
the system confirms a delivery date.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The class {{P}}DELIVERY_SCHEDULE does not exist. Create it in package $TMP.
|
|
- The caller gives the plant holidays as a table of dates. The class does not read
|
|
a factory calendar. The class does not read the system date.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}DELIVERY_SCHEDULE in package $TMP.
|
|
- The class is public, final, and has a public constructor without parameters.
|
|
- The class has the public type TY_HOLIDAYS. TY_HOLIDAYS is a standard table of
|
|
dates (TYPE d) with an empty key.
|
|
- The class has the public methods below. Do not add other public methods.
|
|
|
|
```abap
|
|
METHODS is_working_day
|
|
IMPORTING iv_date TYPE d
|
|
it_holidays TYPE ty_holidays
|
|
RETURNING VALUE(rv_working) TYPE abap_bool.
|
|
|
|
METHODS next_working_day
|
|
IMPORTING iv_date TYPE d
|
|
it_holidays TYPE ty_holidays
|
|
RETURNING VALUE(rv_date) TYPE d.
|
|
|
|
METHODS add_working_days
|
|
IMPORTING iv_start TYPE d
|
|
iv_days TYPE i
|
|
it_holidays TYPE ty_holidays
|
|
RETURNING VALUE(rv_date) TYPE d.
|
|
|
|
METHODS count_working_days
|
|
IMPORTING iv_from TYPE d
|
|
iv_to TYPE d
|
|
it_holidays TYPE ty_holidays
|
|
RETURNING VALUE(rv_count) TYPE i.
|
|
```
|
|
|
|
# 5. Business rules
|
|
1. The days of the week are Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
|
|
Sunday.
|
|
2. A date is a working day when these two conditions are true:
|
|
- The date is not a Saturday and not a Sunday.
|
|
- The date is not in it_holidays.
|
|
3. IS_WORKING_DAY returns abap_true for a working day. It returns abap_false for
|
|
all other days.
|
|
4. NEXT_WORKING_DAY returns the first working day that is on iv_date or after
|
|
iv_date.
|
|
5. ADD_WORKING_DAYS counts working days.
|
|
- If iv_days is 0, the result is iv_start.
|
|
- If iv_days is greater than 0, the result is the date that is iv_days working
|
|
days after iv_start. Count only working days. Ignore all other days.
|
|
- If iv_days is less than 0, the result is the date that is the absolute value
|
|
of iv_days working days before iv_start. Count only working days. Ignore all
|
|
other days.
|
|
- Example: iv_start is a Friday and iv_days is 1. The result is the next Monday.
|
|
- Example: iv_start is a Monday and iv_days is -1. The result is the Friday
|
|
before.
|
|
6. COUNT_WORKING_DAYS counts the working days in the interval from iv_from to
|
|
iv_to. The interval contains iv_from and iv_to.
|
|
- If iv_from is after iv_to, the result is 0.
|
|
- If iv_from is equal to iv_to, the result is 1 for a working day and 0 for all
|
|
other days.
|
|
7. it_holidays can be empty. it_holidays can contain dates that are outside the
|
|
interval. it_holidays can contain the same date more than one time. A date that
|
|
occurs more than one time in it_holidays is a holiday.
|
|
|
|
# 6. Constraints
|
|
- Release target: 8.16.
|
|
- Coding standards: Clean ABAP. A method has less than 40 statements. No global
|
|
variables. No comment that restates the code.
|
|
- Out of scope: do not read a factory calendar. Do not read the system date. Do
|
|
not create other objects.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|