Guest User

Untitled

a guest
Apr 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. SELECT miq.SubInventory_Code,
  2. msi1.Segment1 fg,
  3. cic.Item_Cost,
  4. Substr(msi1.Description,1,50) fg_desc,
  5. miq.fg_qty,
  6. DECODE(miq.Organization_Id,173,'IPH',
  7. 'SNY') Organization,
  8. Round((SYSDATE - miq.LastReceived),0) aGing,
  9. miq2.Totalfg--,blog.sonum
  10. FROM mtl_System_Items_b msi1,
  11. cst_Item_Costs cic,
  12. (SELECT moq.Inventory_Item_Id,
  13. moq.SubInventory_Code,
  14. moq.Organization_Id,
  15. SUM(Transaction_Quantity) fg_qty,
  16. MAX(Date_Received) LastReceived-- ,msi1.segment1 fg,substr(msi1.description,1,50)fg_desc
  17. FROM mtl_OnHand_quAntiTies_Detail moq
  18. WHERE moq.Organization_Id IN (173,
  19. 92)
  20. AND SubInventory_Code IN ('IPHFG',
  21. 'IPHFGTBS',
  22. 'IPHFGSORT',
  23. 'IPHNPIFG',
  24. 'IPHINFFG',
  25. 'IPHPONFG')
  26. GROUP BY moq.Inventory_Item_Id,
  27. moq.Organization_Id,
  28. moq.SubInventory_Code--msi1.segment1,substr(msi1.description,1,50)
  29. ) miq,
  30. (SELECT moq.Inventory_Item_Id,
  31. SUM(Transaction_Quantity) Totalfg
  32. FROM mtl_OnHand_quAntiTies_Detail moq
  33. WHERE moq.Organization_Id IN (173,
  34. 92)
  35. AND SubInventory_Code IN ('IPHFG',
  36. 'IPHFGTBS',
  37. 'IPHFGSORT',
  38. 'IPHNPIFG',
  39. 'IPHINFFG',
  40. 'IPHPONFG')
  41. GROUP BY moq.Inventory_Item_Id) miq2,
  42. (SELECT msi.Inventory_Item_Id Inventory_Item_Id,
  43. msi.Segment1 ItemNumber,
  44. oeh.Order_Number Sonum,
  45. oel.Ship_From_Org_Id Organization_Id
  46. FROM wsh_Delivery_Details wsh,
  47. oe_Order_Headers_All oeh,
  48. oe_Order_Lines_All oel,
  49. mtl_System_Items_b msi
  50. WHERE wsh.Source_Header_Id = oeh.Header_Id
  51. AND wsh.Source_Line_Id = oel.Line_Id
  52. AND oeh.Header_Id = oel.Header_Id
  53. AND wsh.Inventory_Item_Id = msi.Inventory_Item_Id
  54. AND wsh.Organization_Id = msi.Organization_Id
  55. AND wsh.Organization_Id IN (92,
  56. 173,
  57. 393)
  58. AND wsh.Released_Status IN ('B',
  59. 'S',
  60. 'R',
  61. 'Y',
  62. 'N') --b backorder, c interfaced, d cancelled, n not ready to release, r ready to release,y staged/pick confirmed,
  63. AND (msi.Item_Type = 'FG'
  64. OR msi.Description LIKE 'UFA%'
  65. OR msi.Description LIKE 'BIA%'
  66. OR msi.Description LIKE 'ASY%SEMI FIN%')
  67. --and oeh.ORDER_NUMBER='109804'
  68. AND oel.Flow_Status_Code NOT IN ('CLOSED',
  69. 'CANCELLED')) bLog
  70. WHERE miq.Inventory_Item_Id = bLog.Inventory_Item_Id (+)
  71. AND msi1.Inventory_Item_Id = cic.Inventory_Item_Id
  72. AND msi1.Organization_Id = cic.Organization_Id
  73. AND cic.Cost_Type_Id = 1 --1 frozen / 2 pending
  74. --and msi.ORGANIZATION_ID = 173
  75. AND msi1.Costing_Enabled_Flag = 'Y'
  76. AND miq.Organization_Id = bLog.Organization_Id (+)
  77. AND bLog.Sonum IS NULL
  78. AND miq.Inventory_Item_Id = msi1.Inventory_Item_Id
  79. AND miq.Organization_Id = msi1.Organization_Id
  80. AND (msi1.Item_Type = 'FG'
  81. OR msi1.Description LIKE 'UFA%'
  82. OR msi1.Description LIKE 'BIA%'
  83. OR msi1.Description LIKE 'ASY%SEMI FIN%')
  84. --and miq.inventory_item_id = '115436'
  85. ORDER BY 1,
  86. 7 DESC
Add Comment
Please, Sign In to add comment