# `Sp_Check_sSmoa` (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_sSmoa`'`._

## Narrative

**Business context:** 半成品出库申请 (semi-goods outbound application) post-save validator on `sgdsemigoodsoutstoreapplymaster`/`sgdsemigoodsoutstoreapplyslave`. Mirror of `Sp_Check_sSmia`: caps the outbound-apply qty per `sSrcSlaveId` by the work-order's per-process plan (`mftworkorderprocess.dProcessQty`).

**What it does:** Iterates a cursor over the apply slave rows. For each row with non-empty `sSrcSlaveId`, joins `mftworkorderprocess` and sums the existing applied `dProcessQty` against the work-order's `dProcessQty`; over-quantity produces `sSmiaQtyUpWorkOrderQty` ("申请数量已超过工单数量") combined with the product name and either `sProductInHalfOutStore` (single bill) or `sProductInHalfOutStoreNo` (multiple bills) localizers. Aborts with `sCode=-1` if `sReturn` non-empty, otherwise chains `Sp_afterSave_sSmoa`.

**Invocation:** Status: appears orphaned. No `gdsmodule.sSaveProName` hook, no `gdsconfigformmaster` binding, no other-routine caller. Family siblings `Sp_afterSave_sSmoa`, `Sp_Calc_sSmoa` exist (no `Sp_beforeSave_sSmoa`). Candidate for maintainer audit on which deployments wire the 半成品出库申请 module to this validator.
