Now accepting guest editorial from SAP, Oracle, Workday and ServiceNow practitioners.Pitch a guide
The Sign-Off Table

Lesson 3 of 5

EDI to XML and back

10 min

Listen to this lesson

0:00 / 15:14

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:

HeaderComes fromExample from a Great Lakes 850
SAP_EDI_Document_StandardDetected standardASC-X12
SAP_EDI_Sender_ID / SAP_EDI_Sender_ID_QualifierISA06 / ISA05GLFLEETEDI / ZZ
SAP_EDI_Receiver_ID / SAP_EDI_Receiver_ID_QualifierISA08 / ISA07CONTOSOMC / ZZ
SAP_EDI_Interchange_Control_NumberISA13000072318
SAP_EDI_Message_Type / SAP_EDI_Message_VersionST01 / GS08850 / 004010
SAP_ISA_Usage_IndicatorISA15P (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.

Contoso's outbound 856 for Great Lakes in a custom flow: map, number, convert, send.
The Sign-Off Table · thesignofftable.com/academy/sap-edi-302

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.

StepValidatesTypical use
EDI SplitterEnvelopes and messages of a bulk interchange, with acknowledgmentFirst step for every inbound interchange
EDI ValidatorOne EDI flat file against an XSD, standard or extendedOutbound check before sending, or a separate quality gate
XML ValidatorAn XML payload against an XML schemaValidating the XML side of a mapping, such as IDoc XML
Three places to validate in a B2B flow.
The Sign-Off Table · thesignofftable.com/academy/sap-edi-302

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.

  1. CreateNumber range CMC_GLFS_ISA13: minimum 1, maximum 999999999, field length 9, Rotate on.
  2. AlignNext value set to 4512, one above the last ISA13 Process Orchestration sent to Great Lakes.
  3. UseA Content Modifier reads the next value into the ISA13 field before the XML to EDI Converter.
  4. WatchThe support runbook checks the next value monthly and before every cutover.
How Contoso sets up the outbound ISA13 number range for Great Lakes.
The Sign-Off Table · thesignofftable.com/academy/sap-edi-302

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?

Key points
  • 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. 1. Which step writes ISA13 and ISA15 values from an incoming X12 document into message headers?

  2. 2. What does Extended Validation in the EDI Validator check in addition to structure?

  3. 3. How do you make the XML to EDI Converter use a plus sign as the data element separator?

  4. 4. What does the Rotate flag on a number range do?