# `Fun_GetSystemSetting` (function) - **Type:** FUNCTION - **Returns:** `varchar(100)` - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `str` | `varchar(200)` | | 2 | IN | `sBrId` | `varchar(200)` | | 3 | IN | `sSuId` | `varchar(200)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `Fun_GetSystemSetting`'`._ ## Narrative **Business context:** Core key-value reader for `SysSystemSettings` — the per-tenant system-config table that holds switches and numeric coefficients used throughout 生产 / 库存 / 销售 calculations (e.g. `CbxMaterialsUnit` = MM/CM/INCH unit choice, `NetSquareM` square-meter rounding flag, `NetConversionRate` for INCH→metric, plus hundreds of other named scalars). Every "should this branch behave one way or another?" question routes through this function. **What it does:** `SELECT sValue FROM SysSystemSettings WHERE sName=str AND sBrandsId=sBrId AND sSubsidiaryId=sSuId`, defaults to `'0'` when missing. Returns a `varchar(100)` — callers cast to numeric where they need to. **Invocation:** referenced by 37 stored routines and many xly-src `Sp_Calc_s*` / `Sp_Manufacture_*` SQL scripts. Heavy hitters include `Fun_GetAuxiliaryQtyUnit`, `Fun_GetMaterialsQtyUnit`, `Fun_GetMaterialsQtyUnitSupple`, `Fun_GetReelAuxiliaryQtyUnit`, `Fun_GetProcessAuxiliaryQty` and the entire `Sp_Calc_s*` family (s`Mma`, `Mmm`, `Mpa`, `Opi1`, `Paj`, `Pmd`, `Psa`, `Cut`, `Dgd`, `DYDgd`...) and `Sp_BillOf*` (`Apply`, `ApplyLine`, `NoPicking`, etc.). It is the canonical xly-side feature-flag/coefficient lookup.