Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
3.3 KiB
1. Goal
A recruitment agency scores job applicants. A recruitment program calls one function module for each applicant. The function module returns a score and a recommendation.
The score calculation is pure logic. Put this logic in a new global class. The function module calls this class. Do not put the calculation in the function module.
2. Open questions
None.
3. Context
- Function group {{P}}FG_HR exists in package $TMP.
- Function module {{P}}APPL_SAMPLE exists in this group. It shows the parameter style of the group.
- Create all new objects in package $TMP.
4. Contract
4.1 Function module {{P}}APPL_SCORE
Create the function module {{P}}APPL_SCORE in function group {{P}}FG_HR. Use this interface:
FUNCTION {{p}}appl_score
IMPORTING
iv_years TYPE i
iv_degree TYPE string
iv_match TYPE i
EXPORTING
ev_score TYPE i
ev_rating TYPE string
EXCEPTIONS
invalid_years
invalid_match
invalid_degree.
4.2 Class {{P}}APP_SCORER
Create the class {{P}}APP_SCORER. The class is public and final. The class has a public constructor without parameters.
Public type TY_RESULT has these components:
| Component | Type | Meaning |
|---|---|---|
| STATUS | TY_STATUS | Result of the input check |
| SCORE | i | Score from 0 to 100 |
| RATING | string | Recommendation |
TY_STATUS is a character type of length 4. The values of STATUS are 'OK', 'YEAR', 'MATC' and 'DEGR'.
Public method EVALUATE:
METHODS evaluate
IMPORTING
iv_years TYPE i
iv_degree TYPE string
iv_match TYPE i
RETURNING
VALUE(rs_result) TYPE ty_result.
The method does not raise an exception.
5. Business rules
- Input check. Use this order:
- If IV_YEARS is less than 0, STATUS is 'YEAR'.
- Else if IV_MATCH is less than 0 or greater than 100, STATUS is 'MATC'.
- Else if IV_DEGREE is not 'PHD', 'MAS', 'BAC' or 'VOC', STATUS is 'DEGR'.
- Else STATUS is 'OK'.
- If STATUS is not 'OK', SCORE is 0 and RATING is empty.
- Experience points: 8 points for each full year of experience. The maximum is 40 points.
- Education points: 'PHD' gives 30 points, 'MAS' 25 points, 'BAC' 20 points and 'VOC' 10 points.
- Skill points: IV_MATCH percent of 30 points. Round the result half up to a whole number.
- SCORE is the sum of the experience points, the education points and the skill points.
- RATING depends on SCORE:
- SCORE 75 or more: 'INVITE'
- SCORE 50 to 74: 'REVIEW'
- SCORE less than 50: 'REJECT'
- The function module raises the exception that belongs to STATUS:
- 'YEAR' raises INVALID_YEARS
- 'MATC' raises INVALID_MATCH
- 'DEGR' raises INVALID_DEGREE For STATUS 'OK' the function module raises no exception. It exports SCORE and RATING.
6. Constraints
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
- Coding standard: Clean ABAP. Each method has less than 40 statements.
- No ATC finding of priority 1 or 2.
- Out of scope: do not change {{P}}APPL_SAMPLE.
7. Acceptance
- {{P}}APPL_SCORE and {{P}}APP_SCORER are active and have no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests for the class in local test classes of the class.
- Write ABAP Unit tests for the function module in a global test class.