# `Sp_MaterialAgingAnalysis_YM` (procedure)

> 材料库龄月末分析表


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sBrId` | `varchar(100)` |
| 2 | IN | `sSuId` | `varchar(100)` |
| 3 | IN | `tStartDate` | `datetime` |
| 4 | IN | `tEndDate` | `datetime` |
| 5 | IN | `sLoginId` | `varchar(100)` |
| 6 | IN | `bFilter` | `longtext` |
| 7 | IN | `pageNum` | `int` |
| 8 | IN | `pageSize` | `int` |
| 9 | OUT | `totalCount` | `int` |
| 10 | IN | `countCloumn` | `longtext` |
| 11 | OUT | `countMapJson` | `longtext` |
| 12 | IN | `sFilterOrderBy` | `longtext` |
| 13 | IN | `sGroupby_select_sql` | `longtext` |
| 14 | IN | `sGroupby_group_sql` | `longtext` |

## Body

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

## Narrative

**Business context:** 材料库存 — month-end variant (header: 材料库龄月末分析表) of `Sp_MaterialAgingAnalysis`. Same aging-bucket logic but constrained to a `tStartDate / tEndDate` month range, so finance can pull a closing-month snapshot of stuck inventory rather than the live position.

**What it does:** Same staging-table layout as the live aging proc — `P_Tmp_sFromId` for the inventory form-list, `P_Tmp_Materials_List` populated from the inventory form-bound tables filtered to the month boundary, `P_Tmp_Materials_List_Group` for the per-material aggregation with aging buckets, `P_Tmp_Materials_List_return` as the paged-output staging. The `tStartDate / tEndDate` parameters narrow the underlying-transaction window before the same `bFilter / sFilterOrderBy / sGroupby_*` paging contract is applied.

**Invocation:** No form-master binding, no gdsmodule hook, no other-routine reference, no Java caller, no xly-src install script. Status: appears orphaned. Likely the planned month-end counterpart to `Sp_MaterialAgingAnalysis` that was authored but not yet attached to a 月末报表 form-master; candidate for maintainer audit.
