# `Sp_System_MaterialsAllSure` (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(4000)` |
| 6 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 成本核算 / 期间材料价格批量确认 — confirms the 材料分摊价格 across all 期间 (accounting periods) selected on the 月度成本 grid, locking the materials-cost layer so subsequent 成本核算 stages can proceed. Same guardrail as `Sp_System_MaterialsAllReSure`: refuses to (re-)confirm while `accordercostanalysis iType=1` 直接材料 or `accproductionmaterialsslave` already has `bConfirm=1` rows.

**What it does:** Validates `sProInParam` ≥ 13 chars, `JSON_EXTRACT($.params)`, and counts matching `sysaccountperiod` ids. Refuses if 0 (`selectedRowKeysNo`) or if input is malformed (`paramsErro`). For each period iterates `$.params[*].value[*].sId`, looks up `sPeriodId/bCalMaterials`, blocks when downstream cost data already confirmed, otherwise flips `sysaccountperiod.bCalMaterials=1` for the period and propagates `bConfirm=1` / `sConfirmMonth=<period>` across the materials-cost ledger family (`accmaterialsstore`, `mitmaterialsstoreadjustmoneymaster/slave`, etc.).

**Invocation:** Status: appears orphaned at the procedure-call level (no proc-to-proc, form-master, gdsmodule, or xly-src caller beyond the install script `script/标版/30100101/cost/Sp_System_MaterialsAllSure.sql`). Signature matches the `Sp_BtnEvent_*` shape — `(sProInParam JSON, sMakePerson, sBrId, sSuId, sReturn, sCode)` — so almost certainly dispatched by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` from a 批量确认 button on the 月度成本 grid. Pair with `Sp_System_MaterialsAllReSure` (反确认) and `Sp_System_ProductionCostAllSure` (生产成本批量确认).
