# `Sp_purchase_BtnEventReturn` (procedure)

> 无需采购返回


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `varchar(10000)` |
| 2 | IN | `sMakePerson` | `varchar(100)` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | OUT | `sReturn` | `varchar(1000)` |
| 6 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 制造 / 工单物料 → 无需采购 (no-need-to-purchase) — cancel the "no purchase required" flag on a 工单材料 line (`mftworkordermaterials`). Operators use this when a line was wrongly marked as not requiring purchase and needs to flow back into the purchase-application queue.

**What it does:** Parses `$.params[*].value[*].sSlaveId` from `sProInParam`. Validates that the line exists (`sPurchaseDataNeedPur` error if `bPurchaseComplete='0'` — i.e. the line still needs purchasing, so there's nothing to cancel). On success: `UPDATE mftworkordermaterials SET bComMaterials=0, bPurchaseComplete=0, bPurchaseApplyComplete=0` per row, then writes an audit row to `syslog` with `sLog='撤销无需发外（无需采购明细）'` and `sFormId='101251240115016110217762400'` (the 工单材料 form). Localised error messages come from `Fun_Sis_GetConst` / `Sp_Sis_GetConst`.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` (POST `/procedureCall/doGenericProcedureCall`) — bound to a "撤销无需采购" / "无需采购返回" button on the 工单材料 grid (form `101251240115016110217762400`). Install script ships at `script/标版/30100101/schedule/Sp_purchase_BtnEventReturn.sql`.
