# `Sp_Check_sPrj` (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_sPrj`'`._ ## Narrative **Business context:** 采购管理 → 物料采购流程 → 采购退货 — post-save validator on `purpurchaserejectmaster`/`purpurchaserejectslave`. Guards two invariants: 反算 (reverse-formula) materials must have a 采购数量, and once a 红冲 (reverse-charge) record exists for the source bill, no further duplicate 红冲 is allowed. **What it does:** Sets `sCode=1`, `iFlag=0`, clears `sReturn`. (1) Counts `purpurchaserejectslave` rows with `iHandIn=1` whose `elematerials.bInverse=0` — if any, aborts with `sCode=-8` and `sMaterialNotFsgs` ("物料不是反算公式物料,请输入采购数量进行计算") concatenated with the offending material names. (2) Reads `sMinusSrcId` from the master; if set, counts mis-matched 红冲 rows by comparing the original slave's `dAuxiliaryQty` against the sum of `dAuxiliaryQty` on matching `sMinusSrcSlaveId` rows — if any imbalance, aborts with `sCcprkHaveRedData` ("已存在红冲数据,不允许重复提交"). Finally calls `Sp_afterSave_sPrj`. **Invocation:** Bound to `gdsmodule.sSaveProName` on `2/4 新增采购退货` (`192116810113315221425660510`) — 采购管理 → 物料采购流程 (KPI流程操作菜单). Dispatched by `BusinessBaseServiceImpl.checkUpdate(..., "sSaveProName")` after the save batch commits. Pre-save peer is `Sp_beforeSave_sPrj`. xly-src ships `script/标版/30100101/Sp_Check_sPrj.sql` as the install body.