Files
abap-llm/tasks_gen/train/G1940/spec.md
2026-10-05 22:08:59 +02:00

3.0 KiB

1. Goal

A mobile crane hire company checks a lift plan before it dispatches a crane. The dispatch office calls one check class for each lift plan. If the check fails, the check class raises a class-based exception. The exception carries a message from a new message class.

Create the message class, the exception class, and the check class.

2. Open questions

None.

3. Context

  • All objects are in package $TMP.
  • The dispatch office already exists. It calls the check class and shows the message text of the exception.
  • No message class for lift plans exists yet.

4. Contract

Message class {{P}}MSG_CRANE

Messages 001, 002, 003, 004 and 005 must exist. The Business rules give the number, the type and the exact text of each message.

Exception class {{P}}CX_CRANE_ERROR

  • Public and final. It inherits from CX_STATIC_CHECK.
  • Public constructor with these parameters:
    • iv_msgno, TYPE symsgno
    • iv_attr1, TYPE string, optional
    • iv_attr2, TYPE string, optional
  • Public method get_message_text, returning VALUE rv_text TYPE string. The method returns the text of the message that the constructor received, with &1 replaced by iv_attr1 and &2 replaced by iv_attr2.

Check class {{P}}LIFT_CHECK

  • Public and final.
  • Public type ty_lift_plan with these components:
    • plan_id, TYPE string
    • crane_id, TYPE string
    • load_kg, TYPE decfloat34
    • capacity_kg, TYPE decfloat34
    • wind_kmh, TYPE decfloat34
  • Public method check_lift_plan with the importing parameter iv_plan of type ty_lift_plan. The method raises {{P}}CX_CRANE_ERROR.

5. Business rules

5.1 Messages of {{P}}MSG_CRANE

Number Type Text
001 E Lift plan &1 has no crane
002 E Lift plan &1 is too heavy for crane &2
003 E Lift plan &1 is blocked because of wind
004 W Lift plan &1 is near the load limit
005 I Lift plan &1 is approved

Messages 001, 002 and 003 are errors. Message 004 is a warning. Message 005 is an information message. The dispatch list shows messages 004 and 005.

5.2 Check of a lift plan

The method check_lift_plan checks the lift plan in this order:

  1. If crane_id is initial, raise {{P}}CX_CRANE_ERROR with message 001 and attribute 1 = plan_id.
  2. Else if load_kg is greater than capacity_kg, raise {{P}}CX_CRANE_ERROR with message 002, attribute 1 = plan_id, attribute 2 = crane_id.
  3. Else if wind_kmh is greater than 60, raise {{P}}CX_CRANE_ERROR with message 003 and attribute 1 = plan_id.
  4. Else the method ends without an exception.

6. Constraints

  • Release target: ABAP Platform 2025 (SAP_BASIS 816).
  • Clean ABAP. Keep every method below 40 statements.
  • Out of scope: no database table, no CDS view, no report. Do not change other objects in package $TMP.

7. Acceptance

  • All objects are active and have no syntax error.
  • The hidden tests pass.
  • Write ABAP Unit tests: a global test class for the message class and the exception class, and local test classes for {{P}}LIFT_CHECK.