Lesson 3 of 5
EDI to XML and back
10 min
Listen to this lesson
Mappings work on XML. EDI arrives as flat text with segment terminators and element separators, and leaves the same way. The converters sit at those two edges of a flow, and three companion steps (the EDI Extractor, the EDI Validator and number ranges) handle headers, deep validation and control numbers.
EDI to XML Converter
The EDI to XML Converter transforms a single incoming EDI message (EDIFACT, ODETTE or ASC X12) into XML using the XSD you attach or name in a header. SAP documents the limits plainly: for X12, one group (GS) per interchange and one transaction set (ST) per group; for EDIFACT, one message type per interchange; and no support for repetition characters (such as ^ in ISA11 of newer X12 versions). Options you'll set include source and target encoding (UTF-8 or ISO-8859-1), target decimal character, how empty segments are handled, and whether to exclude interchange and group envelopes from the XML.
Excluding envelopes is a design choice, not a default to accept blindly. If your mapping needs ISA or GS values, such as the sender ID or usage indicator, either keep the envelopes or read them first with the EDI Extractor.
EDI Extractor
The EDI Extractor reads envelope values from a single EDI document (flat file or XML) and writes them to message headers, so routing and logging can use them without parsing the payload. For an X12 document it creates headers such as these:
| Header | Comes from | Example from a Great Lakes 850 |
|---|---|---|
| SAP_EDI_Document_Standard | Detected standard | ASC-X12 |
| SAP_EDI_Sender_ID / SAP_EDI_Sender_ID_Qualifier | ISA06 / ISA05 | GLFLEETEDI / ZZ |
| SAP_EDI_Receiver_ID / SAP_EDI_Receiver_ID_Qualifier | ISA08 / ISA07 | CONTOSOMC / ZZ |
| SAP_EDI_Interchange_Control_Number | ISA13 | 000072318 |
| SAP_EDI_Message_Type / SAP_EDI_Message_Version | ST01 / GS08 | 850 / 004010 |
| SAP_ISA_Usage_Indicator | ISA15 | P (production) or T (test) |
EDI Extractor headers for an X12 interchange, with Contoso values.
XML to EDI Converter
Outbound, the XML to EDI Converter turns one XML message into EDIFACT, ODETTE or X12 flat format against its XSD. You can set source and target encoding and, with Use Custom Separators, choose the segment terminator, composite separator, data element separator, escape character and decimal character, either from a list, as a hexadecimal value such as #x2b for a plus sign, or from a header. Agree the separators with each partner in writing: a partner whose parser expects ~ as segment terminator will reject a file that uses a newline. SAP also notes that when both PO and Integration Advisor XSDs are supplied, the converter prioritizes the Integration Advisor XSD.
EDI Validator
Validation can happen in the splitter, but sometimes you need it as its own step, for example after a mapping or before sending. The EDI Validator (palette: Message Validator > EDI Validator) validates an EDI flat file in UN/EDIFACT, ODETTE or ASC X12 against the configured XSD. Standard Validation checks structure; Extended Validation also checks conditional rules expressed as XSLT constraints in the schema. With Prevent Exception on Failure, the flow continues and the error details land in the header SAP_EDIValidationResult as an XML document listing errors by interchange, group and message, with XPath and error codes, so you can build your own rejection or report.
| Step | Validates | Typical use |
|---|---|---|
| EDI Splitter | Envelopes and messages of a bulk interchange, with acknowledgment | First step for every inbound interchange |
| EDI Validator | One EDI flat file against an XSD, standard or extended | Outbound check before sending, or a separate quality gate |
| XML Validator | An XML payload against an XML schema | Validating the XML side of a mapping, such as IDoc XML |
Integration Advisor runtime artifacts and templates
If you design mappings in Integration Advisor but build your own flows, SAP publishes the package EDI Integration Templates for SAP Integration Advisor on SAP Business Accelerator Hub, with templates for EDI to IDoc, EDI to SOAP, IDoc to EDI and IDoc to cXML. The EDI to IDoc template shows the canonical inbound chain: AS2 sender, validate and analyze the interchange (with acknowledgment), a router, the EDI to XML Converter, qualifier pre-processing with the MIG's _preproc.xsl, optional extended validation against the MIG's "Russian doll" XSD, the MAG's XSLT mapping, qualifier post-processing, and preparation of the IDoc control record (EDI_DC40) before the IDoc receiver.
Number ranges for outbound control numbers
Every outbound interchange needs a unique control number. Cloud Integration provides number range objects (Monitor > Manage Stores > Number Ranges) with a minimum value, a maximum value of fewer than 15 digits, a field length that pads with zeros (at most 14), and a Rotate flag that resets the range to its minimum when the maximum is reached. For EDIFACT the interchange control reference is 1 to 9 digits; for X12, ISA13 is 9 digits, so a range from 1 to 999999999 with field length 9 fits.
- CreateNumber range CMC_GLFS_ISA13: minimum 1, maximum 999999999, field length 9, Rotate on.
- AlignNext value set to 4512, one above the last ISA13 Process Orchestration sent to Great Lakes.
- UseA Content Modifier reads the next value into the ISA13 field before the XML to EDI Converter.
- WatchThe support runbook checks the next value monthly and before every cutover.
What would you do?
A new flow's EDI to XML Converter fails on Great Lakes' test 850 with a schema error. Great Lakes' ISA header contains the repetition separator ^ in ISA11, and the XSD is named ASC_850004010.xsd. What should the developer check first?
- The EDI to XML Converter handles one message; for X12 one GS per ISA and one ST per GS; no repetition characters.
- The EDI Extractor writes envelope values such as sender ID, control number and usage indicator to SAP_EDI headers.
- The XML to EDI Converter supports custom separators; agree them with each partner.
- The EDI Validator offers standard and extended validation and can report errors in SAP_EDIValidationResult instead of failing.
- Number ranges give unique outbound control numbers; align them with the legacy platform at cutover.
Check your understanding · not graded
Lesson check
1. Which step writes ISA13 and ISA15 values from an incoming X12 document into message headers?
2. What does Extended Validation in the EDI Validator check in addition to structure?
3. How do you make the XML to EDI Converter use a plus sign as the data element separator?
4. What does the Rotate flag on a number range do?