Files
cobol-java-v3/benchmark-programs/03-matching-N-1/README.md
T
NB-076 94400d50d4 feat: add benchmark-programs — 58 telecom COBOL test programs
作为子目录纳入系统,与核心测试管道协同

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 09:53:21 +08:00

2.2 KiB

03-matching-N-1: N:1 Matching (N master records match one detail record)

电信业务场景

多线路→请求书汇集。读取多条电话线路记录(LINE)和请求地址文件(BILL-ADDR),按地址进行N:1汇集。同一个地址的多条线路汇总到一张请求书。

Description

Tests N:1 matching where multiple master records sharing the same key match a single detail record. The program groups masters by key, finds the corresponding detail, and writes one output record per master that has a match.

Record Layout

Field Type Length Description
STD-KEY PIC X 10 Record key
STD-DATA-1 PIC X 20 Description text
STD-DATA-2 PIC 9 10 Numeric data (display)
STD-DATA-3 PIC S9(7)V99 05 Numeric data (COMP-3)

Total record length: 45 bytes.

Files

File Purpose
main-03-matching-N-1.cbl Main COBOL program (fixed format)
data-gen.sh Generate test data files
run.sh Compile, run, verify
README.md This file

Data

  • master.dat: 3 records, all with key KEY00001 (N=3 masters)
  • detail.dat: 2 records — KEY00001 (matches the 3 masters), KEY00002 (unmatched, not referenced)

Matching Logic

  1. Read masters by group (all records sharing the same key).
  2. Advance the detail pointer to find a key matching the group.
  3. If a match is found, write one output record per master in the group.
  4. If no match is found, skip the entire master group.
  5. Unmatched detail records are also skipped.

Test

Check Expected
Output records 3 (3 masters x 1 match)
Output file size 135 bytes (3 x 45)
Unmatched master groups 0 (all 3 have a match)

Usage

cd 03-matching-N-1
bash run.sh