Files

57 lines
2.5 KiB
Markdown

# 1. Goal
An IT asset manager consolidates the software licence records of two
subsidiaries. A reporting program calls one service that merges the two lists
into one list. The result has one row for each product and cost centre.
# 2. Open questions
None.
# 3. Context
- The interface {{P}}IF_LICENCE_MERGE exists in package $TMP. It is active.
- The interface has the type TY_PRODUCT (character, length 10), the type
TY_COST_CENTRE (character, length 6), and the type TY_PRICE (packed number,
length 8, 2 decimals).
- The interface has the structure type TY_LICENCE with these components:
PRODUCT (TY_PRODUCT), COST_CENTRE (TY_COST_CENTRE), SEATS (integer),
UNIT_PRICE (TY_PRICE).
- The interface has the table type TT_LICENCES. TT_LICENCES is a standard table
of TY_LICENCE.
- The interface has one method:
MERGE
IMPORTING it_primary TYPE tt_licences
it_secondary TYPE tt_licences
RETURNING VALUE(rt_merged) TYPE tt_licences.
# 4. Contract
- Create the class {{P}}LICENCE_MERGER in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class implements {{P}}IF_LICENCE_MERGE.
- Do not add other public methods.
# 5. Business rules
The method MERGE reads the two input tables IT_PRIMARY and IT_SECONDARY.
1. Normalize the product and the cost centre of each input row: remove the
leading and the trailing blanks and convert all letters to upper case.
2. Ignore an input row if the normalized product is empty, or if the normalized
cost centre is empty, or if the seats are less than 1.
3. All remaining input rows with the same product and the same cost centre
become one result row. Rows of the same input table and rows of different
input tables are combined in the same way.
4. The seats of a result row are the sum of the seats of its input rows.
5. The unit price of a result row is the highest unit price of its input rows.
6. The result has one row for each pair of product and cost centre that has at
least one remaining input row.
7. Sort the result by product in ascending order. If two rows have the same
product, sort them by cost centre in ascending order.
# 6. Constraints
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
- Coding standards: Clean ABAP. Method length below 40 statements. No global
variables. No comment that restates the code.
- Out of scope: do not change {{P}}IF_LICENCE_MERGE.
# 7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.