# `Sp_beforeSave_sPpa` (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_sPpa`'`._

## Narrative

**Business context:** 采购明细 / 采购申请单据 — before-save dispatcher for the purchase-requisition document. Wraps `sGuid` and delegates to `Sp_saveReturn_sPpa` to backwrite requested quantities onto upstream material-plan / demand documents before the master save commits.

**What it does:** Normalises `sGuid` to a quoted-CSV form, then `CALL Sp_saveReturn_sPpa(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 = '192116810113315217105813660'` (采购申请单据).
