# `Sp_beforeSave_sTLPmd` (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_sTLPmd`'`._

## Narrative

**Business context:** 生产退料 (Production material return) — would-be before-save dispatcher for the production-return document, intended to backwrite returned-material quantity (`dAuxiliaryQty` / `dMaterialsQty`) onto the upstream `mitproductionapplySlave` (production-apply) rows. Header comment: `生产退料存前反写数量`.

**What it does:** Normalises `sGuid` to a quoted-CSV form and calls `Sp_saveReturn_sTLPmd(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)`. The historical inline `Update mitproductionapplySlave` block joining `MitProductionMaterialsSlave` / `…Master` remains commented-out in the body.

**Invocation:** Status: appears orphaned. No caller in any channel — no `gdsmodule` hook, no form-master reference, no entry in the backwriting dispatchers, no xly-src hit. The actively-wired 生产退料 path runs through `Sp_beforeSave_sPmd` instead (called by `Sp_delete_backwriting` on form `192116810113315226622476570` 生产退料). The `_sTLPmd` naming suggests an earlier variant superseded by `_sPmd`. Candidate for maintainer audit.

Flag: target `Sp_saveReturn_sTLPmd` does not exist in this DB — call would error if ever invoked.
