# `Sp_beforeSaveReturn_sWod` (procedure)

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


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 生产管理 / 生产工单 — parallel-fork variant of the work-order save-hook that would backwrite produced quantities onto the originating sales orders. Comment header: `生产工单保存前反写数量`. The active before-save chain for 生产工单 is `Sp_beforeSave_sWod` → `Sp_saveReturn_sWod`.

**What it does:** Parses CSV `sGuid` into `p_t_sId`, joins `MftWorkOrderSlave` ↔ `mftworkordermaster` to gather source-slave IDs, builds `p_MftworkOrderSlave_tmp` of produced quantities, then in each `iTag` branch updates `salSalesOrderChild`, `SalSalesOrderSlave`, and `developorderslave` so upstream sales-order/dev-order rows reflect the work-order's progress.

**Invocation:** Status: appears orphaned. No caller found in any channel. Candidate for maintainer audit — superseded by `Sp_saveReturn_sWod`.
