# `Sp_saveReturn_sOsa` (procedure)

> 采购到货反写报价数量


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 物料采购流程 / 发外加工流程 — "采购到货反写报价数量". Back-writes the offered qty when an arrival document (采购到货 or 成品调拨) is saved, so the upstream 工序发外 / 采购报价 row reflects the in-flight qty.

**What it does:** Splits `sGuid` into `p_t_sId`, collects matching `sSrcSlaveId` into `p_sSrcSlaveId_tmp`, sums offered qty/amount (with `iTag=1` zeroing the in-flight batch) into `p_data_tmp`, then issues `update opsoutsideprocessslave` rows whose `sId = sSrcSlaveId`.

**Invocation:** Called by `Sp_beforeSave_sOsa` (`iTag=1`) and `Sp_afterSave_sOsa` (`iTag=2`); also called by `Sp_afterSave_sPaj` (`iTag=2`) — the 成品调拨 post-save wrapper re-uses this routine to back-write the offered qty onto the same 发外 slave (i.e. 成品调拨 reuses the procurement-offer back-write logic). The save-side `gdsmodule.sSaveProNameBefore` row for the 采购到货/成品调拨 forms was not present in this DB snapshot — likely a tenant-form configuration. No xly-src callers.
