Files
2026-10-05 22:08:59 +02:00

2.7 KiB

1. Goal

A rope access company checks a work permit before a technician starts a job on a building. The permit desk calls one check for each job. The check returns one reason code for each job.

2. Open questions

None.

3. Context

  • All objects are in package $TMP.
  • The interface {{P}}IF_ROPE_CHECK does not exist yet. You create it.
  • The interface contains the type TY_REASON (character, length 10), the type TY_TICKET (character, length 10), the constant structure C_REASON with the components OK, EMPTY, TICKET, AGE, HOURS and HEIGHT, the constant structure C_TICKET with the components LEVEL_1, LEVEL_2 and LEVEL_3, and one method: CHECK IMPORTING iv_ticket TYPE ty_ticket iv_height_m TYPE i iv_logged_hours TYPE i iv_age TYPE i RETURNING VALUE(rv_reason) TYPE ty_reason.

4. Contract

  • Create the interface {{P}}IF_ROPE_CHECK in package $TMP with the types, the constants and the method of section 3.
  • Create the class {{P}}ROPE_CHECKER in package $TMP.
  • The class is public and final. It has a public constructor without parameters.
  • The class implements {{P}}IF_ROPE_CHECK.
  • Do not add other public methods to the class.
  • The values of the constants: C_REASON-OK = 'OK'. C_REASON-EMPTY = 'EMPTY'. C_REASON-TICKET = 'TICKET'. C_REASON-AGE = 'AGE'. C_REASON-HOURS = 'HOURS'. C_REASON-HEIGHT = 'HEIGHT'. C_TICKET-LEVEL_1 = 'LEVEL_1'. C_TICKET-LEVEL_2 = 'LEVEL_2'. C_TICKET-LEVEL_3 = 'LEVEL_3'.

5. Business rules

Apply the rules in this sequence. Return the reason code of the first rule that fails.

  1. Remove all spaces from iv_ticket. Convert all letters to upper case. The result is the ticket.
  2. If the ticket is empty, return EMPTY.
  3. The ticket must be the value of one component of C_TICKET. If not, return TICKET.
  4. The tickets have these limits: LEVEL_1: minimum age 18, minimum logged hours 0, maximum height 30. LEVEL_2: minimum age 18, minimum logged hours 500, maximum height 60. LEVEL_3: minimum age 21, minimum logged hours 1000, maximum height 120. If iv_age is less than the minimum age of the ticket, return AGE.
  5. If iv_logged_hours is less than the minimum logged hours of the ticket, return HOURS.
  6. If iv_height_m is greater than the maximum height of the ticket, return HEIGHT.
  7. Else return OK.

6. Constraints

  • Release target: SAP_BASIS 816 (ABAP Platform 2025).
  • Coding standards: Clean ABAP. A method has less than 40 statements. No global variables. No comment that restates the code. Pass large parameters by reference.
  • Out of scope: do not change objects that are not in the contract.

7. Acceptance

  • The interface and the class are active and have no syntax error.
  • The hidden tests pass.
  • Write your own ABAP Unit tests for the class.