• Items not exists bom list


    -- 没有加入BOM的物料

    select
        msi.segment1 item_no,
        msi.description,
        msi.primary_uom_code uom,
        --msi.item_type,
        (select meaning from FND_LOOKUP_VALUES_VL where 1=1 AND lookup_type = 'ITEM_TYPE' and lookup_code=msi.item_type) item_type,
        nvl((SELECT SUM (moq.primary_transaction_quantity) on_hand
            FROM mtl_onhand_quantities_detail moq
            WHERE 1 = 1 AND moq.inventory_item_id = msi.inventory_item_id AND moq.organization_id = msi.organization_id), 0) on_hand_qty
    from mtl_system_items_b msi
    where 1=1
    and msi.eng_item_flag = 'N'
    and msi.organization_id = 190
    --and msi.inventory_item_id= 15395
    --and msi.segment1 = '9SL4000030AFDIF0'
    and not exists(
        select  'x'
        --       bom.assembly_item_id,
        --       bic.component_item_id,
        --       bom.organization_id
          from bom_bill_of_materials bom,
               bom_inventory_components bic
         where bom.BILL_SEQUENCE_ID = bic.bill_sequence_id
           and bom.organization_id = msi.organization_id--190
           --and bom.assembly_item_id = 15395
           --and bic.component_item_id = 11898
           and ( bom.assembly_item_id = msi.inventory_item_id or bic.component_item_id = msi.inventory_item_id)
       )

    ---------------------------------------------------------------------------------------------------------------------------------------------------------

    -- bom list
    select level,
    lst.assembly_item_id,
    lst.component_item_id,
    lst.organization_id,
    lst.farther,
    lst.component
      from (select bom.assembly_item_id,
                   bic.component_item_id,
                   bom.organization_id
                   ,(select msi.segment1 from inv.mtl_system_items_b msi where msi.organization_id=123 and  msi.inventory_item_id = bom.assembly_item_id) farther,
                   (select msi.segment1 from inv.mtl_system_items_b msi where msi.organization_id=123 and msi.inventory_item_id = bic.component_item_id) component
              from bom_bill_of_materials bom,
                   bom_inventory_components bic
             where bom.BILL_SEQUENCE_ID = bic.bill_sequence_id
               and bom.organization_id = 123) lst
    start with (lst.assembly_item_id = 15395)--15395)
    connect by lst.assembly_item_id = prior lst.component_item_id

  • 相关阅读:
    多库查询 sp_addlinkedserver使用方法(添加链接服务器)(转)片段整理
    利用asp.net路由实现url解析
    C#事务 访问数据库(转)
    男人30而立,30岁的男人喊起来!你们立了吗?
    c# 调用SQL Server存储过程返回值(转)
    转摘 JQUERY操作JSON例子
    jstree 从简单说起Jquery 插件应用说明
    利用反射对对象属性赋值取值操作
    asp.net 造成seesion 丢失的问题之一
    jquery 实现从左边listbox选择至右边listbox
  • 原文地址:https://www.cnblogs.com/quanweiru/p/2733504.html
Copyright © 2020-2023  润新知