# `Sp_Check_sPaj` (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_sPaj`'`._

## Narrative

**Business context:** Post-save validator nominally for 成品调拨单据 (per procedure summary), targeting `pitproductadjustmaster`/`pitproductadjustslave`. Enforces the rule that 正数仓 and 余数仓 can't be mixed in one 调拨, and prevents duplicate-submit of 红冲 lines that already net to zero.

**What it does:** Counts `pitproductadjustslave` rows whose warehouse `bRemainder` does not match the master warehouse's `bRemainder` (`Where A.sParentId=sGuid AND B.bRemainder NOT IN (...)`); on hit, aborts with `sZsYsCantTransferred` (正数仓和余数仓不能进行调拨). Then, if `sMinusSrcId` is set on the master, sums the original slave qty plus all non-`bInvalid` red-impound qty for each `sMinusSrcSlaveId` and counts rows whose net is non-zero; on hit, aborts with `sCcprkHaveRedData` (已存在红冲数据，不允许重复提交).

**Invocation:** Status: appears orphaned. No `gdsmodule.sSaveProName`/`sSaveProNameBefore`/`sProcName`/`sDeleteProName` row references it; no form-master `sSqlStr` ref; no other DB routine calls it; xly-src grep finds only `script/标版/30100101/Sp_Check_sPaj.sql` (the install body). The 成品调拨 module appears to dispatch its post-save logic through a different `sSaveProName` — candidate for maintainer audit.
