Sp_AL_SHDCheckSave (procedure)
业务单据保存校验
- Type: PROCEDURE
- Deterministic: NO
- SQL data access: CONTAINS SQL
Parameters
| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | sFormGuid |
varchar(100) |
| 2 | IN | sGuid |
varchar(100) |
| 3 | IN | sTableName |
varchar(100) |
| 4 | IN | sLoginId |
varchar(100) |
| 5 | OUT | sReturn |
varchar(4000) |
| 6 | IN | sBrId |
varchar(100) |
| 7 | IN | sSuId |
varchar(100) |
| 8 | OUT | sCode |
int |
Body
Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURESpAL_SHDCheckSave'._
Narrative
Business context: 送货单 (Delivery) save-time validation + qty redistribution for saldelivergoodsslavechildren (the batch-level child of 送货单 slave) — header says 业务单据保存校验. The AL prefix and SHD token mark this as a customer-specific helper rather than a standard Sp_Check_s<Code> proc.
What it does: Rejects the save with localized code -1 if any product/batch combination (sProductId,sDefineNo,sDefineNo2) appears more than once under the same master. Then for each sProductId under sGuid it sums the dProductQty + dGiveQty on saldelivergoodsslave, walks saldelivergoodsslavechildren rows in iOrder sequence using MySQL session variables (@dQty/@dCheckQty/@sProduct) to compute running totals, and rewrites dProductQty/dUseQty so the children sum exactly matches the slave-line qty (truncates the last child when the running total would exceed). Finally deletes any child rows whose final dUseQty<=0.
Invocation: Status: appears orphaned. No gdsmodule.sSaveProName/sSaveProNameBefore/sDeleteProName slot in this database references it, no gdsconfigformmaster.sSqlStr embeds it, no other routine calls it, and grep finds zero call sites in xly-src. Candidate for maintainer audit.