Skip to content

PF8: Production data, Db2, COBOL interoperability - #1

Merged
mms-it-ch merged 6 commits into
mainfrom
claude/produktion-1-4
Oct 7, 2026
Merged

mms-it-ch merged 6 commits into
mainfrom
claude/produktion-1-4

Conversation

@mms-it-ch

Copy link
Copy Markdown
Owner

Summary

This PR adds PF8 (Production – Business Data, Db2, COBOL Interop), the final phase of the z/OS Pascal port. It provides comprehensive support for COBOL copybook integration, packed/zoned decimal arithmetic, EBCDIC code page handling, Db2 ODBC/CLI access, and AMODE-31 program interoperability.

Key Changes

COBOL Copybook Support

  • scripts/copybook2pas.py: New tool that converts COBOL copybooks to Pascal units with exact field offsets matching COBOL programs. Supports:
    • Levels 01-49, 66, 77, 88 with PIC clauses (X/A/N/9/S9/V/P)
    • USAGE variants (DISPLAY, COMP/COMP-4/BINARY, COMP-3/PACKED-DECIMAL, COMP-5, COMP-1/2, INDEX, POINTER, NATIONAL)
    • SIGN LEADING/TRAILING with SEPARATE option
    • SYNC/SYNCHRONIZED alignment relative to record start
    • OCCURS with DEPENDING ON (ODO) support
    • REDEFINES for variant records
    • Level 88 conditions with VALUE, THRU, and figurative constants
    • Generates packed records with byte fields, offset/length constants, Get_/Set_ accessors, and layout validation

Decimal Arithmetic (rtl/zosdecimal.pp, rtl/zosdecimalbcd.pp)

  • TDecimal: Fixed-point decimal type supporting up to 63 digits with independent scale
  • Packed (COMP-3) and zoned (DISPLAY/EBCDIC) field I/O with validation (S0C7 equivalent)
  • Arithmetic without floating-point, comparison, rescaling with truncation or rounding
  • Conversion to/from Int64, Currency, and strings
  • TBCD (fmtbcd) bridge for database integration
  • Byte-wise implementation: platform-independent, same behavior on x86_64 and z/OS

EBCDIC Code Page Support

  • rtl/zosccsid.pp: ISO-8859-1 ↔ EBCDIC conversion for CECP code pages (1047, 37, 273, 277, 278, 280, 284, 285, 297, 500, 871, 1140-1149)
  • scripts/gen-ccsid.py: Generates conversion tables from ICU data
  • runtime/zosccsid.h and rtl/zosccsid.inc: Pre-computed tables for C and Pascal
  • Selectable per-file via ZOS_CCSID environment variable or ,ccsid=NNN in dataset names
  • Pure Pascal, runs on any platform for EBCDIC data preparation

COBOL Field Access (rtl/zoscobol.pp)

  • Unified interface for reading/writing copybook record fields:
    • Text (PIC X/A): EBCDIC per CCSID
    • PIC N (NATIONAL): UTF-16 Big-Endian
    • Zoned/packed (DISPLAY, COMP-3): via TDecimal
    • Binary (COMP/COMP-4/BINARY/COMP-5): Big-Endian with PIC validation
    • COMP-1/COMP-2: HFP ↔ IEEE-754 conversion (z/OS typically uses hexadecimal floating-point)
  • Byte-wise, platform-independent implementation

Db2 ODBC/CLI Support (rtl/zosdb2cli.pp)

  • Complete ODBC 3 CLI bindings for Db2 for z/OS (64-bit, ASCII mode)
  • Type definitions and constants for SQL functions (SQLAllocHandle, SQLConnect, SQLExecDirect, SQLPrepare, SQLExecute, SQLBindParameter, SQLBindCol, SQLFetch, SQLGetData, SQLGetDiagRec, SQLEndTran, SQLF

https://claude.ai/code/session_01EPRbtCyWfDPbr8mS8FXmY8

marcels68 and others added 6 commits October 4, 2026 19:42
- Version 0.9.0: VERSION, zfpc --version, ppcs390x -iZ und Logo, ZosPortVersion
  und Eyecatcher FPC_ZOS_VERSION (ASCII/EBCDIC) in jedem Programm (FPC-Patch
  0043), Kopfzeile im Start-Skript von zos-ld; CHANGELOG.md
- FPC-Patch 0042: cwstring ließ sich mit dem Start-Compiler FPC 3.2.2 nicht
  übersetzen ({$elseif} nach {$ifdef}); Basis-Commit in fpc/BASE
- CI (.github/workflows/ci.yml, scripts/ci-build.sh): FPC klonen, Patchserie
  anwenden, nativer FPC main + ppcs390x, RTL und 337 Package-Units bis zum
  Objekt (Distributions-llc, ZFPC_CI=1), Soll-Liste ci/package-failures.txt,
  pf-Programme mit -Cn, Python-Skripte; im Container vollständig durchgelaufen
  (~8 min). Job "zos" für einen Self-Hosted-Runner (Variable ZOS_RUNNER,
  Zugangsdaten nur aus Secrets, scripts/ci-zos.sh + ci/zos-tests.txt); auf
  z/OS noch nicht getestet
- z/OS-Skripte auch unter Linux ohne WSL (scripts/zos-hostenv.sh: ssh/sftp,
  /tmp); zos-ld im Linux-Modus mit ssh-Attrappe geprüft
- PRODUKTION.md: freigegebene Compilerschalter (-O2 Standard, -O4 nicht
  freigegeben wegen tw41865g/h, -Cr/-Co/-gl empfohlen, -Ct bei Rekursion,
  -gc -gh nur Fehlersuche), Versionen, Release-Ablauf, CI-Einrichtung
- Skripte ausführbar (Dateimodus)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EPRbtCyWfDPbr8mS8FXmY8
…pybook -> Pascal

- EBCDIC-Codepages: Datasets und zosebcdic nicht mehr fest IBM-1047. Global über
  ZOS_CCSID oder SetDefaultCcsid, je Datei über ",ccsid=NNN" im Namen oder
  SetTextCcsid (FPC-Patch 0044, runtime/zosdsn.c). 21 CECP-Codepages: 1047, 37,
  273, 277, 278, 280, 284, 285, 297, 500, 871, 1140-1149 (Euro auf X'A4' der
  ISO-8859-1-Seite). Tabellen erzeugt aus den IBM-Zuordnungen der ICU
  (scripts/gen-ccsid.py, Prüfsummen); 1047 ist gleich der früher auf z/OS mit
  iconv gemessenen Tabelle. Portable Unit zosccsid (Pascal-Tabellen).
- Unit zosdecimal: TDecimal (63 Stellen, eigener Scale, + - * / Rest, Rundung
  abschneiden/kaufmännisch/Banker, ohne Gleitkomma), gepackt und gezont (alle
  SIGN-Varianten) lesen/schreiben mit Prüfung wie S0C7, Int64/Currency/String;
  zosdecimalbcd für TBCD.
- scripts/copybook2pas.py: Copybook -> Pascal-Unit (packed records aus
  Byte-Feldern mit den COBOL-Offsets, Get_/Set_ je Feld, Stufe 88 als
  Konstanten + Is_/Set_, OCCURS/ODO, REDEFINES als varianter Record, SYNC mit
  Füllbytes, FILLER, PIC N, HFP/IEEE für COMP-1/2, Initialize_, LayoutOk);
  Laufzeit-Unit zoscobol.
- Tests auf x86_64: dectest 110/110, ccsidtest 17/17, cobtest 60/60,
  C-Prüfstand für zosdsn.c 131/131 (tests/c, Attrappen der z/OS-Header),
  tests/test_ccsid.py, tests/test_copybook2pas.py; CI-Schritt x86
  (tests/run-x86.sh). Für z/OS übersetzt, dort noch nicht ausgeführt
  (pf8/README.md: Aufruf und Erwartung).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EPRbtCyWfDPbr8mS8FXmY8
- Unit zosdb2cli: CLI-Funktionen (SQLAllocHandle ... SQLGetDiagRec, SQLEndTran,
  SQLFreeHandle, SQLTables/SQLColumns), Konstanten nach ODBC 3 + Db2, Klassen
  TDb2Connection/TDb2Statement mit Parametern (Text, BIGINT, DOUBLE, DECIMAL als
  Text <-> TDecimal, NULL), SQLGetData-Spaltenwerten und EDb2Error (SQLSTATE,
  SQLCODE, alle Diagnosesätze). Auf z/OS gegen DSNAO64C, sonst unixODBC.
- z/OS-Typgrößen in rtl/zosdb2cli_zos.inc: NICHT gemessen (Annahme LP64,
  4-Byte-Handles); pf8/db2probe_c.c misst sie und gibt die Datei neu aus,
  prüft die Prototypen per _Generic und die Konstanten (gegen die
  unixODBC-Header geprüft: alles OK).
- zfpc --db2 / ZOS_DB2=1: zos-ld bindet ZOS_DB2HLQ.SDSNMACS(DSNAO64C) mit, das
  Start-Skript setzt STEPLIB und DSNAOINI (ZOS_DB2_STEPLIB, ZOS_DB2_INI);
  zos-batch.sh: ZOS_BATCH_STEPLIB; gen-zosmap.py: Db2-Header (ZOS_DB2_INCLUDE)
  für mögliche #pragma map der CLI-Namen.
- pf8/db2test.pas (13 Prüfungen: DDL, Parameter, NULL, DECIMAL, Commit/Rollback,
  SQLSTATE): lokal gegen SQLite über unixODBC 13/13 (CI-Schritt x86);
  dsnaoini.txt, db2test.jcl, dsnacli-bind.jcl; Anleitung pf8/README.md.
  Auf z/OS noch nicht getestet. SQLDB-Connector nicht umgesetzt (Weg beschrieben).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EPRbtCyWfDPbr8mS8FXmY8
… Pascal (CEL4RO64)

- Recherche: LE bietet ab z/OS 3.1 (bzw. per APAR) CEL4RO31/CEL4RO64 (zweite
  LE-Umgebung der anderen AMODE in derselben Task). Layout von CEL4RO64 aus
  Eclipse OpenJ9 (j9cel4ro64.h); für CEL4RO31 kein frei zugängliches Layout
  -> nicht umgesetzt, Weg in pf8/README.md.
- Pascal -> AMODE 31: Unit zoscall31 (TCall31Session.Call(name, Bereiche)),
  runtime/zosc31.c (Prozess + Pipes, Protokoll), Brücke pf8/zpcall31.s (HLASM,
  AMODE 31, ohne LE: GETMAIN LOC=31, LOAD, OS-Parameterliste mit Hochbit,
  BASSM, BPX1RED/BPX1WRT). Daten über die Copybook-Records aus copybook2pas.
- AMODE 31 -> Pascal: LE-konformer HLASM-Stub pf8/zp64call.s (CEEENTRY,
  RO64-Kontrollblock, CAA+1024 -> +8), COBOL-Hauptprogramm zpcob2.cbl,
  Pascal-DLL call64lib.pas, Batch-JCL call64.jcl.
- Testprogramme ZPASM1 (HLASM), ZPCOB1 (COBOL, COPY KUNDE), call31test.pas;
  Bau auf z/OS mit pf8/build31.sh (as, ld, cob2). Start-Skript: ZOS_RUN_ENV.
- Lokal getestet: call31test 11/11 gegen die Brücken-Attrappe
  tests/c/fake_zpcall31.c (CI-Schritt x86), call64lib über einen Lade-Treiber.
  HLASM, COBOL und CEL4RO64 auf z/OS noch nicht getestet; Grenzen (Kopien,
  Enclave je Aufruf, kein AMODE 24, keine Zeiger in Bereichen) dokumentiert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EPRbtCyWfDPbr8mS8FXmY8
- README.md: Meilenstein PF8, neue Werkzeuge, Verweise auf PRODUKTION.md und
  CHANGELOG.md, zfpc --version/--db2
- CLAUDE.md (Stand): PF8 knapp, was lokal getestet ist und dass auf z/OS noch
  nichts davon gelaufen ist
- pf8/README.md: Prüfliste für die ersten Läufe auf z/OS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EPRbtCyWfDPbr8mS8FXmY8
…SQLINTEGER

- FPC-Patch 0045: odbcsql bindet auf z/OS statisch gegen DSNAO64C (external
  'dsnao64c') und nimmt die CLI-Typen aus rtl/zosdb2cli_zos.inc (dieselben wie
  zosdb2cli); odbcconn benutzt dort odbcsql statt des dynamischen Laders und
  vergleicht das Umgebungs-Handle mit SQL_NULL_HENV (ganzzahlige Handles).
- zos-ld: "clib dsnao64c/dsnao64w" bindet das Db2-Sidedeck und setzt STEPLIB/
  DSNAOINI im Start-Skript (wie zfpc --db2); build-packages.sh baut odbc und
  fcl-db/src/sqldb/odbc (340 Package-Units, Soll-Liste unverändert).
- pf8/sqldbtest.pas (10 Prüfungen über TSQLQuery/TSQLTransaction): lokal gegen
  SQLite 10/10, CI-Schritt x86; für z/OS übersetzt, dort noch nicht gelaufen.
- Allgemeiner FPC-Fehler gefunden: odbcsql SQLINTEGER = clong ist auf 64-Bit-
  Unix 8 Byte, der Treiber schreibt 4 (SQLGetDiagRec liefert -4294967295 statt
  1 unter Linux); Issue-Text, Patch 0008 und Reproduzierer in fpc/upstream/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EPRbtCyWfDPbr8mS8FXmY8
@mms-it-ch
mms-it-ch merged commit 2e5918e into main Oct 7, 2026
4 checks passed
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.

2 participants