# `Sp_beforeSave_sScr` (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_sScr`'`._

## Narrative

**Business context:** 10.物流单据 / 派车单单据 — before-save dispatcher for the dispatch-car (vehicle-dispatch) document. Wraps `sGuid` and delegates to `Sp_saveReturn_sScr` to backwrite dispatched quantities onto upstream delivery-note slaves before the master save commits.

**What it does:** Normalises `sGuid` to a quoted-CSV form, then `CALL Sp_saveReturn_sScr(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)` (always — no `IF sGuid IS NOT EMPTY` guard). The body retains ~2K chars of commented-out legacy fallback SQL that aggregated `salsendcarslave.dProductQty` into `saldelivergoodsslave.dSendCarQty` directly — superseded by the saveReturn sibling.

**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 = '15839936170002427227633635401000'` (派车单单据). The save-time before-save hook is presumably configured at the form-master / customer-override layer rather than on a gdsmodule node.
