94400d50d4
作为子目录纳入系统,与核心测试管道协同 Co-Authored-By: Claude <noreply@anthropic.com>
2.2 KiB
2.2 KiB
17-matching-2stage-N-1: Two-Stage N:1 Matching
电信业务场景
线路→请求书二级汇集。两段式N:1汇集。第一段:多条线路CDR→中间汇总;第二段:中间汇总→请求书。
Description
Two-stage N:1 matching process. Stage 1 performs N:1 matching from multiple master records through detail records to an intermediate file. Stage 2 performs another N:1 match from the intermediate file to a final reference file.
This tests the ability to chain N:1 matching operations across two stages, where the intermediate result of one N:1 match feeds into a second N:1 match. The final output contains only records that successfully matched in both stages.
Record Layout
Standard record (45 bytes, copybook STD-REC.cpy):
| Field | Type | Length | Description |
|---|---|---|---|
| STD-KEY | PIC X | 10 | Record key |
| STD-DATA-1 | PIC X | 20 | Text data |
| STD-DATA-2 | PIC 9 | 10 | Numeric data |
| STD-DATA-3 | PIC S9(7)V99 COMP-3 | 5 | Packed decimal |
Files
| File | Purpose |
|---|---|
| main-17-matching-2stage-N-1.cbl | Main COBOL program (fixed format) |
| data-gen.sh | Generate test data for all files |
| run.sh | Compile, run, verify |
| README.md | This file |
Data Design
- master.dat: 5 records -- 3 with KEY00001, 2 with KEY00002
- detail.dat: 2 records -- KEY00001, KEY00002 (one per master group)
- final-ref.dat: 1 record -- KEY00001 only
Stage 1: 5 masters -> 2 intermediate records (N:1, one per matching group) Stage 2: 2 intermediate -> 1 final output (only KEY00001 matches final-ref)
Expected Behavior
- Stage 1 matches each master group to one detail record (N:1), writing one temp record per group that has a matching detail.
- Stage 2 matches each temp record against the final reference, writing one output per matching temp group.
- Final output: 1 record (only KEY00001 group matches final-ref).