# `Sp_afterSave_sSmi` (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_afterSave_sSmi`'`._

## Narrative

**Business context:** 半成品入库申请 (`sgdsemigoodsinstoreapplyslave` → `sgdsemigoodsinstoreslave`) — header says 半成品入库存前反写数量 (label says "before-save" but routine is after-save iFlag=2). Thin save-phase 反写 wrapper in the `Sp_afterSave_s<Code>` family that delegates the actual qty back-write to `Sp_saveReturn_sSmi`.

**What it does:** Wraps `sGuid` in double-quotes if not already quoted and unconditionally calls `Sp_saveReturn_sSmi(sGuid, sBrId, sSuId, 2, @sCode, @sReturn)` (iFlag=2 = "after save" phase). The body carries a large commented-out dynamic-SQL block that would once have updated `sgdsemigoodsinstoreapplyslave.dProcessInStoreQty` from `sgdsemigoodsinstoreslave.dProcessQty` totals — inert. Does not propagate the inner `@sCode`/`@sReturn` back to its own OUT params.

**Invocation:** Reached only via dispatch. `Sp_Check_sSmi` and `Sp_Check_sSmia` both call this proc, but neither has a live `gdsmodule.sSaveProName` binding. The live path is `Sp_Invalid_backwriting`, which dispatches to this proc on 作废/取消作废 of form `101801153119616759291255520` (半成品入库申请), itself triggered from Java `CheckmodelServiceImpl` via `Sp_Invalidation`.
