# `Sp_Sales_PurchaseAnalysiseOfMaterial` (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_PurchaseAnalysiseOfMaterial`'`._ ## Narrative **Business context:** 采购管理 → 采购分析报表 → 采购分析-按物料 — paged report that aggregates purchase qty, money and payment status by material across the period. Used by procurement to see which materials drive purchase spend. **What it does:** Builds temp `SAS`/`tempSAS`, `INSERT INTO SAS` from `viw_purpurchaseorder` (the standard purchase-order view) joined against `elematerials` and `viw_cahpayment` to pull payment progress per PO. `UPDATE SAS` folds in additional aggregates, then the standard `Sp_Do_UpdateByPageSizeBefore` trailer slices out `pageNum/pageSize` and computes `countMapJson` from `countCloumn`. The `bFilter`/`sFilterOrderBy`/`sGroupby_*` params are spliced into the dynamic SQL by the same trailer. **Invocation:** Bound to `gdsconfigformmaster.sSqlStr` on form `101251240115015848408620791` (采购分析-按物料) and also referenced from form `101251240115015848408987391` (采购分析-按物料分类) — both under 采购分析报表 → 采购管理. Install scripts at `script/标版/30100101/Sp_Sales_PurchaseAnalysiseOfMaterial.sql`, optimised at `script/标版/20210323/optimizeprocedure.sql`; customer override at `script/客户/福雅/`. Note: the page's heading `现金日记帐` is an artefact of the auto-catalog grabbing the wrong `gdsmodule.sChinese` row — the business identity is 采购分析-按物料 per `gdsconfigformmaster`.