# `Fun_GetMachineLenWidthAPS` (function) - **Type:** FUNCTION - **Returns:** `int` - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sMachineLength` | `int` | | 2 | IN | `sMachineWidth` | `int` | | 3 | IN | `dMaxLength` | `int` | | 4 | IN | `dMaxWidth` | `int` | | 5 | IN | `dMinLength` | `int` | | 6 | IN | `dMinWidth` | `int` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `Fun_GetMachineLenWidthAPS`'`._ ## Narrative **Business context:** APS (advanced planning) machine-eligibility check — given a sheet's `sMachineLength`/`sMachineWidth` and a candidate machine's `(dMin..dMax) × (dMin..dMax)` window, returns `1` when the sheet falls outside the window (i.e. the machine is unsuitable), else `0`. **What it does:** Sorts length ≥ width, then flags out-of-range against the four limits in either orientation. **Invocation:** Called by `Sp_GetMachineByApsRule` — the procedure that ranks/filters machines when auto-assigning a work order to a press, comparing the order's sheet size against each machine's configured min/max. Parameterised replacement for the now-orphan `Fun_GetMachineLenWidth`.