# `Sp_beforeSave_sSod` (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_beforeSave_sSod`'`._

## Narrative

**Business context:** 销售订单 / 订单生产流程 — before-save dispatcher for the sales-order document family. Wraps `sGuid` and delegates to `Sp_saveReturn_sSod` to backwrite quoted quantities onto the upstream quotation (`salsaleschanceproduct`) rows before the order master save commits. Header comment: `销售订单保存前反写报价数量`.

**What it does:** Normalises `sGuid` to a quoted-CSV form, then `CALL Sp_saveReturn_sSod(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)`.

**Invocation:** Hooked as `gdsmodule.sSaveProNameBefore` on two modules — `1/3 新增轮转销售订单` (sId `101251240115015878710737470`) and `1/3 新增销售订单` (sId `101251240115016086186007360`), both under 订单生产流程 / KPI流程操作菜单. Also dispatched by `Sp_Invalid_backwriting` and `Sp_delete_backwriting` when `sFormGuid` matches any of five sales-order form IDs (including the two above plus three variants like 套装 / 合版), to replay the writeback on cancel-invalidate and on delete.
