Files
abap-llm/tasks_gen/train/G1124/spec.md
2026-10-05 18:02:52 +02:00

77 lines
3.0 KiB
Markdown

# 1. Goal
Check a work booking of a production shift and calculate the pay of the shift. A
payroll program calls the check before it posts the pay. The program needs one
reason code for each booking that is not correct.
# 2. Open questions
None.
# 3. Context
- The class {{P}}SHIFT_BOOKER does not exist. You create it.
- The exception class {{P}}CX_SHIFT_ERROR does not exist. You create it.
- The business uses the words hours, mode, order, date, count, group and value.
These words are reserved words or SQL words. The contract below uses other
names for the same concepts.
# 4. Contract
## 4.1 Exception class {{P}}CX_SHIFT_ERROR
- The class is in package $TMP. It inherits from CX_STATIC_CHECK.
- The class has the public instance attribute MV_REASON. The type is CHAR 10.
MV_REASON holds the reason code of the error.
- Do not add other public components.
## 4.2 Class {{P}}SHIFT_BOOKER
- The class is in package $TMP. It is public, final, and has a public constructor
without parameters.
- Public types:
- TY_AMOUNT: packed number, length 9, 2 decimal places.
- TY_HOURS: packed number, length 5, 2 decimal places.
- TY_MODE: CHAR 3.
- TY_GROUP: CHAR 1.
- TY_ORDER: CHAR 10.
- TY_SHIFT: structure with these components:
- ORDER_NO: TYPE TY_ORDER
- START_DATE: TYPE d
- WORK_HOURS: TYPE TY_HOURS
- CALC_MODE: TYPE TY_MODE
- GROUP_CODE: TYPE TY_GROUP
- PIECE_COUNT: TYPE i
- Public method:
EVALUATE
IMPORTING is_shift TYPE ty_shift
RETURNING VALUE(rv_pay) TYPE ty_amount
RAISING {{P}}CX_SHIFT_ERROR
- Do not add other public methods.
# 5. Business rules
The method EVALUATE checks the booking. Apply the rules in this sequence. The
method raises {{P}}CX_SHIFT_ERROR with the reason code of the first rule that
fails.
1. If ORDER_NO is empty, the reason code is ORDER.
2. If START_DATE is initial, the reason code is DATE.
3. If WORK_HOURS is not greater than zero, the reason code is HOURS.
4. CALC_MODE must be STD, OT1 or OT2. If not, the reason code is MODE.
5. GROUP_CODE must be A, B or C. If not, the reason code is GROUP.
6. If PIECE_COUNT is less than 1, the reason code is COUNT.
If all rules pass, the method returns the value of the shift.
The value of the shift is:
WORK_HOURS x base rate x mode factor + PIECE_COUNT x 0.50
- The base rate of the group is: A = 18.00, B = 22.00, C = 26.00.
- The mode factor is: STD = 1.0, OT1 = 1.5, OT2 = 2.0.
- The value has 2 decimal places.
# 6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Coding standards: Clean ABAP. Method length below 40 statements. No global
variables. No comment that restates the code.
- Do not use the words HOURS, MODE, ORDER, DATE, COUNT, GROUP or VALUE as the name
of a field, of a component or of a parameter. The reason codes in the rules
above are values, not names.
- Out of scope: do not create other objects. Do not use transports.
# 7. Acceptance
- The two classes are active and have no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for {{P}}SHIFT_BOOKER.