# `PRO_MATERIALS_SMAIL` (procedure)

> 两变都小于305的材料（单位CM）


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `dQty` | `decimal(18,6)` |
| 2 | IN | `dWidth` | `decimal(18,6)` |
| 3 | IN | `dLength` | `decimal(18,6)` |
| 4 | OUT | `dQtyXy` | `decimal(18,6)` |

## Body

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

## Narrative

**Business context:** Materials — 305cm sheet-packing estimator (header: "两变都小于305的材料（单位CM）" = "materials whose both dimensions are under 305cm"). Procedure form of the orphan function `FUN_MATERIALS_SMAIL` (session 8 flagged) — given a requested quantity, sheet width and sheet length (all in cm), returns the number of master sheets needed assuming a 305cm raw sheet, by simulating greedy lay-down of pieces.

**What it does:** swaps width/length so width≤length, accounts for any whole-master pieces when either dimension exceeds 305, then runs a `WHILE indexOrder < dQty` loop greedily fitting pieces into a 305cm strip, tracking strip count in `clsl` and accumulating leftover lengths into a JSON array. Returns the total master-sheet count `dQtyXy = p_zgs + clsl`.

**Invocation:** Status: appears orphaned. No caller found in any channel (form-master, gdsmodule hooks, other routines, xly-src grep across all extensions). The function-variant `FUN_MATERIALS_SMAIL` is similarly orphan — both appear to be experimental packing-estimator scaffolding that was never wired into a live materials-issue or order-quoting flow. Candidate for maintainer audit.
