# `Sp_Calc_sOrderBgd` (procedure) > 订单变更单 - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `iFlag` | `int` | | 2 | IN | `iTmpCheck` | `int` | | 3 | IN | `sFormGuid` | `varchar(100)` | | 4 | IN | `sGuid` | `varchar(100)` | | 5 | IN | `sLoginId` | `varchar(100)` | | 6 | OUT | `sReturn` | `varchar(5000)` | | 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_Calc_sOrderBgd`'`._ ## Narrative **Business context:** Two-bind audit for 订单变更单据 — sales-order change request. The 订单变更单 is the formal record of an in-flight 销售订单 amendment (qty / price / spec / due-date change); on approval it back-writes the change into `salsalesordermaster` so downstream production / planning sees the new terms. Also serves the 模具管理 → 6.内部版材管理 → 版材内部加工单 module (sibling form reusing the same change-doc pattern). **What it does:** Standard `Sp_Calc_*` validate-and-flip — guards `sGuid`/`bInvalid`/`bCheck`, then `Update`s `salsalesorderchangemaster` to set `bCheck=1, sStatus=1, sCheckPerson, tCheckDate=NOW()`, and `UPDATE salsalesordermaster` to apply the changed fields back onto the parent sales-order. `iFlag=0` reverses the flags. **Invocation:** Bound to `gdsmodule.sProcName` on: - `订单变更单据` (sId `101251240115016233151134120`) — 销售管理 → 销售单据 - `版材内部加工单` (sId `101251240115016284068261640`) — 模具管理 → 6.内部版材管理 Dispatched by `BusinessBaseServiceImpl.getPrcName(sFormGuid, …)` on the audit/un-audit button. Install scripts ship at `script/标版/30100101/Sp_Calc_sOrderBgd.sql` and `script/标版/optimize/Sp_Calc_sOrderBgd.sql`.