# `Sp_afterSave_sWod` (procedure)

> 生产工单保存前反写数量


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `varchar(2000)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | OUT | `sCode` | `int` |
| 5 | OUT | `sReturn` | `varchar(4000)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_afterSave_sWod`'`._

## Narrative

**Business context:** 生产工单 / 2/3 新增生产补单 → 订单生产流程 → KPI流程操作菜单 — header says 生产工单保存前反写数量 (label is misleading; the proc is bound on `sDeleteProName` slot and called by `Sp_Check_sWod` as the after-save hook). Thin save-phase 反写 wrapper that delegates the actual qty back-write to `Sp_saveReturn_sWod` (the in-line `MftWorkOrderSlave` → `SalSalesOrderSlave.dWorkOrderQty/dWorkOrderStockupQty/dPresentQty/dWorkSparesQty` denorm UPDATE chain is fully commented out).

**What it does:** Wraps `sGuid` in double-quotes if not already quoted and calls `Sp_saveReturn_sWod(sGuid, sBrId, sSuId, 2, @sCode, @sReturn)` (iFlag=2 = "after save" phase). Does not propagate the inner `@sCode`/`@sReturn` back to its own OUT params.

**Invocation:** Reached on two paths. (1) `Sp_Check_sWod` (the save-commit dispatch proc bound via `gdsmodule.sSaveProName` on 生产工单 + 2/3 新增生产补单 + 轮转工单) calls this proc near the tail of a successful save; on 生产工单 and 2/3 新增生产补单 the `gdsmodule.sDeleteProName` slot also points here directly. (2) `Sp_Invalid_backwriting` dispatches to this proc on 作废/取消作废 of forms `101251240115016002469445380` (生产工单), `101251240115015840916341460` (轮转工单), `101251240115015876865630390`, `101251240115015923023677080`, `101251240115016002468935320`, `101251240115016002470020610` and others, itself triggered from Java `CheckmodelServiceImpl` via `Sp_Invalidation`.
