# `Sp_Calc_sSmi` (procedure) > 半成品入库 - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `iFlag` | `int` | | 2 | IN | `iTmpCheck` | `int` | | 3 | IN | `sFormGuid` | `varchar(100)` | | 4 | IN | `sGuid` | `varchar(100)` | | 5 | IN | `sLoginId` | `varchar(100)` | | 6 | OUT | `sReturn` | `varchar(4000)` | | 7 | IN | `sBrId` | `varchar(100)` | | 8 | IN | `sSuId` | `varchar(100)` | | 9 | OUT | `sCode` | `int` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Calc_sSmi`'`._ ## Narrative **Business context:** 半成品入库 (semi-goods inbound — `sgdsemigoodsinstoremaster`) audit / un-audit. Auditing the inbound bill writes the semi-goods qty into stock, posts the movement row and back-writes the originating 入库申请 with the received qty. **What it does:** Validates `sGuid`/`bInvalid` and `SysLocking`, then on `iFlag=1` sets `bCheck=1`, `sCheckPerson`, `tCheckDate` on `sgdsemigoodsinstoremaster`; iterates `sgdsemigoodsinstoreslave`, calls `SP_Inventory_SemgoodsInOutWareHouse` (`+1` direction) per row to write `INSERT INTO sgdSemigoodsStore` and `UPDATE elesemigoodsstock` for the on-hand; writes back `UPDATE sgdsemigoodsinstoreapplyslave` to mark the apply line as received. `iFlag=0` reverses every step. **Invocation:** Status: appears orphaned. No `gdsmodule.sProcName` binding, no form-master `sSqlStr` ref, no other-routine caller, no live xly-src Java caller — only the install scripts in `script/标版/30100101/` and the optimize patch at `script/标版/optimize/Sp_Calc_sSmi.sql`. The 半成品入库 form is currently wired up under a different proc; candidate for maintainer audit.