lumnik. / scénarios Tous les scénarios · English

AS/400: le client au-delà de son encours autorisé, lu en EBCDIC

Objectif Lire le fichier clients d'un IBM i dans son EBCDIC français, et être prévenu quand l'encours d'un client dépasse son plafond.

Un fichier clients d'IBM i, CLIENTS, CCSID 297: 30 clients.

manifests/10-clients-binary.yaml
# The first attempt: the physical file CLIENTS, transferred in binary, read as text.apiVersion: connectors.lumnik.io/v1kind: Connectormetadata:  name: scenario-as400-bin-a  connector_type: csv-file  scopes: [credit-as400-a]spec:  transport:    kind: local    path: /tmp/lumnik-scenario/as400-customer-credit/a/CLIENTS.bin  parser:    lines: true    encoding: IBM297               # CCSID 297, the IBM i's French EBCDIC  after_process: none
record 1
f4 f1 f0 f0 f0 f1 d8 a4 89 95 83 81 89 93 93 85 99 89 85 40 c4 a4 82 96 85 a4 86 40 40 40 40 40 40 40 40 40 e2 81 89 95 a3 60 71 a3 89 85 95 95 85 40 40 40 40 40 40 40 f0 f0 f0 f0 f0 f0 f3 f5 f2 f5 4b f0 f0 f0 f0 f0 f0 f0 f0 f7 f5 f0 f0 4b f0 f0 0d 25

preuves: replay.log, binary-record-1.txt, dlq-letter.txt, export-record-1.txt, clients.txt, count-read.txt, over-limit.txt, inbox-day2.json · transform v1

manifests/20-clients.yaml
apiVersion: connectors.lumnik.io/v1kind: Connectormetadata:  name: scenario-as400-a  connector_type: csv-file  scopes: [credit-as400-a]spec:  transport:    kind: local    # CPYTOIMPF FROMFILE(GESCOM/CLIENTS) TOSTMF('/exports/CLIENTS-<date>.txt') DTAFMT(*FIXED) RCDDLM(*CRLF) STMFCCSID(297)    path: /tmp/lumnik-scenario/as400-customer-credit/a/cpytoimpf/CLIENTS-*.txt  parser:    lines: true                    # fixed columns, one record per line    encoding: IBM297  after_process: none  mapping:    cell:      # CLINUM 6, RAISOC 30, VILLE 20, ENCOURS 13, PLAFOND 13: the file's DDS, column by column      - regex-extract:          column: line          pattern: "^(.{6})(.{30})(.{20})(.{13})(.{13})$"          groups: { 1: clinum, 2: raisoc, 3: ville, 4: encours, 5: plafond }      - clean: { columns: [raisoc, ville], strip: true }      - parse-number: { column: encours, decimal-separator: "." }      - parse-number: { column: plafond, decimal-separator: "." }
manifests/30-over-limit.yaml
apiVersion: apps.lumnik.io/v1kind: Processmetadata:  name: scenario-as400-over-limit-aspec:  scope: credit-as400-a  on: { event: data.row.changed, table: connector.t_scenario_as400_a }  when:    - "encours>{plafond}"            # the outstanding balance above the customer's own credit limit  emit:    type: decision.credit-over-limit-a    message: "{clinum} {raisoc} ({ville}): {encours} € outstanding, credit limit {plafond} €"    key: clinum
$ lm connector run scenario-as400-a
run scheduled: 6233527a-5fda-44fe-946b-8eb0e5df1bdd

$ lm run get 6233527a-5fda-44fe-946b-8eb0e5df1bdd
ID        CONNECTOR         ENDPOINT  STATUS     IN  OUT  SKIPPED  DEAD-LETTERS  STARTED           ENDED             EVALUATED
6233527a  scenario-as400-a  default   Completed  30  30   0        0             2026-11-06 21:08  2026-11-06 21:08  yes
• 1 file(s) unchanged since they were last read — not read again

$ lm inbox --process scenario-as400-over-limit-a
ID     WHEN      PROCESS                      MESSAGE                                                                        ENTITY_KEY
24813  just now  scenario-as400-over-limit-a  410022 Escaliers Thérèse (Valence): 16470 € outstanding, credit limit 15000 €  410022
24812  just now  scenario-as400-over-limit-a  410007 Plomberie Gaëtan (Vienne): 23820 € outstanding, credit limit 22500 €    410007
24802  just now  scenario-as400-over-limit-a  410022 Escaliers Thérèse (Valence): 16470 € outstanding, credit limit 15000 €  410022
24801  just now  scenario-as400-over-limit-a  410007 Plomberie Gaëtan (Vienne): 23820 € outstanding, credit limit 22500 €    410007

Limites

  • Un transfert binaire ne se lit pas: pas de longueur d'enregistrement fixe, pas de décimal packé. L'export passe par CPYTOIMPF.
  • Le CCSID 297 n'a pas de œ: un nom écrit avec ne peut pas exister sur l'IBM i.
  • L'export de chaque jour est gardé: la table tient une ligne par client et par export.
  • Clients, encours et plafonds synthétiques.

Crédit · IBM i

Les clients vivent sur un AS/400.

En EBCDIC, CCSID 297.

CLIENTS: 30 clients, encours et plafond

Le fichier binaire

Un transfert binaire ne se lit pas.

  • Pas de délimiteur, des champs packés.
  • Chaque ligne en dead letter, la cause nommée.

Ce qui n'est pas modifié

L'IBM i reste tel quel.

  • CPYTOIMPF, sa propre commande d'export.
  • Aucune conversion en ASCII, aucun RPG.

Ce qu'il a fallu écrire

encoding: IBM297
when: ["encours>{plafond}"]

Le CCSID, les largeurs de la DDS, une condition.

  • csv-file: les colonnes fixes.
  • Un Process: l'encours au-delà du plafond.

Ce qui a été corrigé

Un octet NUL faisait échouer le run.

  • Désormais: une dead letter, la cause, le geste (#1855).
  • Avant: « Error invoking subclass method ».

Essayer

Le scénario se rejoue en local.

Chaque étape est publiée avec sa sortie.

Ce scénario tourne sur lumnik Open, gratuit et open source.

Essayer lumnik Open →