Files
Kral 5de5e2851c Generator: pilot analysis and fixes; G0002-G0021 tasks; handover notes merged
- Static bundle checks (name length, seed type, reserved words, contract test classes,
  testclasses_file), local abaplint parser check before SAP, max_tokens, robust JSON parse
- Runner: G2 for CDS views with parameters, contract_check detail in report
- G0020 and G0013 fixed by review and revalidated (oracle 100, null 0)
- Pilot results in docs/faz1-tasarim.md 11e; handover notes merged into CLAUDE.md and docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 05:04:23 +02:00

3.1 KiB

1. Goal

A warehouse planner checks if the free stock covers the requirements of a production run. The planner sends a list of stock items and a list of requirements to a class. The class returns one result row for each requirement.

2. Open questions

None.

3. Context

  • The interface {{P}}IF_STOCK_COVER exists in package $TMP. It is active.
  • The interface contains the types TY_MATERIAL (CHAR 18), TY_PLANT (CHAR 4), TY_QUANTITY (PACKED 13, 3) and TY_STATUS (CHAR 10).
  • The interface contains the structures TY_STOCK_ITEM, TY_REQUIREMENT and TY_RESULT and the table types TT_STOCK_ITEM, TT_REQUIREMENT and TT_RESULT.
  • The interface contains the constant structure C_STATUS with the values OK, SHORT and INVALID.
  • The interface has the method CHECK. It imports a stock table and a requirement table and returns a result table.
  • The interface has the method SHORTAGES. It imports a result table and returns a result table.

4. Contract

  • Create the class {{P}}STOCK_COVER_CHECKER in package $TMP.
  • The class is public and final.
  • The class implements {{P}}IF_STOCK_COVER.
  • Do not add other public methods.
  • The hidden tests create the class with NEW {{P}}STOCK_COVER_CHECKER( ).

5. Business rules

Stock

  1. Each stock item has a material, a plant and a quantity. Ignore every stock item whose quantity is less than zero.
  2. Sum the quantities of the remaining stock items for each combination of material and plant. This sum is the free stock of the material and plant.
  3. Compare material and plant without regard to case. Remove all blanks before you compare them.

Requirements

  1. Process the requirements in the given sequence. The result contains one row for each requirement in the same sequence.
  2. The available quantity of a requirement is the free stock of its material and plant at the time of the requirement. If no stock exists for the material and plant, the available quantity is 0.
  3. If the required quantity is less than or equal to 0, the status is INVALID. The requirement does not use free stock. The shortage is 0.
  4. Else if the available quantity is greater than or equal to the required quantity, the status is OK. The shortage is 0. The requirement uses the required quantity of the free stock.
  5. Else the status is SHORT. The requirement uses all free stock. The shortage is the required quantity minus the available quantity.

Result

  1. A result row contains the material and the plant of the requirement without a change, the required quantity, the available quantity, the shortage and the status.
  2. The method SHORTAGES returns all rows of the result table whose status is SHORT. Sort these rows by material in ascending order and then by plant in ascending order. The result can be empty.

6. Constraints

  • Release target: 8.16 (SAP_BASIS 816).
  • Coding standards: Clean ABAP. Method length below 40 statements. No global variables. No comment that restates the code.
  • Out of scope: do not change {{P}}IF_STOCK_COVER.

7. Acceptance

  • The class is active and has no syntax error.
  • The hidden tests pass.
  • Write your own ABAP Unit tests for the class.