Files
abap-llm/tasks_gen/train/G1069/spec.md
2026-10-05 18:02:52 +02:00

68 lines
3.2 KiB
Markdown

# 1. Goal
A regional football league collects the results of one season. The league office
needs the league table. The table shows one row for each team with the matches,
the points, the goals and the rank. A league program calls the evaluation once
for the whole season.
# 2. Open questions
None.
# 3. Context
- Work in package $TMP. No other object is necessary.
- The caller collects all match results of the season in one internal table.
The caller passes this table to the evaluation.
- The evaluation works only on this table. It does not read the database.
# 4. Contract
- Create the class {{P}}LEAGUE_TABLE in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class has these public types:
- TY_TEAM: type c length 10. The name of a team.
- TY_MATCH: structure with HOME_TEAM (TY_TEAM), AWAY_TEAM (TY_TEAM),
HOME_GOALS (type i), AWAY_GOALS (type i).
- TT_MATCH: standard table of TY_MATCH.
- TY_ROW: structure with RANK (type i), TEAM (TY_TEAM), PLAYED (type i),
WON (type i), DRAWN (type i), LOST (type i), GOALS_FOR (type i),
GOALS_AGAINST (type i), GOAL_DIFF (type i), POINTS (type i).
- TT_ROW: standard table of TY_ROW.
- The class has this public method:
EVALUATE
IMPORTING it_matches TYPE tt_match
RETURNING VALUE(rt_table) TYPE tt_row.
- Do not add other public methods.
# 5. Business rules
1. A match is valid when HOME_TEAM is not initial, AWAY_TEAM is not initial,
HOME_TEAM and AWAY_TEAM are different, HOME_GOALS is not negative and
AWAY_GOALS is not negative. Ignore every match that is not valid.
2. Each team that appears in at least one valid match gets exactly one row in
the result. A team that appears in several matches keeps this one row.
3. For each valid match the home team gets HOME_GOALS as goals for and
AWAY_GOALS as goals against. The away team gets AWAY_GOALS as goals for and
HOME_GOALS as goals against.
4. The team with more goals wins the match. If both teams have the same number
of goals, both teams draw the match.
5. A win gives 3 points. A draw gives 1 point. A loss gives 0 points.
6. PLAYED is the number of valid matches of the team. WON, DRAWN and LOST count
the wins, the draws and the losses. GOALS_FOR and GOALS_AGAINST are the sums
of the goals. GOAL_DIFF is GOALS_FOR minus GOALS_AGAINST. POINTS is the sum
of the points.
7. Sort the result: POINTS descending, then GOAL_DIFF descending, then
GOALS_FOR descending, then TEAM ascending.
8. RANK of a row is 1 plus the number of rows in the result that have more
POINTS, or that have the same POINTS and a higher GOAL_DIFF, or that have
the same POINTS, the same GOAL_DIFF and more GOALS_FOR. Rows with equal
POINTS, equal GOAL_DIFF and equal GOALS_FOR have the same rank.
9. If IT_MATCHES is empty or has no valid match, return an empty table.
# 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: no database access. Do not create other objects in package $TMP.
# 7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.