Files

2.0 KiB

1. Goal

Give the total repair charge of each customer of a cobbler's workshop. A report and an OData service read the charges, so the calculation must be in the database, in a CDS view.

2. Open questions

None.

3. Context

  • Table {{P}}JOB (repair job), package $TMP. Key: JOB_ID (CHAR 10). Fields: CUSTOMER (CHAR 10), SHOE_TYPE (CHAR 4), REPAIR_TYPE (CHAR 4), PAIRS (INT4), JOB_STATE (CHAR 1).
  • Table {{P}}RATE (repair rate), package $TMP. Key: SHOE_TYPE (CHAR 4), REPAIR_TYPE (CHAR 4). Field: PRICE (DEC 15,2, price for one pair).
  • The CDS view entity {{P}}I_REPAIR_CHARGE in package $TMP already exists and has a defect.

4. Contract

  • Fix the CDS view entity {{P}}I_REPAIR_CHARGE in package $TMP.
  • Elements, with these names: CUSTOMER (key), JOB_COUNT, TOTAL_PAIRS, TOTAL_CHARGE.
  • No authorization check (#NOT_REQUIRED).

5. Business rules

  1. The view shows one row for each customer that has at least one repair job in the view.
  2. JOB_COUNT is the number of repair jobs of the customer in the view.
  3. TOTAL_PAIRS is the sum of PAIRS of these jobs.
  4. The charge of a repair job is its PAIRS multiplied by the price that the rate table holds for the shoe type and the repair type of the job. TOTAL_CHARGE is the sum of the charges of these jobs, with 2 decimals.
  5. Users report that JOB_COUNT, TOTAL_PAIRS and TOTAL_CHARGE of a customer are too high. The three values are correct when the customer has no job whose shoe type has more than one repair type in the rate table. The three values must be correct for every customer.
  6. All other behavior of the view stays the same.

6. Constraints

  • Release target: 8.16.
  • Coding standards: Clean ABAP. No ATC priority 1 or 2 findings.
  • Out of scope: do not change {{P}}JOB and {{P}}RATE. No dynpro, no SmartForms, no BAdI, no RAP behavior definition.

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.