# `Sp_Manufacture_InsertMftPlanToErp` (procedure) > @author:钱豹 @date:20210711 封存 @describe: 发外工序,返回重排过程中调用:插入计划(工单审核,重新投入规划调用),主要功能: 1、根据工序中设定的 拆单方式 按贴,按付... 插入到机台计划表中 2、根据工单工序从表ID汇总数量 反写工单工序的已排程数 - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sWorkOrderProcessGuid` | `varchar(255)` | | 2 | IN | `bCheck` | `int` | | 3 | IN | `sLoginId` | `varchar(100)` | | 4 | IN | `sErpMachineGuid` | `varchar(100)` | | 5 | IN | `p_sState` | `int` | | 6 | IN | `sBrId` | `varchar(100)` | | 7 | IN | `sSuId` | `varchar(100)` | | 8 | OUT | `sCode` | `int` | | 9 | OUT | `sReturn` | `varchar(500)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Manufacture_InsertMftPlanToErp`'`._ ## Narrative **Business context:** 生产管理 → 生产计划管理 — ERP-side variant of `Sp_Manufacture_InsertMftPlanProcess`. Pushes a work-order-process row into ERP-tracked `mftproductionplanmaster` with the chosen ERP machine (`sErpMachineGuid`) and state (`p_sState`). Per the COMMENT, owned by 钱豹, 封存 20210711, "发外工序,返回重排过程中调用". **What it does:** For the given `sWorkOrderProcessGuid`, `CALL Sp_Sis_GetMaxNo` to mint a plan bill number, builds the master-row column-list dynamically, and `INSERT INTO mftproductionplanmaster` with the resolved 拆单方式 split (按贴/按付/...). Writes back the scheduled qty to the work-order process row. **Invocation:** Chained from `Sp_PLC_ScanInsertToERP` (the PLC scan → ERP push flow) — invoked when PLC-side data needs a corresponding ERP-side plan-master row. No form-master or `gdsmodule` hook binding. Install: xly-src `script/标版/30100101/schedule/Sp_Manufacture_InsertMftPlanToErp.sql`.