When there is defect quantity during work order checkout, send the defect stock-in data to ERP to create a scrap stock-in order.
After ERP returns the stock-in order number, MES writes it back to SFT_TRANSORDER_LINE.
Basic Information
API Name
wo.scrap.data.create
Internal Task Name
woScrapDataCreate
Transport Format
JSON (Content-Type: application/json)
Case Number
0189144
API ID
api-2191
TRANSORDERTYPE
58 (Scrap Stock-In)
Trigger Timing
Key Condition:
Only when SCRAPQTY > 0 (defect quantity greater than zero) during checkout,
the system will create a transfer order with TRANSORDERTYPE=58 and call the ERP defect stock-in API.
Trigger Location
After checkout is completed, the TransOrderDataToJson.sentTransOrderDataAgain() method
determines the transfer order type; if it's scrap stock-in, it calls woScrapDataCreate.
{
"code": 200,
"msg": "Defect stock-in order created successfully",
"ERPMessage": {
"description": "Processing successful",
"doc_no": "58-20260319001"
}
}
Failure Response (code=500)
{
"code": 500,
"msg": "Defect stock-in order creation failed",
"ERPMessage": {
"description": "Warehouse code does not exist"
}
}
Response Field Description
Field
Type
Description
code
Integer
200=Success, 500=Failure
msg
String
Processing message
ERPMessage.doc_no
String
Defect stock-in order number returned by ERP (type-number)
ERP Write Back Logic
After ERP returns the defect stock-in order number, MES writes it back to the transfer order line:
Write Back SQL
-- Update SFT_TRANSORDER_LINE
UPDATE SFT_TRANSORDER_LINE
SET TL011 = '58',
TL012 = '20260319001'
WHERE TRANSORDERTYPE = '58'
AND TRANSNO = :TRANSNO
AND SN = :SN