Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
2.0 KiB
Create the class {{P}}STOCK_COVER_CHECKER in package $TMP. The class is public and final. It implements the interface {{P}}IF_STOCK_COVER. Do not add other public methods. The class must be creatable with NEW {{P}}STOCK_COVER_CHECKER( ).
A stock item has a material, a plant, and a quantity. Ignore every stock item whose quantity is less than zero. Sum the quantities of the remaining stock items for each material and plant. This sum is the free stock. Compare material and plant without regard to case. Remove all blanks before you compare them.
Process the requirements in the given sequence. The result contains one row for each requirement in the same sequence. 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.
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. 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. Else the status is SHORT. The requirement uses all free stock. The shortage is the required quantity minus the available quantity.
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.
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.
Release target: 8.16 (SAP_BASIS 816). Use Clean ABAP. Keep method length below 40 statements. Do not use global variables. Do not write comments that restate the code. Do not change {{P}}IF_STOCK_COVER.
The class must be active and have no syntax error. The hidden tests must pass. Write your own ABAP Unit tests for the class.