Generate EDI acknowledgments Last updated: 2026-10-01
ediFabric Native generates an X12 acknowledgment in the same call that validates the file. parse in mode 3 returns the transaction JSON, then a report that holds the acknowledgment. This walkthrough follows example_all_functions.py in the Python bindings. The .NET, Native, and Cloud overview is Generate EDI acknowledgments.
Load the library and the model
The example loads the native library, authorizes with set_serial, then calls set_map. The acknowledgment demos run after demo_set_online_map. That function reads map/map.json and sets default to the serial, which is load_online_map. load_local_map is the earlier call, used for the mode 1 parse: it points each map entry's location at the map folder and leaves default blank.
serial in the example comes from --serial, then EDIFABRIC_SERIAL, then the Community serial in the file. Copy yours from Your account.
import json
from pathlib import Path
import edifabric_x12 as ef
ROOT = Path(__file__).resolve().parent
MAP_PATH = ROOT / "map" / "map.json"
ef.load_library()
ef.set_serial(serial)
model_map = json.loads(MAP_PATH.read_text(encoding="utf-8"))
model_map["default"] = serial
ef.set_map(json.dumps(model_map))set_map has to run before parse. The same set_map call is demo_set_online_map in the example.
Parse with an acknowledgment
ParseMode.JSON is 1, ParseMode.JSON_VALIDATE is 2, and ParseMode.JSON_VALIDATE_ACK is 3. Mode 3 is the acknowledgment. demo_parse_ack parses edi/837p.txt. demo_parse_ack_invalid parses edi/837p_error.txt with the same configuration. Both read the file with read_text(encoding="utf-8").
The configuration is PARSE_CONFIG in the example. gen997 false keeps the X12 acknowledgment as a 999. Set it true for a 997. supress_ta1 is spelled that way in the bindings. False leaves TA1 to ISA14: it is generated when ISA14 is 1. gen_for_valid true also writes an AK2 loop for valid transactions. ak901p false leaves AK901 as E for a partial group. True writes P.
edi = (ROOT / "edi" / "837p.txt").read_text(encoding="utf-8")
config = json.dumps({
"validate": {
"regex": None,
"date_format": None,
"time_format": None,
"skip_seq_count": False,
"skip_hl_seq": False,
"snip_level": 4,
"max_errors": 100,
},
"ack": {
"supress_ta1": False,
"ak901p": False,
"gen_for_valid": True,
"gen997": False,
},
})
output, offset = ef.parse(edi, ef.ParseMode.JSON_VALIDATE_ACK, config)Read the report
parse in edifabric_x12.py returns a UTF-8 string and an offset. For mode 3 the offset is where the validation and acknowledgment JSON starts. The slice is already a string. Do not call decode on it. The README reads errors_count and ack from that object. demo_parse_ack prints the same slice.
report = json.loads(output[offset:])
print(report["errors_count"], report["ack"])The full program, including the invalid 837P file, is example_all_functions.py. How .NET and Cloud generate the same receipt is Generate EDI acknowledgments.
