# `Sp_Save_CheckSaveAfter` (procedure)

> 保存校验单据


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 系统 → 保存校验单据 — central POST-save validator that the framework calls after a row is committed but before the user sees "saved". Branches on `sTableName` and `sFormGuid` to run business-rule guards across most of the ERP — basic data (`elecustomer`, `eleemployee`, `eleKnifemould`, `elematerialsyearmaster`, `eleproductpricemaster`, `elesupply`, `mftproductmaster`), sales (`salsalesordermaster`, `SalSalesInvoiceMaster`, `salsalesorderbecomemaster`, `saldelivergoodsdedmaster`, `saldelivergoodsdedinmaster`), production / outsource (`mftoutprocessmaster`, `mftprocesschangemaster`, `mftmaterialstest`, `mitproductionapplymaster`, `mitproductionmaterialsmaster`, `mftproductionplanbillslave`, `pitproductcheckmaster`), purchasing (`purpurchaseinstorededmaster`, `opsoutsideinstorededmaster`), and file management (`filfilemanagemaster`).

**What it does:** For each branch, runs a `SELECT COUNT` / `EXISTS` style check on the slave or related tables, and on violation emits a localised error from `Fun_Sis_GetConst` / `Sp_Sis_GetConst` (e.g. `sGykkNagativeNum` "扣款单单价请填写负数!", `sCheckSaveAfterRemarkEmpty`, `sCheckSaveAfterProductCantInsert`, `sCheckSaveAfterChooseDbType`, `sCheckSaveAfterMaterialCg`, `sCheckSaveAfterZyzrMoneyNoSameZr`, `sCheckSaveAfterOrderTypeZlsgNeedNo`, ...) and aborts with `sCode=-1` via the labelled `top:` block. On all-pass falls through with no message.

**Invocation:** Signature matches the save-validator hook contract. Dispatched by Java `BusinessBaseServiceImpl` against `gdsmodule.sSaveProName` for every form whose `sFormGuid` the proc explicitly branches on (the form ids enumerated inside the body). No other-routine caller; no install script ships in `xly-src/script/` under the standard tree — this proc is DB-resident. Effectively the catch-all "everything-else" save validator for the ERP modules that don't have a dedicated `Sp_Check_s<Code>`.
