Skip to content

Migrate CBSTM03A/CBSTM03B statement generation to Java - #187

Open
devanshi-gpta wants to merge 1 commit into
devin/1786577620-carddemo-java-foundationfrom
devin/1786577937-carddemo-statements
Open

devanshi-gpta wants to merge 1 commit into
devin/1786577620-carddemo-java-foundationfrom
devin/1786577937-carddemo-statements

Conversation

@devanshi-gpta

@devanshi-gpta devanshi-gpta commented Aug 12, 2026

Copy link
Copy Markdown

Summary

Migrates CBSTM03A (statement driver, replacing CREASTMT.JCL) and its CBSTM03B I/O subroutine into com.carddemo.batch.statement. No files outside that package (plus the README mapping table) are touched.

The whole point of this migration is byte-level fidelity of the two outputs, so the COBOL record layouts are reproduced field by field rather than re-expressed as templates:

  • StatementService.render(...) emits List<String> records padded to the DD LRECL (STMTFILE 80, HTMLFILE 100), in the exact write order of the COBOL paragraphs (5000-CREATE-STATEMENT5100/5200 HTML header → 6000-WRITE-TRANS per transaction → 4000-TRNXFILE-GET totals/footer). The HTML 88-level literals are transcribed verbatim, including their continuation lines.
  • StatementFormatter implements the COBOL data movements the layout depends on, which are the easy things to get subtly wrong:
    • PIC 9(9).99- (ST-CURR-BAL) → 1234.56 renders as "000001234.56 ", -42.07 as "000000042.07-"; integer digits beyond nine are truncated high-order, as MOVE does.
    • PIC Z(9).99- (ST-TRANAMT / ST-TOTAL-TRAMT) → 0.75 renders as " .75 ".
    • MOVE ACCT-ID PIC 9(11) TO PIC X(20)"00000000011" + 9 spaces.
    • STRING ... DELIMITED BY ' ' / ' ' (the name and address-line-3 builds, and the DELIMITED BY ' ' HTML variants) transfer only the part of the fixed-width sending field before the delimiter.
  • StatementTransactionTable replaces the WS-TRNX-TABLE two-dimensional table: TRNXFILE is read once in TRAN-CARD-NUM + TRAN-ID order (the sort CREASTMT.JCL STEP010 performs) and grouped per card, and the per-statement scan stops at the first stored card sorting after XREF-CARD-NUM, exactly like 4000-TRNXFILE-GET. The OCCURS 51 / OCCURS 10 bounds are kept as constants; records past them are dropped with a warning instead of overwriting adjacent storage the way the COBOL would.
  • StatementFileService is the CBSTM03B stand-in over the repositories (sequential XREFFILE/TRNXFILE, keyed CUSTFILE/ACCTFILE). It does not reproduce the literal CALL interface, but it keeps the status semantics: a missing keyed record raises StatementFileException("CUSTFILE", "23"), mirroring 9999-ABEND-PROGRAM.
  • StatementJobConfig wraps the service in a Spring Batch job creastmtJob writing to carddemo.statement.text-file / carddemo.statement.html-file.

No new dependencies; pom.xml unchanged.

Testing

cd java && mvn -B clean verify passes (25 tests). New: layout assertions for every header line, transaction line and the Total EXP: line; HTML order/content; the numeric-edit pictures; table grouping and OCCURS limits; and a @SpringBootTest generating statements for a seeded cardxref/custdata/acctdata account with two transactions (250.00, -100.50 → total 149.50).

Link to Devin session: https://app.devin.ai/sessions/3485785cb7574e7e8391ead52ee9ee82
Requested by: @devanshi-gpta


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Open in Devin Review (Staging)

Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant