# `Sp_beforeSaveReturn_sSmi` (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_sSmi`'`._

## Narrative

**Business context:** 仓库管理 / 半成品入库 — parallel-fork variant of the half-finished-goods inbound-receipt save-hook. Comment header: `半成品入库存前反写数量`. The active before-save chain for 半成品入库 is `Sp_beforeSave_sSmi` → `Sp_saveReturn_sSmi`; this `*Return` proc carries a separate writeback path against `sgdsemigoodsinstoreapplyslave` and the upstream `salsalesorderslave` / `developorderslave` / `mftworkorderslave`.

**What it does:** Parses CSV `sGuid` into a temp table, joins `sgdsemigoodsinstoreslave` to its source-slave IDs, then in each `iTag` branch builds `p_MftworkOrderSlave_tmp` of inbound quantities and updates the upstream half-finished-goods application/order slave rows so their `dInStoreQty`/`dRemainderQty` reflect the receipt.

**Invocation:** Status: appears orphaned. No caller found in any channel (form-master, gdsmodule hooks, other routines, xly-src grep across all extensions). Candidate for maintainer audit — superseded by `Sp_saveReturn_sSmi`.
