# `Sp_Check_sAcc` (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_sAcc`'`._ ## Narrative **Business context:** 品质管理 → 质量事故报告 / 客户投诉单 / 设备异常单 — post-save validator on `mftqualityaccidentmaster`. Enforces the business rules around 不良品处理方式 (rework/scrap/return-to-外协): bad-product flag must pair with scrap qty, 外协商扣款 must pair with 部门, 退加工商 must select supplier, etc. Same proc serves three forms that share the underlying table. **What it does:** Branches on `sFormGuid` (`11811781131121915261093794470` = 新增质量事故报告; `101251240115016045682733390` = 设备异常单; `101251240115016180439686010` = 新增客户投诉单). For each, runs a battery of `SELECT COUNT(1) INTO p_iCount` consistency checks (bad-flag/reprint mismatch, missing scrap/rework qty, missing department on 外协商扣款, missing supplier on 退加工商) and aborts with the localised `Fun_Sis_GetConstNew` message (`sDealNeedScrap`, `sDealNeedScrapQty`, `sWxUpZeroNeedWxskk`, `sBlDealNeedWxs`, etc.). Also normalises cost-split fields against `mftqualityaccidentslave` totals before returning. **Invocation:** Bound to `gdsmodule.sSaveProName` (post-save) on `质量事故报告` (`101251240115015934849804300`), `设备异常单` (`101251240115016045682733390`), `01/01 新增质量事故报告` (`11811781131121915261093794470`), `01/02 新增客户投诉单` (`101251240115016180439686010`) — all four roll up under 品质管理. Dispatched by `BusinessBaseServiceImpl.checkUpdate(..., "sSaveProName")` after the save batch commits. Pre-save peer is `Sp_beforeSave_sAcc`; xly-src ships `script/标版/30100101/Sp_Check_sAcc.sql` as the install body.