# `Sp_beforeSave_sPdt` (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_sPdt`'`._

## Narrative

**Business context:** 质量管理单据 / 成品检验单据 — before-save dispatcher for the finished-goods inspection document. Wraps `sGuid` and delegates to `Sp_saveReturn_sPdt` to backwrite inspected quantities onto the upstream work-order / quality chain before the master save commits.

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

**Invocation:** **Not** hooked on any `gdsmodule` row directly. Reached only via dispatcher procs `Sp_Invalid_backwriting` and `Sp_delete_backwriting`, which branch to this proc when `sFormGuid` is one of `15831288240001057224508428921300` (成品检验单据), `1691254111217009930478230`, or `1691254111217035911623480` (customer-override variants).
