0% found this document useful (0 votes)
735 views5 pages

Order by Pegging - Level Query

This document contains a SQL query that selects data from various MSC tables to retrieve information about supply and demand pegging for a specific plan and end demand order. It joins data from tables including msc_plans, msc_supplies, msc_demands, msc_system_items, and others to return fields like plan name, item name, supply/demand details, pegging IDs, and sort by pegging level. The query filters for a specific plan ("ASCP-DC") and end demand order number.

Uploaded by

Rahul Kulkarni
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
735 views5 pages

Order by Pegging - Level Query

This document contains a SQL query that selects data from various MSC tables to retrieve information about supply and demand pegging for a specific plan and end demand order. It joins data from tables including msc_plans, msc_supplies, msc_demands, msc_system_items, and others to return fields like plan name, item name, supply/demand details, pegging IDs, and sort by pegging level. The query filters for a specific plan ("ASCP-DC") and end demand order number.

Uploaded by

Rahul Kulkarni
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

select * from ( select x.plan_name , x.end_demand_order_number , (CASE WHEN x.pegging_id=x.end_pegging_id THEN 1 WHEN x.prev_pegging_id=x.

end_pegging_id THEN 2 ELSE (select count(*)+3 from msc_full_pegging fp WHERE fp.end_pegging_id=x.end_pegging_id AND fp.pegging_id <> fp.end_pegging_id AND fp.prev_pegging_id <> fp.end_pegging_id AND fp.plan_id=x.plan_id AND fp.pegging_id <= x.prev_pegging_id) END) pegging_level , x.organization_code , x.organization_id , x.item_name , x.inventory_item_id , x.supply_due_date , x.supply_order_type , x.supply_order_number , x.new_order_quantity , x.allocated_supply_qty , x.demand_order_number from( select distinct compile_designator plan_name , i.item_name , i.inventory_item_id , i.organization_code , i.organization_id , p.allocated_quantity allocated_supply_qty , p.end_item_usage , s.new_schedule_date supply_due_date , s.old_schedule_date , s.new_wip_start_date , s.old_wip_start_date , decode(s.order_type,5,to_char(s.disposition_id),17,to_char(s.disposition_id),t o_char(s.order_number)) supply_order_number , sf.meaning supply_order_type , sup.partner_name supplier , sups.partner_address supplier_site , s.new_order_quantity , s.old_order_quantity , s.non_nettable_qty , s.subinventory_code , s.lot_number , decode(s.firm_planned_type,1,'Yes','No') firm_planned_type , decode(s.release_status,1,'Yes','No') checked_for_release , s.operation_seq_num , s.new_dock_date , s.old_dock_date , decode(s.applied,2,'Released','Not Released') release_flag , s.need_by_date , fw.meaning wip_status_code , s.days_late , df.meaning demand_type , decode(d.origination_type,1,to_char(d.disposition_id),to_char(d.order_number)) demand_order_number , d.using_requirement_quantity demand_qty , d.using_assembly_demand_date demand_due_date

, d.quantity_by_due_date demand_qty_by_due_date , d.unmet_quantity demand_unmet_qty , d.demand_class demand_demand_class , ef.meaning end_demand_type , designator end_demand_designator , emsi.item_name end_demand_item , ed.using_requirement_quantity end_demand_qty , ed.order_number end_demand_order_number , ed.using_assembly_demand_date end_demand_date , c.partner_name end_demand_customer , cs.partner_address customer_address , ss.partner_address ship_to_address , ed.demand_class end_demand_demand_class , ed.promise_date end_demand_promise_date , ed.issued_quantity end_demand_issued_qty , ed.quantity_by_due_date end_demand_qty_by_due_date , ed.unmet_quantity end_demand_unmet_qty , ed.request_ship_date end_demand_request_ship_date , ed.ship_method end_demand_ship_method , p.plan_id , p.pegging_id , p.end_pegging_id , p.prev_pegging_id from msc_system_items i , msc_plans pl , msc_full_pegging p , msc_full_pegging ep , msc_supplies s , msc_demands ed , msc_demands d , msc_system_items emsi , fnd_lookup_values sf , fnd_lookup_values ef , fnd_lookup_values df , fnd_lookup_values fw , msc_trading_partners c , msc_trading_partner_sites cs , msc_trading_partner_sites ss , msc_trading_partners sup , msc_trading_partner_sites sups , msc_designators sd where p.plan_id != -1 and pl.plan_id=p.plan_id and sf.lookup_type(+)='MRP_ORDER_TYPE' and sf.language(+)='US' and sf.lookup_code(+)=s.order_type and ef.lookup_type(+)='MRP_DEMAND_ORIGINATION' and ef.language(+)='US' and ef.lookup_code(+)=ed.origination_type and df.lookup_type(+)='MRP_DEMAND_ORIGINATION' and df.language(+)='US' and df.lookup_code(+)=d.origination_type and c.partner_id(+)=ed.customer_id and cs.partner_site_id(+)=ed.customer_site_id and ss.partner_site_id(+)=ed.ship_to_site_id and i.plan_id = p.plan_id and i.sr_instance_id = p.sr_instance_id and i.inventory_item_id = p.inventory_item_id and i.organization_id = p.organization_id and emsi.plan_id(+) = ed.plan_id

and emsi.sr_instance_id(+) = ed.sr_instance_id and emsi.inventory_item_id(+) = ed.inventory_item_id and emsi.organization_id(+) = ed.organization_id and s.plan_id (+)= p.plan_id and s.sr_instance_id (+)= p.sr_instance_id and s.transaction_id (+)= p.transaction_id and sup.partner_id(+)=s.supplier_id and sups.partner_site_id(+)=s.supplier_site_id and fw.lookup_code(+)=s.wip_status_code and fw.lookup_type(+)='WIP_JOB_STATUS' and fw.language(+)='US' and d.plan_id(+) = p.plan_id and d.sr_instance_id(+) = p.sr_instance_id and d.demand_id(+) = p.demand_id and d.using_requirement_quantity(+)>0 and ep.plan_id = p.plan_id and ep.sr_instance_id = p.sr_instance_id and ep.pegging_id = p.end_pegging_id and ed.plan_id(+) = ep.plan_id and ed.sr_instance_id(+) = ep.sr_instance_id and ed.demand_id(+) = ep.demand_id and ed.using_requirement_quantity(+)>0 and sd.designator_id(+)=ed.schedule_designator_id and p.end_pegging_id!=p.pegging_id UNION select distinct compile_designator plan_name , i.item_name , i.inventory_item_id , i.organization_code , i.organization_id , p.allocated_quantity allocated_supply_qty , p.end_item_usage , s.new_schedule_date supply_due_date , s.old_schedule_date , s.new_wip_start_date , s.old_wip_start_date , decode(s.order_type,5,to_char(s.disposition_id),17,to_char(s.disposition_id),t o_char(s.order_number)) supply_order_number , sf.meaning supply_order_type , sup.partner_name supplier , sups.partner_address supplier_site , s.new_order_quantity , s.old_order_quantity , s.non_nettable_qty , s.subinventory_code , s.lot_number , decode(s.firm_planned_type,1,'Yes','No') firm_planned_type , decode(s.release_status,1,'Yes','No') checked_for_release , s.operation_seq_num , s.new_dock_date , s.old_dock_date , decode(s.applied,2,'Released','Not Released') release_flag , s.need_by_date , fw.meaning wip_status_code , s.days_late , null demand_type , null demand_order_number , null demand_qty , null demand_due_date , null demand_qty_by_due_date

, null demand_unmet_qty , null demand_demand_class , ef.meaning end_demand_type , designator end_demand_designator , emsi.item_name end_demand_item , ed.using_requirement_quantity end_demand_qty , ed.order_number end_demand_order_number , ed.using_assembly_demand_date end_demand_date , c.partner_name end_demand_customer , cs.partner_address customer_address , ss.partner_address ship_to_address , ed.demand_class end_demand_demand_class , ed.promise_date end_demand_promise_date , ed.issued_quantity end_demand_issued_qty , ed.quantity_by_due_date end_demand_qty_by_due_date , ed.unmet_quantity end_demand_unmet_qty , ed.request_ship_date end_demand_request_ship_date , ed.ship_method end_demand_ship_method , p.plan_id , p.pegging_id , p.end_pegging_id , p.prev_pegging_id from msc_supplies s , msc_plans pl , msc_system_items i , msc_full_pegging p , msc_demands ed , msc_system_items emsi , fnd_lookup_values sf , fnd_lookup_values ef , fnd_lookup_values fw , msc_trading_partners c , msc_trading_partner_sites cs , msc_trading_partner_sites ss , msc_trading_partners sup , msc_trading_partner_sites sups , msc_designators sd where p.plan_id != -1 and pl.plan_id=p.plan_id and sf.lookup_type(+)='MRP_ORDER_TYPE' and sf.language(+)='US' and sf.lookup_code(+)=s.order_type and ef.lookup_type(+)='MRP_DEMAND_ORIGINATION' and ef.language(+)='US' and ef.lookup_code(+)=ed.origination_type and c.partner_id(+)=ed.customer_id and cs.partner_site_id(+)=ed.customer_site_id and ss.partner_site_id(+)=ed.ship_to_site_id and i.plan_id = p.plan_id and i.sr_instance_id = p.sr_instance_id and i.inventory_item_id = p.inventory_item_id and i.organization_id = p.organization_id and emsi.plan_id(+) = ed.plan_id and emsi.sr_instance_id(+) = ed.sr_instance_id and emsi.inventory_item_id(+) = ed.inventory_item_id and emsi.organization_id(+) = ed.organization_id and s.plan_id (+)= p.plan_id and s.sr_instance_id (+)= p.sr_instance_id and s.transaction_id (+)= p.transaction_id and sup.partner_id(+)=s.supplier_id

and sups.partner_site_id(+)=s.supplier_site_id and fw.lookup_code(+)=s.wip_status_code and fw.lookup_type(+)='WIP_JOB_STATUS' and fw.language(+)='US' and ed.plan_id(+) = p.plan_id and ed.sr_instance_id(+) = p.sr_instance_id and ed.demand_id(+) = p.demand_id and ed.using_requirement_quantity(+)>0 and sd.designator_id(+)=ed.schedule_designator_id and p.end_pegging_id=p.pegging_id) x ) where plan_name='ASCP-DC' and end_demand_order_number='50960.SI Disti Standard.ORDER ENTRY(1.1)' order by pegging_level

You might also like