# `Sp_beforeSave_sOis` (procedure)

> 工序发外确认前反写数量


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `varchar(2000)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | OUT | `sCode` | `int` |
| 5 | OUT | `sReturn` | `varchar(4000)` |

## Body

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

## Narrative

**Business context:** KPI流程操作菜单 / 发外加工流程 / 工序发外确认 (also 现场 / 发外报工(mobile单据), 发外加工流程 / 工序发外确认单据) — before-save delegator for the process-outsourcing-confirmation document. Wraps `sGuid` and forwards to `Sp_saveReturn_sOis` to backwrite confirmed quantities onto the upstream `工序发外` (process outsourcing) documents before the master save commits. Comment header: `工序发外确认前反写数量`.

**What it does:** Normalises `sGuid` to a quoted-CSV form, then `CALL Sp_saveReturn_sOis(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)`.

**Invocation:** Hooked as `gdsmodule.sSaveProNameBefore` on 3 modules — `工序发外确认` (sId `192116810113315234275562360`), `发外报工(mobile单据)` (`101251240115015952158106410`), `工序发外确认单据` (`101251240115016182844497490`). Also called by dispatcher procs `Sp_Invalid_backwriting` and `Sp_delete_backwriting` to replay the writeback on invalidate/delete. Install script: `xly-src/script/标版/30100101/Sp_beforeSave_sOis.sql`.
