CRTD模拟MGF工单进行绑定

Posted Snowfun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CRTD模拟MGF工单进行绑定相关的知识,希望对你有一定的参考价值。

 需求:按单按库生产的CRTD状态半成品工单重复创建问题

 

绑定成功案例:

SELECT DEMANDLINEID,SUPPLYORDERID,DEMANDORDERID,QTYALLOCATED,ITEM FROM ABPPMGR.SUPPLYDMDPEGPLAN  WHERE  ITEM=\'000000102002000817CZ\';--前台显示

--SO:5000156623 模拟创建了成品MO:5000156623/70_1-MFG001,成品MO号供给者为半成品MO:001201126508
SELECT DEMANDORDERID,DEMANDLINEID,DEMANDTYPE,ITEM,QTYINMOVE,SOURCEDATE,SUPPLYORDERID,SUPPLYTYPE,QTYALLOCATED
 FROM ABPPMGR.supplydmdpegging WHERE (DEMANDORDERID=\'5000156623\' AND DEMANDLINEID=\'70_1\') OR DEMANDORDERID=\'5000156623/70_1-MFG001\'  ;  --000000101002001849CZ   001201126508    000000102002000845CZ    
 
SELECT PRODUCTIONORDID,BOMID,ITEM,QTYORDERED,REQUIREDDATE,ROUTINGID,UDF_MO_FACTORY FROM ABPPMGR.PRODUCTIONORDERS WHERE PRODUCTIONORDID=\'5000156623/70_1-MFG001\';

SELECT * FROM IN_SFCHEADER where so_id=\'5000156623\' and so_line_id=\'70\';
SELECT * FROM ABPPMGR.MST_BOMCOMPONENTSALT where alternateitem like \'000000102002000817CZ%\' ;--alternateitem替代料,item为主料

 解决方法:

 

下面修改SAP_MO表是为了避免TECO,CLSD的工单写到IN_MO或IN_SFCHEADER表的PEGGED_MO_ID栏位中,导致supplydmdpegging表中无法将此工单与SO进行绑定

 

下面是修复当使用替料时导致CRTD绑定失败问题,原因是工艺路线数据问题导致

.

以下是因为工艺路线问题导致绑定不成功

 

 成功绑定案例2(拆分计划行)

SELECT DEMANDLINEID,SUPPLYORDERID,DEMANDORDERID,QTYALLOCATED,ITEM FROM ABPPMGR.SUPPLYDMDPEGPLAN  WHERE  ITEM=\'000000102005000397CA\';--前台显示

SELECT DEMANDORDERID,DEMANDLINEID,DEMANDTYPE,ITEM,QTYINMOVE,SOURCEDATE,SUPPLYORDERID,SUPPLYTYPE,QTYALLOCATED
 FROM ABPPMGR.supplydmdpegging WHERE ITEM=\'000000102005000397CA\'  ;  
 
SELECT PRODUCTIONORDID,BOMID,ITEM,QTYORDERED,REQUIREDDATE,ROUTINGID,UDF_MO_FACTORY FROM ABPPMGR.PRODUCTIONORDERS WHERE PRODUCTIONORDID LIKE \'5000154378/460%\';

SELECT * FROM IN_MO where so_id=\'5000154378\' and so_line_id=\'460\';

 

 

 

 

 

 

写入代码为

  --no ASS MO yet
   INSERT ALL
   WHEN SOCOUNT =1 THEN
   INTO abppmgr.SUPPLYDMDPEGGING
         ( ENTERPRISE
         , ENGINE_ID
         , DEMANDLINEID
         , DEMANDORDERID
         , DEMANDTYPE
         , ITEM
         , QTYALLOCATED
         , SITEID
         , LOCATIONID
         , SUPPLYORDERID
         , SUPPLYTYPE
         , ISDEMANDLOCKED
         , SYS_CREATED_BY
         ) 
         values( ENTERPRISE
         , ENGINE_ID
         , SO_LINE_ID
         , SO_ID
         , \'SO\'
         , PRODUCT_ITEM
         , QTYORDERED
         , SITEID
         , NULL 
         , PRODUCTIONORDID
         , \'MFG\'
         , \'1\'
         , SYS_CREATED_BY
         )
  when SOCOUNT=1 then INTO abppmgr.PRODUCTIONORDERS
         ( ENTERPRISE
         , ENGINE_ID
         , BOMID
         , ITEM
         , PLANNEDSTARTDATE
         , PRODUCTIONORDID
         , QTYORDERED
         , REQUIREDDATE
         , ROUTINGID
         , SITEID
         , SYS_CREATED_BY
         ,ISFEEDSLOCKED
         ,ISQTYLOCKED
         ,ISROUTINGLOCKED
         )
         values(ENTERPRISE
         , ENGINE_ID
         , BOMID
         , PRODUCT_ITEM
         , PLANNEDSTARTDATE
         , PRODUCTIONORDID
         , QTYORDERED
         , REQUIREDDATE
         , ROUTINGID
         , SITEID
         , SYS_CREATED_BY
         ,ISFEEDSLOCKED
         ,ISQTYLOCKED
         ,ISROUTINGLOCKED)
    when SOCOUNT is not null then
     INTO abppmgr.SUPPLYDMDPEGGING
         ( ENTERPRISE
         , ENGINE_ID
         , DEMANDLINEID
         , DEMANDORDERID
         , DEMANDTYPE
         , ITEM
         , QTYALLOCATED
         , SITEID
         , SUPPLYORDERID
         , SUPPLYTYPE
         , ISDEMANDLOCKED
         , SYS_CREATED_BY
         ) 
         values( ENTERPRISE
         , ENGINE_ID
         , NULL
         , PRODUCTIONORDID
         , \'MFG\'
         , SEMI_ITEM
         , SEMI_QTY
         , SITEID
         , SEMI_MO
         , \'MFG\'
         , \'1\'
         , SYS_CREATED_BY
         )
         SELECT ENTERPRISE
         , ENGINE_ID
         , BOMID
         , SO_ID
         , SO_LINE_ID
         , SEMI_ITEM 
         , PRODUCT_ITEM
         , PLANNEDSTARTDATE
         , PRODUCTIONORDID
         , QTYORDERED
         , SEMI_QTY
         , SEMI_MO
         , REQUIREDDATE
         , ROUTINGID
         , SITEID
         , SYS_CREATED_BY
         ,ISFEEDSLOCKED
         ,ISQTYLOCKED
         ,ISROUTINGLOCKED
         , SOCOUNT from (
   SELECT V_ENTERPRISE ENTERPRISE
        , V_ENGINEID ENGINE_ID
        , SO.SO_ID
        , SO.SO_LINE_ID
        , DECODE(TRIM(BR.BOM_ID),NULL,NULL,\'\'|| LTRIM(SO.ITEM_ID,\'0\') ||\'_\'|| TRIM(BR.BOM_ID)) BOMID
        , SO.ITEM_ID PRODUCT_ITEM
        , SYSDATE PLANNEDSTARTDATE
        , SO.SO_ID||\'/\'||SO. SO_LINE_ID||\'-\'||\'MFG001\' PRODUCTIONORDID
        , SO.ORDERED_QTY QTYORDERED
        , MO.QUANTITY SEMI_QTY
        , MO.MO_ID SEMI_MO
        , NVL(SO.UDF_PROMD,SO.UDF_CRSD) REQUIREDDATE
        , BR.ROUTING_ID ROUTINGID
        , V_SITEID SITEID
        , MO.ITEM_ID SEMI_ITEM
        , V_PRONAME||\'_\'||V_STEP SYS_CREATED_BY
        ,\'1\' ISFEEDSLOCKED
        ,\'1\' ISQTYLOCKED
        ,\'1\' ISROUTINGLOCKED,
        ROW_NUMBER() OVER(PARTITION BY MO.PEGGED_SO_ID,MO.PEGGED_SO_LINE_ID ORDER BY SO.SO_LINE_ID desc) SOCOUNT,
        ROW_NUMBER() OVER(PARTITION BY MO.PEGGED_SO_ID,MO.PEGGED_SO_LINE_ID,MO.MO_ID ORDER BY SO.SO_LINE_ID desc) RN
     FROM IN_SEMI_MO_LOCKED MO,IN_SALES_ORDER SO,IN_ITEMBOMROUTING BR WHERE
     MO.PEGGED_SO_ID=SO.SO_ID AND MO.PEGGED_SO_LINE_ID=SUBSTR(SO.SO_LINE_ID,1,INSTR(SO.SO_LINE_ID,\'_\')-1)
     AND BR.PRODUCED_ITEM_ID=SO.ITEM_ID and MO.PEGGED_MO_ID is null
     AND BR.siteid=SO.siteid
     AND EXISTS(SELECT NULL FROM IN_BOM_HEADER BH WHERE BH.BOM_ID=BR.BOM_ID AND BH.MO_BOM_MARK=\'0\')
      ) WHERE RN=1 AND EXISTS (SELECT NULL FROM ABPPMGR.MST_ITEMMASTER AM WHERE PRODUCT_ITEM = AM.ITEM) AND EXISTS (SELECT NULL FROM ABPPMGR.MST_ITEMMASTER AM WHERE SEMI_ITEM = AM.ITEM) 
      AND NOT EXISTS (SELECT NULL FROM abppmgr.SUPPLYDMDPEGGING SUP WHERE SO_ID = SUP.DEMANDORDERID AND SO_LINE_ID = SUP.DEMANDLINEID)
      ;
    COMMIT;

 

以上是关于CRTD模拟MGF工单进行绑定的主要内容,如果未能解决你的问题,请参考以下文章

设计模式责任链模式之模拟工单流转

有没有更聪明的方法将布局绑定到片段?

矩量母函数(Moment Generating Function,mgf,又称:动差生成函数)

概率论中的矩母函数(MGF)

利用微搭低代码实现工单系统

如何初始化片段中的绑定属性以使双向数据绑定工作