# `Sp_beforeSave_sPst` (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_sPst`'`._

## Narrative

**Business context:** 销售送货流程 / 成品入库 — before-save dispatcher for the finished-goods receipt document. Wraps `sGuid` and delegates to `Sp_saveReturn_sPst` to backwrite received finished-goods quantities onto upstream work-orders, quality-test masters, and the picking/packing chain before the master save commits.

**What it does:** Normalises `sGuid` to a quoted-CSV form, then `CALL Sp_saveReturn_sPst(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)`. The body retains 7K chars of commented-out legacy fallback SQL (direct multi-statement updates against `qlyproducttestmaster`, `MftWorkOrderSlave`, etc.) that the active path now delegates to the saveReturn sibling.

**Invocation:** Hooked as `gdsmodule.sSaveProNameBefore` on `成品入库` (sId `192116810113315228246447250`). Also called by dispatcher procs `Sp_Invalid_backwriting` and `Sp_delete_backwriting`.
