# `Sp_elematerials_AfterUpdate` (procedure)

> 物料信息保存过程


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `varchar(2000)` |
| 2 | IN | `sData` | `longtext` |
| 3 | IN | `sAllData` | `longtext` |
| 4 | IN | `sFormGuid` | `varchar(100)` |
| 5 | IN | `sLoginId` | `varchar(100)` |
| 6 | IN | `sBrId` | `varchar(100)` |
| 7 | IN | `sSuId` | `varchar(100)` |
| 8 | OUT | `sCode` | `int` |
| 9 | OUT | `sReturn` | `varchar(4000)` |

## Body

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

## Narrative

**Business context:** 物料信息保存过程 (material-master post-save denormalizer). After an `elematerials` row is saved, this proc back-fills cost-center frames, climbs the `sismaterialsclassify` tree to set first-level (`sOneParentId/sOneParentName`) and second-level (`sTwoParentId/sTwoParentName`) classification, flags 瓦楞 materials, enforces 卷筒料 spec rules, and applies the 营销部 "客来纸张/客来辅料" rule for sales-department users.

**What it does:** JOINs `elematerials` to `sismaterialsclassify` to copy `sCostFrameId`/`sOtherCostFrameId`. Two more JOINs walk the classify tree to write `sOneParentId/sOneParentName` and `sTwoParentId/sTwoParentName`. Sets `bCorrugate=1` for `iAssort=1`, `iTestType=3` for a hard-coded classify branch. Counts `elematerialssafe` rows on the same material with `bReel=1` and non-empty `sLength1`; aborts with `sJtMaterialOnlyInputWidth` if found. Looks up the editor's `sDepartId` from `eleemployee`; for four hard-coded marketing departments, restricts allowed classifications to two IDs (`17125801620004896591379538541000`, `17126288040001483670552713122300`), aborting with `sMaterialOnlyChooseKlzzfl`, otherwise sets `bComMaterials=1`. Finally `CALL Sp_elematerials_AfterUpdateCard(sGuid)` to recompute corrugated-board guide price.

**Invocation:** Status: appears orphaned via the standard hook channels — not bound to any `gdsmodule.sSaveProName`/`sProcName`/`sSaveProNameBefore`, no form-master `sSqlStr` references it, and `grep -rln Sp_elematerials_AfterUpdate` across xly-src returns nothing. Only DB callers are intra-test (`sp_cursor_CardEdit`, `sp_cursor_test`). The matching `_AfterUpdate` naming convention strongly suggests it was intended as a customer-override save hook for the 物料信息 form (likely a 客户/见坑纸板 tenant). Candidate for maintainer audit to confirm whether a tenant override slot is supposed to point at this name.
