Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions en/docs/develop/transform/edi.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The generated file contains:
- **`getSchema`**: returns the EDI schema as an `EdiSchema` object.
- **`fromEdiStringWithSchema`** / **`toEdiStringWithSchema`**: variants that accept a pre-loaded `EdiSchema`, useful when the same code must handle multiple schemas selected at runtime.

## Adjusting a schema for a trading partner
## Adapting the schema to a trading partner

Trading partners routinely use variations of a standard format: an extra segment, a segment the standard marks optional but the partner always sends, a different delimiter set, or a field the partner sends as a number where the standard says text. Because `convertEdifactSchema` and `convertX12Schema` write the schema out as JSON before any code is generated, a partner's deviations are handled by editing that file and re-running `codegen` — the standard specification itself is never touched.

Expand Down Expand Up @@ -287,11 +287,12 @@ public function main() returns error? {

orders:ORDERSInterchange interchange = check orders:interchangeFromEdiString(ediContent);
foreach var txn in interchange.transactions {
if txn.body is error {
log:printError("Quarantined malformed transaction", 'error = txn.body);
orders:ORDERS|error body = txn.body;
if body is error {
log:printError("Quarantined malformed transaction", 'error = body);
continue;
}
log:printInfo(txn.body.toString());
log:printInfo(body.toString());
}
}
```
Expand Down
9 changes: 5 additions & 4 deletions en/docs/reference/data-formats/edi.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ public function main() returns error? {

edi:EdiInterchange interchange = check edi:interchangeFromEdiString(ediText, schema);
foreach var txn in interchange.transactions ?: [] {
if txn.body is error {
io:println("Quarantined: ", txn.body.message());
json|error body = txn.body;
if body is error {
io:println("Quarantined: ", body.message());
continue;
}
io:println(txn.body);
io:println(body);
}
}
```
Expand All @@ -185,7 +186,7 @@ For full signatures, parameters, error types (`InvalidEnvelopeError`, `SchemaCom

## Custom EDI schemas

For EDI formats not covered by prebuilt packages — or when you need to tune a generated schema for partner-specific variations — define the structure as a JSON schema. The following JSON schema defines the structure of the simple order EDI format shown above.
For a proprietary or non-standard format — one with no X12 or EDIFACT specification to convert from — define the structure directly as a JSON schema. The following JSON schema defines the structure of the simple order EDI format shown above. To handle a trading partner's variations on a *standard* format, start from the converted schema instead: see [Adapting the schema to a trading partner](../../develop/transform/edi.md#adapting-the-schema-to-a-trading-partner).

```json
{
Expand Down