Pushing MES Return Orders into U8 Sales Outbound (Red-Word): A Deep Dive into One Strategy
What This Strategy Solves (Scenario and Value)
In a manufacturer's supply chain, MES is the "source of truth" on the shop floor, while the ERP (U8 here) is the "ledger" for finance and inventory. When a return happens on the floor, the operator logs a return order in MES, and finance needs to immediately see a red-word sales outbound voucher in U8 so that inventory and receivables can be reversed in sync. It looks like a single strategy, but return scenarios are trickier than outbound: the document direction is reversed (red-word), quantities are negative, and the auto-audit switch must be handled carefully. A small mistake and inventory no longer reconciles. In real projects, we use the Qeasy Data Integration Platform to carry this strategy, stably converting MES return orders into U8 red-word sales outbound vouchers.
Data Flow and Field Mapping (Source → Middle Layer → Target)
The pipeline is one-way: MES return order → Qeasy middle layer → U8 sales outbound voucher (red-word).
The source side pulls return records from MES's common/search API, paginated by bomNo/id (100 per page), with queryKey identifying the return type. The target side calls U8's XSCKDAdd (sales outbound add) and forces red-word direction via bIsRedVouch=true.
Key field mapping table:
| Business meaning | MES source field | Middle-layer variable | U8 target field | Note |
|---|---|---|---|---|
| Document date | createTime | {{createTime}} | dDate | Formatted to second |
| Return number | confrimNo | {{confrimNo}} | cCode | Outbound number, must be unique |
| Red/blue flag | Business type/qty sign | Derived | bIsRedVouch | Hard-coded true |
| Add type | — | Constant | AddType | Value 1 (new) |
| Auto audit | — | Constant | AutoAudit | Default true, switchable |
Worth noting: in return scenarios the quantity is already negative, and bIsRedVouch must be explicitly set to true—both are required. This is one of the easiest places to trip up.
How to Configure in Qeasy
The source is a query-type WebAPI and the target is an execute-type WebAPI—this strategy is a textbook case in Qeasy.
- Source connector: register the MES platform, bind the request parameter template (
pageNum/pageSize/wsId/queryKey), enable pagination and incremental cursor (useidas cursor key). - Target connector: register the U8 platform, point the API to
XSCKDAdd, hard-codebIsRedVouch=true,AddType=1, and convert the timestamp indDatewithDATE_FORMAT('{{createTime}}', '%Y-%m-%d %H:%i:%s'). - Code mapping: material codes, customer codes, warehouse codes, and units of measure are centrally managed in Qeasy's "Code Mapping" module. This is a common pattern among Qeasy customers—a single source of truth for all master data mappings, making audit and traceability straightforward.
- Header/body phased writing: a return order usually has a header (number, customer, date) and multiple body rows (material, qty, batch). We recommend landing the header in the staging table first, then expanding the body line by line keyed on the document number, and writing each line to U8. If one line fails, you can retry that single line without rolling back the whole document.
- Idempotency and retry: ERP systems like U8 reject duplicate submissions. Configure a dedup key (typically
cCode+ line number) and auto-retry 2–3 times on failure to avoid lost documents from network jitter.
Implementation Steps (Phased Scheduling)
- First full load trigger: on go-live day, manually trigger a full load in Qeasy to backfill historical returns (align the cut-off time with finance first, to avoid double reversals).
- Incremental start point: after the full load, Qeasy automatically records the cursor position (
idCheck=trueis enabled) and proceeds incrementally from there. - Scheduling frequency: source side uses
*/9 7-22 * * *(every 9 minutes, covering 7am–10pm working hours); target side uses2-59/9 7-22 * * *(staggered by 2 minutes, so the target does not compete for resources with the source during stress tests). - Reconciliation mechanism: at 22:30 every day, run a reconciliation comparing MES and U8 return numbers. Any discrepancies enter a "pending review" queue for ops to follow up manually.
Pitfalls and Lessons Learned
- Judging red-word documents by negative quantity alone will fail you. If the source system still fills the return quantity as positive and uses a business type to distinguish red/blue, you must explicitly pass
bIsRedVouch=true—do not rely on the quantity sign. The safe approach is to add a validation rule in the mapping: a red-word document's quantity must be ≤ 0. - Think carefully about the AutoAudit switch. Turning it on by default is convenient, but finance usually wants "see the document first, then manual review". We recommend leaving it off during initial rollout and turning it on after two weeks of stable runs.
- Document number conflicts. MES return numbers and U8 outbound numbers follow different conventions, so passing
confrimNodirectly ascCodecan collide. A safer approach is to add a prefix in Qeasy (e.g.TH-), or let U8 auto-generate the number and write the external reference back via an "external number" field. - Cursor failure causes dropped records. If MES's
idcursor is sorted as a string, newly inserted ids may not be strictly increasing—causing "cursor skipping → dropped records". The safe approach is to double-key the check withupdateTime; if the timestamp goes backward, automatically pause and raise an alert. - Missing batch/serial number fields. Returns in manufacturing often involve batch traceability. If U8 requires batch input and the mapping forgets to include it, U8 will reject the whole document. We recommend running a "field completeness check" in Qeasy before the first full load.
Applicable and Non-applicable Scenarios
Applicable: manufacturers where MES already logs returns and need real-time red-word sales outbound in U8 (or similar ERP) for inventory reversal and financial accounting. Not applicable: enterprises whose returns must go through an approval workflow before landing in ERP (this strategy is a direct push with no approval node); nor complex cross-ledger or cross-organization returns (these should be split into multiple strategies).