WIP与SO关联的一种方式

   ORACLE中,除了ATO外,其他SO订单均与任务单无法关联,即使是ATO的单,在完工入库的时候仍然会切断他们之间的关联,但是实际业务过程中仍有需求算出已下SO订单的是否都有全部完工,故可以使用如下方式来客制化实现:

    

/* Formatted on 2014-9-22 17:41:45 (QP5 v5.115.810.9015) */
CREATE OR REPLACE TRIGGER CUX_WIP_DISCRETE_JOBS
   BEFORE INSERT
   ON INV.MTL_RESERVATIONS
   FOR EACH ROW
   WHEN(NEW.SUPPLY_SOURCE_TYPE_ID = 5
    AND NEW.DEMAND_SOURCE_TYPE_ID IN (2, 8))
DECLARE
   L_REQ          NUMBER;
   L_ORDER        VARCHAR2(40);
   L_LINE         VARCHAR2(40);
   H_PACKING      VARCHAR2(150);
   L_PACKING      VARCHAR2(150);
BEGIN
   BEGIN
      SELECT MSO.SEGMENT1
        INTO L_ORDER
        FROM MTL_SALES_ORDERS MSO
       WHERE MSO.SALES_ORDER_ID = :NEW.DEMAND_SOURCE_HEADER_ID;
   EXCEPTION
      WHEN NO_DATA_FOUND THEN
         RETURN;
   END;

   /*BEGIN
   SELECT SUBSTR(OOH.PACKING_INSTRUCTIONS, 1, 150)
   INTO H_PACKING
   FROM OE_ORDER_HEADERS_ALL OOH
   WHERE OOH.HEADER_ID = :NEW.DEMAND_SOURCE_HEADER_ID;
   EXCEPTION
   WHEN OTHERS THEN
   H_PACKING := '';
   END;

   BEGIN
   SELECT SUBSTR(OOL.PACKING_INSTRUCTIONS, 1, 150)
   INTO L_PACKING
   FROM OE_ORDER_LINES OOL
   WHERE OOL.LINE_ID = :NEW.DEMAND_SOURCE_LINE_ID;
   EXCEPTION
   WHEN OTHERS THEN
   L_PACKING := '';
   END;*/

   BEGIN
      SELECT TO_CHAR(OOL.LINE_NUMBER)
        INTO L_LINE
        FROM OE_ORDER_LINES OOL
       WHERE OOL.LINE_ID = :NEW.DEMAND_SOURCE_LINE_ID;
   EXCEPTION
      WHEN NO_DATA_FOUND THEN
         RETURN;
   END;

   BEGIN
      SELECT WRV.REQUEST_ID
        INTO L_REQ
        FROM WIP_DISCRETE_JOBS WRV
       WHERE WRV.ORGANIZATION_ID = 104
         AND WRV.WIP_ENTITY_ID = :NEW.SUPPLY_SOURCE_HEADER_ID
         AND WRV.SOURCE_CODE = 'WICDOL';
   EXCEPTION
      WHEN NO_DATA_FOUND THEN
         RETURN;
   END;

   UPDATE WIP_DISCRETE_JOBS WJ
      SET WJ.ATTRIBUTE3 = L_ORDER || '.' || L_LINE, WJ.SOURCE_CODE = ''
    --WJ.ATTRIBUTE12 = L_PACKING,
    -- WJ.ATTRIBUTE11 = H_PACKING
    /*,WJ.SCHEDULE_GROUP_ID = (SELECT WSG.SCHEDULE_GROUP_ID
    FROM WIP_SCHEDULE_GROUPS WSG,
    FND_LOOKUP_VALUES flv
    WHERE WSG.ORGANIZATION_ID = 104
    AND WSG.SCHEDULE_GROUP_NAME = FLV.TAG
    AND FLV.LOOKUP_TYPE = 'WIP_WORKFLOOR_XXX'
    AND FLV.LANGUAGE = 'ZHS'
    AND WJ.CLASS_CODE = FLV.DESCRIPTION)*/
    WHERE WJ.REQUEST_ID = L_REQ;
END;

转自:http://blog.itpub.net/41594/viewspace-528393

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值