# `Sp_beforeSave_sMad` (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_sMad`'`._

## Narrative

**Business context:** 材料调拨 — before-save delegator for the material-transfer document. Wraps `sGuid` and forwards to `Sp_saveReturn_sMad` to backwrite transferred quantities onto the upstream source documents before the master save commits. Comment header: `材料调拨保存前反写数量`.

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

**Invocation:** Status: appears orphaned. No `gdsmodule` hook references this name, no form-master sSqlStr embeds it, the standard `Sp_Invalid_backwriting` / `Sp_delete_backwriting` dispatchers do not call it, and no xly-src file references it. The companion `Sp_saveReturn_sMad` exists in the DB but is unreachable through this wrapper. Candidate for maintainer audit.
