# `Sp_Check_sSmo` (procedure)

> 半成品出库保存之前数据校验


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sTableName` | `varchar(100)` |
| 2 | IN | `sGuid` | `varchar(100)` |
| 3 | IN | `sFormGuid` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | IN | `iFlag` | `int` |
| 8 | OUT | `sCode` | `int` |
| 9 | OUT | `sReturn` | `varchar(4000)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Check_sSmo`'`._

## Narrative

**Business context:** 半成品出库 (semi-goods outbound) post-save validator on `sgdsemigoodsoutstoremaster`/`sgdsemigoodsoutstoreslave`. Mirror of `Sp_Check_sSmi`: enforces 红冲 netting against the source bill, then caps the outbound qty per `sSrcSlaveId` by the upstream 半成品出库申请 (`sgdsemigoodsoutstoreapplyslave.dProcessQty`).

**What it does:** Reads `sMinusSrcId`; if set, sums all linked reversal-slave `dProcessQty` and aborts with `sCcprkHaveRedData` ("已存在红冲数据，不允许重复提交") on non-zero net. Opens a cursor over slave rows; for each `sSrcSlaveId` joins `sgdsemigoodsoutstoreapplyslave` and accumulates the over-quantity with bill numbers, emits `sProductInBcpOut`/`sProductInBcpOutNo` plus `sQuantityShippedExceed` ("出库数量已超过申请数量") on overage. Aborts with `sCode=-1` if `sReturn` non-empty, otherwise chains `Sp_afterSave_sSmo`.

**Invocation:** Status: appears orphaned. No `gdsmodule.sSaveProName` hook, no `gdsconfigformmaster` binding, no other-routine caller. Family siblings `Sp_beforeSave_sSmo`, `Sp_afterSave_sSmo`, `Sp_Calc_sSmo` all exist (full family registered) and xly-src ships `script/标版/30100101/Sp_Check_sSmo.sql` as the install body. Candidate for maintainer audit on whether any tenant still uses the 半成品出库 module.
