# `Sp_beforeSaveReturn_sPtr` (procedure)

> 成品报废保存前反写数量


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `longtext` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | IN | `iTag` | `int` |
| 5 | OUT | `sCode` | `int` |
| 6 | OUT | `sReturn` | `longtext` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_beforeSaveReturn_sPtr`'`._

## Narrative

**Business context:** 成品报废 (Finished-goods scrap) — would-be before-save backwriter for the scrap-document family, intended to roll scrap quantity onto the originating `salchildproductapplyslave` (child-product apply) row before the master save commits. Header comment: `成品报废保存前反写数量`.

**What it does:** Materialises `sGuid` (CSV list) into temp tables `p_t_sId`, `p_sSrcSlaveId_tmp`, `p_MftworkOrderSlave_tmp3`, then runs a single `UPDATE salchildproductapplyslave` to recompute its scrap-aggregate column from the joined `MftWorkOrderSlave` chain. The 7-arg signature (`sGuid longtext, sBrId, sSuId, iTag, sCode, sReturn`) mirrors the live `Sp_saveReturn_*` family.

**Invocation:** Status: appears orphaned. No caller found in any channel (form-master, gdsmodule hooks, other routines, xly-src grep, dynamic-dispatch search). The wired-up scrap path runs through `Sp_beforeSave_sPtr` → `Sp_saveReturn_sPtr` (`Sp_delete_backwriting` calls `Sp_beforeSave_sPtr` on the 成品报废 form). This `_sPtr` variant appears to be an unused draft — candidate for maintainer audit.
