Friday, 5 January 2018

Query to get component path of Item in Cloud

SELECT level,
  msib.item_number Struct,
  msib2.item_number Com_item,
  SYS_CONNECT_BY_PATH (msib2.item_number ,'>') PATH,
  mp.organization_code org_struct,
  mp2.organization_code org_comp
FROM EGP_COMPONENTS_B BIC,
  EGP_STRUCTURES_B BOM ,
  EGP_SYSTEM_ITEMS_B msib ,
  EGP_SYSTEM_ITEMS_B msib2 ,
  INV_ORG_PARAMETERS mp ,
  INV_ORG_PARAMETERS mp2
WHERE 1                                            =1
AND bic.bill_sequence_id                           = bom.bill_sequence_id
AND BOM.PK1_VALUE                                  = MSIB.INVENTORY_ITEM_ID
AND bom.PK2_Value                                  = msib.organization_id
AND bic.PK1_VALUE                                  = msib2.inventory_item_id
AND bic.PK2_Value                                  = msib2.organization_id
AND MP.ORGANIZATION_ID                             = MSIB.ORGANIZATION_ID
AND MP2.ORGANIZATION_ID                            = MSIB2.ORGANIZATION_ID
AND mp.organization_code                           = :Org_code
AND msib2.item_number                              = :Component_item
  CONNECT BY nocycle prior msib2.INVENTORY_ITEM_ID = MSIB.INVENTORY_ITEM_ID
ORDER BY level

2 comments: