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

Lesson 4 of 6

Simulating and testing MAGs: the outbound 810

9 min

Listen to this lesson

0:00 / 14:41

A MAG is code, even when it is drawn. It needs tests with known inputs and expected outputs, and Integration Advisor lets you run them where you design. This lesson uses Contoso's outbound invoice to Great Lakes: INVOIC02 from S/4HANA CMP mapped to an X12 810 (version 004010), using invoice 90001877 for sales order 1000457, 50 × CMC-ALT-100 at 240.00 = 12,000.00 USD, tax-exempt.

810 segmentContent for invoice 90001877Source in INVOIC02
BIGBIG01 invoice date, BIG02 90001877, BIG04 Great Lakes PO GLF-PO-55120E1EDK02 document references (invoice number and customer PO qualifiers)
N1 [BT] / N1 [ST]Bill-to and ship-to depot in Great Lakes' own codesE1EDKA1 partner segments, translated with a code value mapping
IT1Line 1: 50, EA, 240.00, VP CMC-ALT-100, BP Great Lakes part numberE1EDP01 quantity and unit, E1EDP19 material numbers, E1EDP26 amounts
TDSTDS01 1200000 (implied two decimals = 12,000.00)E1EDS01 summary amount, multiplied by 100 in a function
CTTOne line itemCount of E1EDP01 segments

The 810 for invoice 90001877 and where each part comes from. No TXI tax segment: the customer is tax-exempt in this example. Check your INVOIC02 output for the exact qualifiers it fills.

Two ways to simulate

Open the MAG, expand the nodes on the Mapping tab and choose Simulate. Simulate with MIG Example Data runs the mapping on a payload generated from the source MIG's example values. Simulate with Payload Data asks for a real Source Payload (XML, or EDI flat file for EDI type systems) and, optionally, an Expected Target Payload. A Simulation Data column then shows source values and transformed target values side by side; errors open a dialog that links straight to the failing node.

The expected target payload turns a demo into a test. Integration Advisor compares the simulated and expected values, shows an Expected Data column, counts the differences, and lets you step through them with Previous Difference and Next Difference. Group nodes are compared by instance count and leaf nodes by value.

Contoso's MAG test loop: a real INVOIC02 as input, the 810 that Process Orchestration produced for the same invoice as the expected result, and zero unexplained differences as the exit criterion.
The Sign-Off Table · thesignofftable.com/academy/sap-pim-206

Where do expected payloads come from? While Process Orchestration still runs the interface, it's the best oracle: the 810 that XP1 produced for the same INVOIC02, minus envelope control numbers. After the move, expected payloads come from the partner's spec examples and from approved earlier runs. This is the same equivalence idea as Contoso's PO migration replays, applied inside the design tool.

The first run for 90001877 showed one difference: TDS01 came out as 12000.00 instead of 1200000. X12's TDS amount has two implied decimal places, so the mapping needed a function that removes the decimal point after scaling. A second difference appeared in a two-line test invoice: the CTT count was 1 because it was mapped from the header. Both were mapping defects that a field-by-field eyeball check would likely have missed.

The defect loop for the 810 MAG: testers with read access simulate and record results; developers fix the draft; the rerun is the retest.
The Sign-Off Table · thesignofftable.com/academy/sap-pim-206

Keep the test set with the guideline, not in someone's downloads folder. Contoso stores each case as a pair, source payload and expected target, in the SAP Cloud ALM test case for the MAG, named after the partner and message (for example GLFS-810-02 two lines). Every new draft version of the MAG is rerun against the full set before activation, so a change for one depot can't quietly break another. Testers with the iadv-content-read role can run simulations without being able to edit the guideline they are testing, which keeps the roles clean.

Getting the output out

After a run, Download simulation result saves the target payload. The default is XML in Cloud Integration format without Integration Advisor's qualifier suffixes; for EDI targets such as ASC X12 you can choose Download as EDI Flat File. Priya's team attaches that file, the input and the difference count to the test case in SAP Cloud ALM. Clear Simulation removes the data when you are done.

MIG simulationDoes the partner's real file fit the guideline? Reports undefined nodes.
MAG simulation with expected payloadDoes the mapping produce exactly the agreed output? Counts differences.
Integration flow test in Cloud IntegrationDo envelopes, splitter validation, acknowledgments and IDoc posting work with the deployed artifacts?
Connected test with the partnerDoes Great Lakes accept the 810 and return a 997? Does CMP post the 850 as a sales order?
Simulation is the first two layers of testing, not all of it. Envelopes, acknowledgments and posting are tested in the runtime and with the partner.
The Sign-Off Table · thesignofftable.com/academy/sap-pim-206

Building a test set that lasts

  • Happy path: one-line and multi-line orders and invoices, such as 90001877 and a three-line invoice.
  • Qualifier coverage: every N1 role and product ID qualifier the MIG allows.
  • Code values: one case per entry in each code value mapping, so a missing entry fails a test, not production.
  • Boundaries: maximum line count, longest text fields, zero-price or free-of-charge items if the spec allows them.
  • Negative: unit CA instead of EA, missing BEG03, unknown depot code; these belong to MIG validation and the runtime, so record where each is expected to fail.
Key points
  • Simulate MAGs with real source payloads and an expected target payload; the difference count is your test result.
  • While PO still runs an interface, its output is the best expected payload for equivalence.
  • Download the simulated target as an EDI flat file and keep it as evidence.
  • Simulation proves mapping logic; envelopes, acknowledgments and posting still need runtime and partner tests.

Check your understanding · not graded

Lesson check

  1. 1. What does uploading an Expected Target Payload add to a MAG simulation?

  2. 2. TDS01 came out as 12000.00 for invoice 90001877. Why is that a defect?

  3. 3. Which simulation download suits an X12 810 test record in SAP Cloud ALM?

  4. 4. Which risk does MAG simulation alone not cover?