When MES cancels check-out and the transfer order is scrap stock-in type (TRANSORDERTYPE=58),
call this API to notify ERP to cancel the corresponding defective stock-in document.
Basic Information
API Name
wo.scrap.data.process
Internal Task Name
woScrapDataProcess
Format
JSON (Content-Type: application/json)
Case Number
0189144
API Number
api-2192
TRANSORDERTYPE
58 (Scrap Stock-In)
Trigger Timing
Cancel API Decision Logic
When cancelling check-out, system determines which cancel API to call based on SFT_TRANSORDER_LINE.TRANSORDERTYPE:
TRANSORDERTYPE
Document Type
API Called
Task Name
58
Scrap Stock-In (Defective)
wo.scrap.data.process
woScrapDataProcess
59
Outsourcing Stock-In
outsourcing.process
outsourcingProcess
Other
General Stock-In
stockin.data.process
cancelStockIn
Code Location
Decision logic is in GeneralUpdater.excuteDeleteErpTransOrders() method,
lines 1577-1592.
Request Parameters
Field
ERP Field Name
Type
Required
Description
Company Code
enterprise_no
String
Required
Enterprise code
Site Code
site_no
String
Required
Factory/site code
Scrap Document No
doc_no
String
Required
Stock-in document to cancel (format: TL011-TL012)
Document Number Format
Document number format is TL011-TL012, e.g.: 58-20260319001.
This value comes from doc_no returned by ERP when creating scrap stock-in, stored in SFT_TRANSORDER_LINE.
After successful scrap stock-in cancellation, MES will clear related transfer order records:
Clear SQL
-- Clear SFT_TRANSORDER_LINE ERP document numbers
UPDATE SFT_TRANSORDER_LINE
SET TL011 = '',
TL012 = ''
WHERE TRANSORDERTYPE = '58'
AND TL011 = :TL011
AND TL012 = :TL012
-- Or delete entire transfer order record (depends on system settings)
DELETE FROM SFT_TRANSORDER_LINE
WHERE TRANSORDERTYPE = '58'
AND TRANSNO = :TRANSNO
Race Condition Risk
Important Notice
Like other cancel APIs, cancel scrap stock-in also has Race Condition risk:
Scenario: Cancel immediately after check-out, but ERP has not yet returned scrap stock-in document number Result:TL011/TL012 is empty, cannot call ERP cancel Consequence: MES has cancelled check-out, but ERP scrap stock-in document still exists
Decision Logic
// GeneralUpdater.java:1571-1575
if(!SftTransorderLine.getTl011().equals("") && !SftTransorderLine.getTl012().equals("")){
// Only call ERP cancel when TL011/TL012 has value
String stock_in_no = SftTransorderLine.getTl011() + "-" + SftTransorderLine.getTl012();
// Determine which API to call based on TRANSORDERTYPE
...
} else {
// TL011/TL012 is empty, skip ERP call
}
Recommended Solutions
Wait for ERP return success before allowing cancel after check-out
Add Lock mechanism to prevent simultaneous operations
Periodically compare MES and ERP scrap stock-in document status