1.7 KiB
1.7 KiB
1. Goal
Show the weight check of each container at a container terminal. A report and an OData service will read the check, so the calculation must be in the database, in a CDS view.
2. Open questions
None.
3. Context
- Table {{P}}CONT (container master), package $TMP. Key: CONT_ID (CHAR 10). Fields: CUSTOMER (CHAR 10), DECL_KG (DEC 15,2, declared weight in kilograms), MAX_KG (DEC 15,2, maximum permitted weight in kilograms).
- Table {{P}}WEIGH (weighbridge record), package $TMP. Key: CONT_ID (CHAR 10). Field: MEAS_KG (DEC 15,2, measured weight in kilograms).
4. Contract
- Create the CDS view entity {{P}}I_CONT_WEIGHT in package $TMP.
- Elements, with these names: CONT_ID (key), CUSTOMER, DECL_KG, MEAS_KG, DEVIATION_KG, DEVIATION_PCT, STATUS.
- No authorization check (#NOT_REQUIRED).
5. Business rules
- Show one row for each container that has a weighbridge record. Do not show a container without a weighbridge record.
- DEVIATION_KG is the difference between MEAS_KG and DECL_KG, without a sign. It is always positive or zero and it has 2 decimals.
- DEVIATION_PCT is DEVIATION_KG as a percentage of DECL_KG. It has 2 decimals.
- STATUS is 'HOLD' if MEAS_KG is greater than MAX_KG.
- STATUS is 'WARN' if rule 4 is not true and DEVIATION_PCT is greater than 5.
- STATUS is 'LOAD' in all other cases.
- DECL_KG is always greater than zero.
6. Constraints
- Release target: 8.16.
- Use Clean ABAP. Keep every method below 40 statements.
- Out of scope: do not change {{P}}CONT and {{P}}WEIGH.
7. Acceptance
- The view is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests with CL_CDS_TEST_ENVIRONMENT in a global test class.