Lesson 4 of 5
IDoc automation
11 min
Listen to this lesson
IDocs are the workhorse of SAP integration: EDI orders and invoices, master data distribution, and many links between SAP systems. Every IDoc has a control record (who sent it, to whom, which message and IDoc type), data records (the segments with business data) and status records that log each processing step. An automated IDoc test creates or sends an IDoc, follows its status and checks the document it produced.
The status codes that matter
SAP's documentation for testing inbound processing is clear about the decisive statuses: when the application has accepted the IDoc, its status is 53 (application document posted); otherwise it is 51 (application document not posted), and the status records hold the application's error messages. Before that, status 64 means the IDoc is ready to be passed to the application. When the test tool writes an IDoc to an inbound file, it saves it with status 68 (error, no further processing).
- ArrivesStatus 64Saved and ready to be passed to the application; partner profile found.
- ProcessingInbound functionProcess code from the partner profile triggers the application logic.
- SuccessStatus 53Application document posted, for example a sales order.
- FailureStatus 51Application document not posted; error messages in the status records.
- AssertBusiness checkThe document exists with the expected data; links from IDoc to document are present.
Creating test IDocs: WE19
The IDoc test tool (transaction WE19) generates an IDoc manually and sends it for inbound or outbound processing. You can start from an IDoc type (an empty IDoc) or use an existing IDoc as a template and change segments and data. For inbound tests, SAP's documentation describes three options: standard inbound processing, where the IDoc is treated as if an external system sent it and the partner profiles are checked; calling the inbound function module directly, optionally in debugging mode; and writing an inbound file. Use standard inbound processing for regression tests, because it tests the partner profile and process code as production will use them.
For automated regression, WE19 is a design and debugging aid rather than the runner. A repeatable test sends the IDoc through the same channel production uses (a file port, an RFC from another system, or the middleware), with a template whose business values are parameters. Keep a library of anonymized template IDocs per message type and partner, and set unique references (such as the customer purchase order number) per run.
Monitoring and assertions
The status monitor (BD87) shows inbound and outbound IDocs grouped by status, message type or partner, lets you display individual IDocs with their control, data and status records, shows links to application objects, and lets you process IDocs manually. For automation you need the same information programmatically: find the IDoc by your reference or by message type and creation time, wait for a final status, read the status records, follow the link to the application document, and assert on that document.
- PrepareTemplate IDoc for message type ORDERS with partner Great Lakes Fleet Services (17100001, partner type KU); unique customer PO number.
- SendThrough the production channel (in test, Process Orchestration XQ1 and port XQ1_PO) into CMQ client 100, not straight into the function module.
- WaitPoll until the IDoc reaches 53 or 51, with a timeout; log the IDoc number.
- Check status53 expected; on 51 capture the status record messages as the failure reason.
- Check documentSales order in sales area 1710 / 10 / 00: sold-to, material CMC-ALT-100, quantity, price, delivery date.
Negative and edge cases
- Unknown material or customer: expect status 51 with the specific message, and no sales order.
- Missing partner profile: expect the IDoc to stop before the application; this proves configuration, not just code.
- Duplicate: send the same customer PO twice and check the expected duplicate handling (a warning, a block or a second order, per Contoso's design).
- Reprocessing: fix the master data and reprocess a 51 IDoc; it should then post. Remember that status 53 IDocs cannot be processed again.
- Volume: send a realistic batch and check that processing mode (immediate or collected) handles it without backlog.
What would you do?
An automated inbound order test reports PASS because the IDoc reached status 53. Maria then finds the sales order has the wrong ship-to party. What should change in the test?
- Status 53 means the application document was posted; 51 means it was not; 64 means ready for the application.
- WE19 builds and sends test IDocs; use standard inbound processing so partner profiles and process codes are tested.
- Run regression through the production channel with parameterized templates and unique references.
- BD87 shows status, records and links; automated tests need the same: wait for a final status, then check the document.
- Always assert on the posted business document, not just the IDoc status.
Check your understanding · not graded
Lesson check
1. Which IDoc status tells you the application document was posted?
2. Which WE19 inbound option tests the partner profile and process code as production uses them?
3. An inbound IDoc ends in status 51. Where does the test find the reason?
4. Which transaction is the status monitor for ALE messages?