# 1. Goal A warehouse system needs the quantity for a replenishment order of a storage bin. The calling program calls the function module {{P}}REPL_CALC. The calculation logic must be in the class {{P}}CL_REPL, because other programs also use this logic. # 2. Open questions None. # 3. Context - Function group {{P}}FG_REPL exists in package $TMP. - Function module {{P}}REPL_SAMPLE exists in this function group. It shows bin information. Do not change it. - The class {{P}}CL_REPL does not exist. Create it first. # 4. Contract ## 4.1 Class {{P}}CL_REPL - Package: $TMP. - The class is instantiable without parameters. - Public instance method calculate: - importing iv_stock, type decfloat34 - importing iv_reorder_point, type decfloat34 - importing iv_target_stock, type decfloat34 - importing iv_pack_size, type decfloat34 - importing iv_min_qty, type decfloat34 - returning rv_qty, type decfloat34 - The method has no exception. Call it only with a positive pack size. ## 4.2 Function module {{P}}REPL_CALC - Function group: {{P}}FG_REPL. - Importing parameters: - iv_stock, type decfloat34 - iv_reorder_point, type decfloat34 - iv_target_stock, type decfloat34 - iv_pack_size, type decfloat34 - iv_min_qty, type decfloat34 - Exporting parameters: - ev_qty, type decfloat34 - Exceptions: invalid_pack_size. - The function module {{P}}REPL_CALC must call the method calculate of the class {{P}}CL_REPL. Create and activate the class before you activate the function module. # 5. Business rules 1. If the pack size is not positive, the function module raises the exception INVALID_PACK_SIZE. The class method is not called in this case. 2. If the stock is greater than or equal to the reorder point, the replenishment quantity is 0. 3. Otherwise, the requirement is the target stock minus the stock. 4. If the requirement is less than the minimum quantity, the requirement is the minimum quantity. A minimum quantity below 0 counts as 0. 5. If the requirement is not positive, the replenishment quantity is 0. 6. Otherwise, round the requirement up to the next full multiple of the pack size. The replenishment quantity is this multiple multiplied by the pack size. # 6. Constraints - Release target: 7.58. - Use Clean ABAP. Keep each method below 40 statements. - Out of scope: do not change {{P}}REPL_SAMPLE. Do not create database tables. # 7. Acceptance - The function module and the class are active and have no syntax error. - The hidden tests pass. - Write ABAP Unit tests for the function module in a global test class.