# `Sp_beforeSaveReturn_sSmia` (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_sSmia`'`._

## Narrative

**Business context:** 仓库管理 / 半成品入库申请 — parallel-fork variant of the half-finished-goods inbound-application save-hook. Comment header: `半成品入库申请存前反写数量`. The active chain is `Sp_beforeSave_sSmia` → `Sp_saveReturn_sSmia`; this `*Return` proc carries an independent writeback path against `sgdsemigoodsinstoreapplyslave` and upstream order/work-order tables.

**What it does:** Resolves `sGuid` CSV into `p_t_sId`, joins `sgdsemigoodsinstoreapplyslave` ↔ master, builds `p_MftworkOrderSlave_tmp` of applied quantities, then in `iTag=1/2` branches updates `mftworkorderprocess`, `salsalesorderslave`, `developorderslave` and the application slave itself so downstream demand counters reflect the inbound application.

**Invocation:** Status: appears orphaned. No caller found in any channel — `Sp_beforeSave_sSmia` calls `Sp_saveReturn_sSmia`, not this proc. Candidate for maintainer audit.
