# `Sp_Sales_PurchaseAnalysiseOfMaterialClass` (procedure) > 现金日记帐 - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `tStartDate` | `datetime` | | 2 | IN | `tEndDate` | `datetime` | | 3 | IN | `sBrId` | `varchar(100)` | | 4 | IN | `sSuId` | `varchar(100)` | | 5 | IN | `sLoginId` | `varchar(100)` | | 6 | IN | `bFilter` | `varchar(5000)` | | 7 | IN | `pageNum` | `int` | | 8 | IN | `pageSize` | `int` | | 9 | OUT | `totalCount` | `int` | | 10 | IN | `countCloumn` | `varchar(5000)` | | 11 | OUT | `countMapJson` | `longtext` | | 12 | IN | `sFilterOrderBy` | `varchar(5000)` | | 13 | IN | `sGroupby_select_sql` | `varchar(5000)` | | 14 | IN | `sGroupby_group_sql` | `varchar(5000)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Sales_PurchaseAnalysiseOfMaterialClass`'`._ ## Narrative **Business context:** 采购管理 → 采购分析报表 → 采购分析-按物料分类 — paged report that aggregates purchase qty, money and payment status by material class across the period. Rolls the by-material view up to the class level for procurement. **What it does:** Builds temp `SAS`/`tempSAS`, `INSERT INTO SAS` from `viw_purpurchaseorder` joined against `elematerials`, `sismaterialsclassify` and `viw_cahpayment`. `UPDATE SAS` folds in extra aggregates. Final paging via `CALL Sp_Outstanding_Query` with `pageNum/pageSize` and `countMapJson` from `countCloumn`; `bFilter`/`sFilterOrderBy`/`sGroupby_*` are spliced into the dynamic SQL. **Invocation:** Bound to `gdsconfigformmaster.sSqlStr` on form `101251240115015848408987391` (采购分析-按物料分类) under 采购分析报表 → 采购管理. Install scripts at `script/标版/30100101/`, optimised variant at `script/标版/20210323/optimizeprocedure.sql`, customer override at `script/客户/福雅/Sp_Sales_PurchaseAnalysiseOfMaterialClass.sql`. Note: the page's heading `现金日记帐` is a stale `gdsmodule.sChinese` artefact — the live business identity is 采购分析-按物料分类.