← Back to API List

Cancel Production Report (Report Reversal)

CANCEL MES → ERP
wo.work.report.data.process

When MES cancels check-out, call this API to notify ERP to cancel the corresponding production report, restoring reported data. ERP will void or reverse the report record upon receipt.

Basic Information

API Name
wo.work.report.data.process
Internal Task Name
cancelProductionForm
Format
JSON (Content-Type: application/json)
Case Number
0190760
API Number
api-2196
Data Direction
MES → ERP

Trigger Timing

Cancel Check-out CancelCheckOut User Action Query Report No PRODUCTION_REPORTID SFT_OP_REALRUN Report No Exists? Yes Send ERP Cancel cancelProductionForm wo.work.report.data.process No → Skip
Important Notice
Cancel production report only calls ERP when PRODUCTION_REPORTID has a value. If ERP has not yet returned the report number during check-out (TIMEOUT or failure), cancel will not be able to notify ERP to reverse.

Trigger Scenarios

Scenario 1: Normal Cancel Check-out

User clicks "Cancel Check-out" in MES, system queries report number then calls ERP to cancel that report.

Scenario 2: Batch Cancel Check-out

Batch cancel multiple check-out records, system calls ERP to cancel corresponding reports one by one.

Scenario 3: Rework Cancel

Cancel check-out at rework station also triggers production report cancel flow.

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
Report Number report_no String Required Report number to cancel (type-number)
Report Number Format
Report number format is PDTYPE-PDNO, e.g.: 10-20260319001. This value comes from SFT_OP_REALRUN.PRODUCTION_REPORTID or SFT_WS_RUN.WR024.

Request Example

JSON Format

{
  "enterprise_no": "COMP01",
  "site_no": "SITE01",
  "report_no": "10-20260319001"
}

ERP XML Format (WFERP)

<parameters>
  <parameter key="enterprise_no" type="string">COMP01</parameter>
  <parameter key="site_no" type="string">SITE01</parameter>
  <parameter key="report_no" type="string">10-20260319001</parameter>
</parameters>

Response Format

Success Response (code=200)

{
  "code": 200,
  "msg": "Production report cancelled successfully",
  "ERPMessage": {
    "description": "Process successful",
    "report_no": "10-20260319001"
  }
}

Failure Response (code=500)

{
  "code": 500,
  "msg": "Production report cancel failed",
  "ERPMessage": {
    "description": "Report already confirmed, cannot cancel"
  }
}

Response Field Description

Field Type Description
code Integer 200=Success, 500=Failure
msg String Processing message
ERPMessage.description String Detailed message from ERP

MES Clear Logic

After successful production report cancellation, MES will clear report number from related records:

Clear SQL Logic

-- Clear SFT_OP_REALRUN report number
UPDATE SFT_OP_REALRUN
SET PRODUCTION_REPORTID = '',
    PRODUCTION_REPORTSN = ''
WHERE ID = :KEYID
  AND ERP_OPSEQ = :ERP_OPSEQ
  AND SEQUENCE = :SEQUENCE

-- Clear SFT_WS_RUN report number
UPDATE SFT_WS_RUN
SET WR024 = '',
    WR025 = ''
WHERE (corresponding check-in/out record conditions)

-- Delete report header/detail (depends on system settings)
DELETE FROM SFT_SFCTE WHERE TE001 = :PDTYPE AND TE002 = :PDNO
DELETE FROM SFT_SFCTD WHERE TD001 = :PDTYPE AND TD002 = :PDNO

Difference from Other Cancel APIs

API Name Task Name Applicable Scenario Document Type Cancelled
wo.work.report.data.process cancelProductionForm General production report cancel Production Report
outsourcing.process outsourcingProcess Outsourcing stock-in cancel (TRANSORDERTYPE=59) Outsourcing Receipt
stockin.data.process cancelStockIn Stock-in cancel Stock-In Document
wo.scrap.data.process woScrapDataProcess Scrap stock-in cancel (TRANSORDERTYPE=58) Scrap Document
Decision Logic
When cancelling check-out, system determines which cancel API to call based on SFT_TRANSORDER_LINE.TRANSORDERTYPE:

- TRANSORDERTYPE = 59 → outsourcingProcess (Outsourcing)
- TRANSORDERTYPE = 58 → woScrapDataProcess (Scrap)
- Other → cancelStockIn or cancelProductionForm

Related Database Tables

Table Description Affected Fields
SFT_OP_REALRUN Process execution records PRODUCTION_REPORTID, PRODUCTION_REPORTSN (cleared)
SFT_WS_RUN Workstation execution records WR024, WR025 (cleared)
SFT_SFCTD Report header Entire record deleted or marked cancelled
SFT_SFCTE Report detail Entire record deleted or marked cancelled

Code Location

Function File Path Line Number
Cancel check-out entry SFT_core/src/com/dci/sft/update/GeneralUpdater.java 1571-1605
Cancel API call SFT_ERPIntegrate/src/com/dci/sft/erp/XmlToERP_handler.java 159-237
Clear report number SFT_core/src/com/dci/sft/jsonMappingHibernate/TransOrderDataToJson.java 1530-1580

Error Handling

Error Scenario ERP Response MES Handling
Report already confirmed code=500, Report confirmed Display error message, requires manual handling
Report does not exist code=500, Report not found Clear MES report number, continue cancel flow
Connection timeout SocketTimeoutException Log error, requires manual supplementary cancel

LOG Record

// Log file: logs/ERPReturnErrorRec.log

[ERP_SEND_ERROR] taskName=cancelProductionForm, errorType=SocketTimeoutException, errorMsg=Read timed out
[ERP_SEND_ERROR] Content sent={"report_no":"10-20260319001"}

Race Condition Risk

Important Notice
Like the create production report API, cancel production report also has Race Condition risk:

Scenario: Cancel immediately after check-out, but ERP has not yet returned report number
Result: PRODUCTION_REPORTID is empty, cannot call ERP cancel
Consequence: MES has cancelled check-out, but ERP production report still exists

Recommended Solutions:
  1. Wait for ERP return success before allowing cancel after check-out
  2. Periodically compare MES and ERP production report status
  3. Provide manual supplementary cancel function