59 lines
2.6 KiB
Markdown
59 lines
2.6 KiB
Markdown
# 1. Goal
|
|
A stock issue program must stop with a clear reason when it cannot issue a
|
|
quantity of a material. The caller needs one exception class that carries the
|
|
reason and the data of the failed issue.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The interface {{P}}IF_ISSUE_ERROR_INFO exists in package $TMP. It is active.
|
|
- The interface has the type TY_CASE (CHAR 20) and the methods GET_CASE,
|
|
GET_MATERIAL, GET_QUANTITY and GET_LIMIT.
|
|
- The exception class {{P}}CX_ISSUE_ERROR is raised by the stock issue program
|
|
and caught by the caller.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}CX_ISSUE_ERROR in package $TMP.
|
|
- The class inherits from CX_STATIC_CHECK.
|
|
- The class is public, final, and has a public constructor.
|
|
- The class implements {{P}}IF_ISSUE_ERROR_INFO.
|
|
- The class has the constant structure C_CASE. Its components are
|
|
UNKNOWN_MATERIAL, ZERO_QUANTITY and OVER_LIMIT. The type of each component is
|
|
{{P}}IF_ISSUE_ERROR_INFO=>TY_CASE. The value of each component is its name.
|
|
- The constructor has these importing parameters, in this order:
|
|
IV_CASE (type {{P}}IF_ISSUE_ERROR_INFO=>TY_CASE), IV_MATERIAL (type STRING),
|
|
IV_QUANTITY (type I), IV_LIMIT (type I).
|
|
- The class redefines the inherited method GET_TEXT. GET_TEXT has no importing
|
|
parameter and returns the text as a string.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
1. The constructor stores IV_CASE, IV_MATERIAL, IV_QUANTITY and IV_LIMIT.
|
|
2. {{P}}IF_ISSUE_ERROR_INFO~GET_CASE returns the stored case, ~GET_MATERIAL the
|
|
stored material, ~GET_QUANTITY the stored quantity and ~GET_LIMIT the stored
|
|
limit.
|
|
3. GET_TEXT returns one text that depends on the stored case:
|
|
- C_CASE-UNKNOWN_MATERIAL: 'Material <material> is not known'
|
|
- C_CASE-ZERO_QUANTITY: 'Quantity must not be zero for material <material>'
|
|
- C_CASE-OVER_LIMIT: 'Quantity <quantity> exceeds limit <limit> for material
|
|
<material>'
|
|
- any other case, including an empty case: 'Stock issue failed for material
|
|
<material>'
|
|
<material>, <quantity> and <limit> are the stored values. Write the quantity
|
|
and the limit as plain digits, for example 120 and 100. The text has no
|
|
leading and no trailing blanks.
|
|
4. The class is a static check exception. A caller must handle it or declare it
|
|
in the RAISING clause.
|
|
|
|
# 6. Constraints
|
|
- Release target: 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_ISSUE_ERROR_INFO.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|