# `Sp_afterSave_sPtr` (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_afterSave_sPtr`'`._

## Narrative

**Business context:** 成品领用单据 → 出库管理 → 成品库存 — header says 报废单保存后反写数量 (label refers to the earlier 报废 use of the form; current bind is 成品领用). Thin save-phase 反写 wrapper in the `Sp_afterSave_s<Code>` family that delegates the actual qty back-write to `Sp_saveReturn_sPtr`.

**What it does:** Declares unused locals `p_sMasterSql`/`sDeliverSrc`, wraps `sGuid` in double-quotes if not already quoted, then unconditionally calls `Sp_saveReturn_sPtr(sGuid, sBrId, sSuId, 2, @sCode, @sReturn)` (iFlag=2 = "after save" phase). The body carries a large commented-out dynamic-SQL block that was once a `salchildproductapplyslave` aggregator over `pitproductrejectslave` — inert. Does not propagate the inner `@sCode`/`@sReturn` back to its own OUT params.

**Invocation:** Called by `Sp_Check_sPtr` (the save-commit dispatch proc bound via `gdsmodule.sSaveProName` on 成品领用单据 `101251240115015920999005840`) near the tail of a successful save. `Sp_Invalid_backwriting` has no dispatch entry for this form.
