Work Order Status Change

wo.status.process
POST JSON Sync ERP → MES

1. Basic Information

ItemDescription
API Chinese NameWork Order Status Change (Delete/Close/Reopen)
API English NameWork Order Status Process
API Codewo.status.process
Case Number0189142
REST EndpointPOST /ESB/API/upModetailStatus
Call DirectionERP → MES
Trigger TimingWhen ERP deletes, closes, or reopens work order
Main Business ScenarioERP changes order status, sync update MES order status or delete order data
Request FormatJSON (Content-Type: application/json)
Sync/AsyncSynchronous call
Call Direction Note
This API is ERP → MES one-way push.
Different operations are executed based on status parameter: Delete(1), Close(2), Reopen(3).

2. Status Mapping Table

statusOperationDescriptionMES Behavior
1Delete OrderDelete order and related lotsDELETE MODETAIL / LOT
2CloseOrder designated complete/closeCheck incomplete process, change status
3ReopenRestore closed orderRestore STATUS (99/100 → original status)

MODETAIL.STATUS Definition

STATUSDescription
1Not Started
2In Progress
3Pending Close
99Closed
100Cancelled

3. Request Specification

Format: JSON
Content-Type: application/json
FieldTypeRequiredDescriptionExample
CompanyIdstringYCompany code"COMP01"
langstringNLanguage"zh_TW"
wo_nostringYWork order number (type-number)"5101-20260319001"
statusstringYOperation type (1/2/3)"1"

4. Response Specification

FieldTypeDescription
codestring200=Success, 500=Failure
msgstringProcessing result message or error code

5. Processing Logic

5.1 status=1 Delete Order

status=1 Delete Released? JS_0126_00062 Yes DELETE MODETAIL DELETE LOT No Complete Check SFT_WS_RUN.EXECUTETYPE='release'
Delete Restriction
If the order has been released (SFT_WS_RUN has EXECUTETYPE='release' record), cannot delete, throws error JS_0126_00062.

5.2 status=2 Close

status=2 Close On Hold? JS_0115_00014 Yes Incomplete ops? No JS_0115_00017 Yes Execute Close No Check SFT_HOLD_REC (hold) and SFT_OP_REALRUN (incomplete)
Close Validation
  • Check SFT_HOLD_REC: Is order on hold
  • Check SFT_OP_REALRUN: Are there incomplete operations

5.3 status=3 Reopen

status=3 Reopen STATUS in(99,100)? JS_0126_00059 No Restore Status Yes Check if MODETAIL.STATUS is closed/cancelled
Reopen Condition
Only orders with STATUS=99 (Closed) or STATUS=100 (Cancelled) can be reopened.

6. Error Codes

CodeMessageTrigger ConditionApplies to status
JS_0126_00062Order has been released, cannot deleteSFT_WS_RUN has release recordstatus=1
JS_0115_00014Order is on hold, please release hold before closingSFT_HOLD_REC has hold recordstatus=2
JS_0115_00017This order has incomplete operations, please complete firstSFT_OP_REALRUN has incomplete opsstatus=2
JS_0126_00059eMES order not closed, cannot reopenMODETAIL.STATUS not in (99,100)status=3
remind_002Data does not existOrder number does not existall

7. JSON Examples

Request - Delete Order (status=1)

{
  "CompanyId": "COMP01",
  "lang": "zh_TW",
  "wo_no": "5101-20260319001",
  "status": "1"  // Delete
}

Request - Close (status=2)

{
  "CompanyId": "COMP01",
  "lang": "zh_TW",
  "wo_no": "5101-20260319001",
  "status": "2"  // Close
}

Request - Reopen (status=3)

{
  "CompanyId": "COMP01",
  "lang": "zh_TW",
  "wo_no": "5101-20260319001",
  "status": "3"  // Reopen
}

Response (Success)

{
  "code": "200",
  "msg": "success"
}

Response (Failure - Already released cannot delete)

{
  "code": "500",
  "msg": "JS_0126_00062"
}

Response (Failure - On hold cannot close)

{
  "code": "500",
  "msg": "JS_0115_00014"
}

Response (Failure - Not closed cannot reopen)

{
  "code": "500",
  "msg": "JS_0126_00059"
}

8. Database Update SQL

8.1 status=1 Delete Order

-- Check if already released (cannot delete if released)
SELECT COUNT(*) FROM SFT_WS_RUN WITH (NOLOCK)
WHERE ID = N'{wo_no}'
  AND EXECUTETYPE = 'release'
  AND PLUSINDEX = '0'
-- If COUNT > 0, throw JS_0126_00062

-- Check for split batch records
SELECT COUNT(*) FROM SFT_BATCH_REC WHERE BR001 = N'{wo_no}'
-- If COUNT > 0, throw remind_004

-- Delete related data (execute in order)
DELETE FROM SFT_OP_REALRUN WHERE ID = :CMOID
DELETE FROM LOT WHERE MOID = :CMOID
DELETE FROM MODETAIL WHERE CMOID = :CMOID
DELETE FROM SFT_SPEC_MODIREC WHERE MD001 = :CMOID
DELETE FROM SFT_BATCH_REC WHERE BR002 = :CMOID
DELETE FROM EQUIPMENT_RUN WHERE LOTID = :CMOID
DELETE FROM SFT_WS_RUN WHERE ID = :CMOID
DELETE FROM SFT_SPLITOUT_REC WHERE SSR001 = :CMOID
DELETE FROM SFT_ASSEMBLY_REC WHERE SAR001 = :CMOID
DELETE FROM SFT_HOLD_REC WHERE HR001 = :CMOID
DELETE FROM SFT_MO_MODI WHERE MODI002 = :CMOID

8.2 status=2 Close

-- Check if order is on hold
jsonQueryFactory.sqlQuery_checkMoidIsHold(dataObject)
-- If on hold, throw JS_0115_00014

-- Check for incomplete operations
jsonQueryFactory.checkHaveUndoneOp(dataObject)
-- If has incomplete ops, throw JS_0115_00017

-- Execute close flow (handled by JsonQueryFactory)
-- Update MODETAIL.STATUS = 99
UPDATE MODETAIL SET
    STATUS = 99,
    LASTMAINTAINUSER = :userid,
    LASTMAINTAINDATETIME = N'{current_time}'
WHERE CMOID = :CMOID

8.3 status=3 Reopen

-- Check if order is closed
SELECT COUNT(*) FROM MODETAIL WITH (NOLOCK)
WHERE CMOID = N'{wo_no}'
  AND STATUS NOT IN ('99', '100')
-- If COUNT > 0, not closed, throw JS_0126_00059

-- Restore closed status (reverse close flow)
-- Determine restore status based on SFT_WS_RUN check-in records
UPDATE MODETAIL SET
    STATUS = CASE
        WHEN (SELECT COUNT(1) FROM SFT_WS_RUN WITH (NOLOCK)
              WHERE ID = N'{wo_no}' AND EXECUTETYPE = 'checkIn') > 0
        THEN 2  -- Has check-in record → In Progress
        ELSE 1  -- No check-in record → Not Started
    END,
    LASTMAINTAINUSER = :userid,
    LASTMAINTAINDATETIME = N'{current_time}'
WHERE CMOID = :CMOID
Related Tables Deleted
TableDescription
SFT_OP_REALRUNProcess execution records
LOTLot records
MODETAILWork order master
SFT_SPEC_MODIRECSpecial modification records
SFT_BATCH_RECSplit batch records
EQUIPMENT_RUNEquipment run records
SFT_WS_RUNWorkstation run records
SFT_SPLITOUT_RECSplit out records
SFT_ASSEMBLY_RECAssembly records
SFT_HOLD_RECHold records
SFT_MO_MODISupplementary release qty records
Code Location
API Entry: ESBapi.java:1400-1493
Status Validation: WoStatusProcess.java:66-108