2.2 KiB
2.2 KiB
1. Goal
The recycling yard pays its customers for scrap metal deliveries. The report {{P}}SCRAP_PAY shows the payout of each metal type for one delivery day in an ALV list. The yard uses the list to check the daily payouts.
The report is a legacy program. It works, but its code is hard to read and hard to maintain. Refactor the report. The behavior stays the same.
2. Open questions
None.
3. Context
- Table {{P}}SCRAP exists in package $TMP and contains data. Fields: DELIV_ID (INT4, key), METAL (CHAR 4), DELIV_DATE (DATS), WEIGHT_KG (DEC 13,3), PRICE_KG (DEC 13,2).
- The executable program {{P}}SCRAP_PAY exists in package $TMP and is active. It has a selection screen and shows an ALV list.
- The program {{P}}SCRAP_PAY contains the business rules of the payout list. Read the code of the program before you change it.
4. Contract
- Refactor the executable program {{P}}SCRAP_PAY in package $TMP. The name stays the same.
- The selection screen stays the same:
- Parameter P_DATE, type DATS, mandatory: the delivery day.
- Select-option S_METAL for the metal type.
- The ALV list stays the same. The output table has these columns with these
names and these value formats:
- METAL: the metal type.
- TOTAL_KG: the total weight of the metal in kg, 3 decimals.
- TOTAL_PAY: the total payout for the metal, 2 decimals.
- DELIV_CNT: the number of deliveries of the metal.
5. Business rules
- The behavior of the program stays the same. The code of the legacy program {{P}}SCRAP_PAY defines every rule: which deliveries are included, how the totals are calculated, and in which order the lines are shown.
- The rules of the legacy program are correct. Do not correct, add or remove a rule.
6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Coding standards: Clean ABAP. Small methods, clear names, no unused code, no FORM routine. Read the data of the list with one database access. No ATC priority 1 or 2 finding.
- Out of scope: do not change the table {{P}}SCRAP. Do not change the selection screen, the ALV column names or the values of the ALV list.
7. Acceptance
- The program {{P}}SCRAP_PAY is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests as local test classes in the program.