# `Sp_beforeSave_sPod` (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_sPod`'`._

## Narrative

**Business context:** 物料采购流程 / 采购订单 — before-save dispatcher for the purchase-order document. Wraps `sGuid` and delegates to `Sp_saveReturn_sPod` to backwrite ordered quantities onto upstream purchase-request / material-plan documents before the master save commits.

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

**Invocation:** Hooked as `gdsmodule.sSaveProNameBefore` on `采购订单` (sId `192116810113315217757747140`). Also called by dispatcher procs `Sp_Invalid_backwriting` and `Sp_delete_backwriting` to replay the writeback on invalidate/delete.
