- 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>
81 lines
3.2 KiB
Markdown
81 lines
3.2 KiB
Markdown
# 1. Goal
|
|
Analyse the age of stock batches. A warehouse report calls the analysis before it
|
|
prints the stock aging report. The report needs the grouped quantity and the number
|
|
of batches for each material and age bucket.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The interface {{P}}IF_STOCK_AGE exists in package $TMP. It is active.
|
|
- The interface defines these types:
|
|
- ty_material: character, length 10.
|
|
- ty_batch_id: character, length 10.
|
|
- ty_bucket: character, length 2.
|
|
- ty_quantity: packed number, length 13, 3 decimals.
|
|
- ty_batch: structure with the components material, batch, quantity, gr_date.
|
|
- tt_batch: table of ty_batch.
|
|
- ty_age_row: structure with the components material, bucket, quantity, batch_count.
|
|
- tt_age_row: table of ty_age_row.
|
|
- ty_total: structure with the components material, quantity, batch_count.
|
|
- tt_total: table of ty_total.
|
|
- The interface defines the constant structure C_BUCKET with the components
|
|
D0_30 = '01', D31_60 = '02', D61_90 = '03', D91_PLUS = '04'.
|
|
- The interface defines two methods:
|
|
- analyze: importing it_batch type tt_batch and iv_key_date type dats,
|
|
returning rt_age type tt_age_row.
|
|
- total_by_material: importing it_batch type tt_batch and iv_key_date type dats,
|
|
returning rt_total type tt_total.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}STOCK_AGE in package $TMP.
|
|
- The class is public, final, and has a public constructor without parameters.
|
|
- The class implements {{P}}IF_STOCK_AGE.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
Both methods use the same validity rules and the same age buckets.
|
|
|
|
Validity
|
|
1. A row of IT_BATCH is valid when its goods receipt date is not initial and is not
|
|
after IV_KEY_DATE.
|
|
2. A row that is not valid is ignored. It must not change any result.
|
|
|
|
Age and bucket
|
|
3. The age of a batch is the number of days between its goods receipt date and
|
|
IV_KEY_DATE.
|
|
4. The bucket of a batch is:
|
|
- age 0 to 30 days: bucket 01 (C_BUCKET-D0_30)
|
|
- age 31 to 60 days: bucket 02 (C_BUCKET-D31_60)
|
|
- age 61 to 90 days: bucket 03 (C_BUCKET-D61_90)
|
|
- age more than 90 days: bucket 04 (C_BUCKET-D91_PLUS)
|
|
|
|
Method ANALYZE
|
|
5. Group the valid rows by material and bucket.
|
|
6. For each group, sum the quantity and count the valid rows.
|
|
7. Return one row per group. Sort the result by material ascending and then by
|
|
bucket ascending.
|
|
8. A group is in the result as soon as one valid row belongs to it, also when the
|
|
summed quantity is zero.
|
|
9. If no valid row exists, return an empty table.
|
|
|
|
Method TOTAL_BY_MATERIAL
|
|
10. Group the valid rows by material only.
|
|
11. For each group, sum the quantity and count the valid rows.
|
|
12. Return one row per material. Sort the result by material ascending.
|
|
13. If no valid row exists, return an empty table.
|
|
|
|
Quantity
|
|
14. The quantity of a batch can be negative. Add the quantities as they are.
|
|
|
|
# 6. Constraints
|
|
- Release target: SAP_BASIS 8.16 (ABAP Platform 2025).
|
|
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
|
variables. No comment that restates the code. Pass large parameters by reference.
|
|
- Out of scope: do not change {{P}}IF_STOCK_AGE.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|