Files
2026-10-05 18:02:52 +02:00

1.9 KiB

1. Goal

Show each hotel stay together with the data of its hotel. A report and an OData service read the stays. The stay view exposes the association _HOTEL, so that the consumers can read the hotel data of a stay through the association.

2. Open questions

None.

3. Context

  • Table {{P}}HOTEL (hotel), package $TMP. Key: HOTEL_ID (CHAR 10). Fields: CITY_NAME (CHAR 20), STAR_RATING (INT1).
  • Table {{P}}STAY (hotel stay), package $TMP. Key: STAY_ID (CHAR 10). Fields: HOTEL_ID (CHAR 10), GUEST (CHAR 20), NIGHTS (INT4), PRICE_PER_NIGHT (DEC 15,2, price for one night).

4. Contract

  • Create the CDS view entity {{P}}I_HOTEL in package $TMP. Elements, with these names: HOTEL_ID (key), CITY_NAME, STAR_RATING.
  • Create the CDS view entity {{P}}I_STAY in package $TMP. Elements, with these names: STAY_ID (key), HOTEL_ID, GUEST, NIGHTS, TOTAL_PRICE, CITY_NAME, STAR_RATING.
  • {{P}}I_STAY has the association _HOTEL. _HOTEL leads to {{P}}I_HOTEL and is part of the interface of {{P}}I_STAY.
  • No authorization check (#NOT_REQUIRED).

5. Business rules

  1. {{P}}I_HOTEL shows one row for each row of {{P}}HOTEL.
  2. {{P}}I_STAY shows one row for each row of {{P}}STAY.
  3. CITY_NAME and STAR_RATING of a stay are the CITY_NAME and the STAR_RATING of the hotel of the stay.
  4. TOTAL_PRICE is NIGHTS multiplied by PRICE_PER_NIGHT. TOTAL_PRICE has 2 decimals.
  5. A stay belongs to zero or one hotel. A stay can point to a hotel that is not in {{P}}HOTEL. In this case {{P}}I_STAY still shows the stay, and CITY_NAME and STAR_RATING are empty.

6. Constraints

  • Release target: 7.58.
  • Coding standards: Clean ABAP. Methods have fewer than 40 statements. Pass large parameters by reference.
  • Out of scope: do not change {{P}}HOTEL and {{P}}STAY.

7. Acceptance

  • The views are active and have no syntax error.
  • The hidden tests pass.
  • Write ABAP Unit tests with CL_CDS_TEST_ENVIRONMENT in a global test class.