Você está na página 1de 11

SQL Queries

Note: Your organization's database administrator should be the person designated to run these SQL Scripts. A basic understanding of the architecture of Oracle Global Order Promising is helpful. The following are some notes:

Data Collection is responsible for gathering all the relevant data in the Source Instance from the INV, BOM, PO, OE, MRP, and WIP schemas, and duplicating the data in the MSC schema for ATP and Oracle Advanced Supply Chain Planning purposes. Since you can collect data from more than one instance, MSC has it's own item numbering system that is seen in MSC_SYSTEM_ITEMS. This means that each item is assigned a new INVENTORY_ITEM_ID in MSC_SYSTEM_ITEMS when it is collected. The Source Inventory Item ID is stored under SR_INVENTORY_ITEM_ID. SR_% is used in many common column names to denote a value on the Source Instance. Many tables contain the first column PLAN_ID.
o o

The PLAN_ID "-1" is reserved for the Collected Data. Positive PLAN_ID numbers are for the ASCP planning data generated when a plan is executed in Oracle Advanced Supply Chain Planning. Some collected data is used regardless of ATP type being executed, and do not need a PLAN_ID. Sourcing rules is an example.

MSC_PLANS and MSC_PLAN_PARTITIONS contain the setup data for your plans. For example, Collections is PLAN_ID = -1 in MSC_PLANS. If you collect data from more than one instance, then the SR_INSTANCE_ID column in the MSC_% tables becomes very important since the data from the two different instances can be exactly the same with the exception of this value. The ORGANIZATION_ID does not change in the MSC tables. It is differentiated by the SR_INTANCE_ID when collecting from more than one instance.

Basic Queries

The basic queries below retrieve item and plan information to start diagnosis of an item problem: From the Source instance, the following gives you:

The organization_id for your organization_code The inventory_item_id which is the sr_inventory_item_id is MSC_SYSTEM_ITEMS Select i.concatenated_segments, i.inventory_item_id, i.organization_id from mtl_system_items_kfv i, mtl_parameters p where i.concatenated_segments like '&Item_name' and i.organization_id = p.organization_id and p.organization_code = '&Organization_code' and i.organization_id = p.organization_id; Use &Organization_Code = Enter your Org Code when prompted &Item_name = Enter your Item Name when prompted

The following query gives you:


The instance_id of your source instance The instance_code of your source instance Select

instance_id, instance_code from mrp_ap_apps_instances; From the destination, the two following queries should produce results to allow for most the various variables: Select substr(item_name,1.30) Item_name, sr_inventory_item_id, inventory_item_id, organization_id from msc_system_items where sr_inventory_item_id = &Source_Inventory_item_id and organization_id = &Organization_id and sr_instance_id = &Instance_ID and plan_id = -1; USE &Source_Inventory_item_id = from first query on the source &Organization_id = organization_id from the first quest on the source &Instance_ID = from the second query of on the source Data Error SQL Queries These SQL queries address the ATP Based on Collected Data Errors and the Other Data Errors from the Troubleshooting section. Error 47: Unable to find a calendar date. Two possible issues: 1. The calendar is not assigned to the organization. Select calendar_code, calendar_exception_set_id from msc_trading_partners

where sr_instance_id = &Instance_id and sr_tp_id = &Organization_id and partner_type = 3; Use &Instance_id = instance id of the source instance &Organization_id = organization id of the item If the above two columns are not populated, then a calendar has not been assigned to the organization. Assign a calendar to the organization and run Data Collections with a Complete Refresh. 2. The request date is outside the date range of the calendar assigned to the organization. Select Min(calendar_date), Max(calendar_date) from msc_calendar_dates where sr_instance_id = &Instance_id and calendar_code = '&Calendar_code' and exception_set_id = &Calendar_exception_set_id; Use &Instance_id = instance id of the source instance &Calendar_code = calendar code from query in section a

&Calendar_exception_set_id = calendar exception set id from query in section a Error 57: Invalid ATP Rule or No ATP Rule defined. Select nvl(msi.atp_rule_id, tp.default_atp_rule_id) atp_rule_id from msc_system_items msi, msc_trading_partners tp where msi.sr_inventory_item_id = &Source_Inventory_item_id and msi.sr_instance_id = &Instance_id and msi.organization_id = &Organization_id and plan_id = -1 and tp.sr_instance_id = msi.sr_instance_id and tp.sr_tp_id = msi.organization_id and tp.partner_type = 3; Use &Source_Inventory_item_id = source inventory item id &Instance_id = instance id of the source instance &Organization_id = organization id of the sourcing organization Error Code 85: This item is not collected. Please run Data Collection. Select item_name, atp_flag, atp_components_flag from msc_system_items where sr_inventory_item_id = &Source_Inventory_item_id and sr_instance_id = &Instance_id and plan_id = -1; Use &Source_Inventory_item_id = source inventory item id &Instance_id = instance id of the source instance &Organization_id = organization id of the item Note: If the above query does not return a row for the organization that you are expecting, then the item has not been collected. Check the item's setup on the source instance. Run Data Collections with a Complete Refresh or Target Refresh. Then check for the item again.

Error 120: Plan not found. Execute the following query: Select distinct(plan_id) Plan_id from msc_atp_plan_sn; Then: Select plan_id, from msc_atp_plan_sn where sr_inventory_item_id = &Source_Inventory_item_id and sr_instance_id = &Instance_id and organization-id = &Organization_id; Use &Source_Inventory_item_id = source inventory item id &Instance_id = instance id of the source instance &Organization_id = organization id of the item Notes: If the above query does not return any data, then:

The Plan has not been made ATP-able. Check that the Inventory ATP Flag is the plan options is checked. The Plan has not run successfully. Then: Select plan_completion_date, data_completion_date, plan_id from msc_plans where compile_designator = '&Plan_name';

Use &Plan_name. The name of the plan. If plan is run successfully, then above two date columns should be populated.

The Plan does not contain the item. Then: Select item_name from msc_system_items where plan_id = &Plan_id and sr_inventory_item_id = &Source_Inventory_item_id and sr_instance_id = &Instance_id and organization-id = &Organization_id; Use &Plan_id = The Plan_id from above &Source_Inventory_item_id = source inventory item id &Instance_id = instance id of the source instance &Organization_id = organization id of the item

Error 140: No APS instance defined. Set APS instance and run collections . Run the following queries on the source instance: Select a2m_dblink from mrp_ap_apps_instances;

Note: The above query should return the name of only one valid database link. Error 220: ATP has detected invalid objects. Contact your system admin. The following query provides some of the possible invalid objects in the database: Select owner, object_name, object_type, status from all_objects where status = 'INVALID' and object_name like 'MSC%' and object_type != 'UNDEFINED'; Then: Select owner, object_name, object_type, status from all_objects where status = 'INVALID' and object_name like 'MRP%' and object_type != 'UNDEFINED'; Note: If any objects are owned by APPS_MRC, ignore them. Recompile the rest of invalid objects returned, and report the errors for each object that cannot be recompiled. Error 230: INV: Capable To Promise must be same at source and destination. Run the following queries on both source and destination: Select FND_PROFILE.value('INV_CTP') from dual; Note: This profile must be the same in both instances and should only be set at the site level.

Other Data Error: Some past due sales orders, supplies, or demands are not included in the ATP. Select rule_name, past_due_demand_cutoff_fence, past_due_supply_cutoff_fence, include_sales_orders, include_purchase_orders, include_discrete_wip_receipts, include_nonstd_wip_receipts, include_discrete_mps, include_rep_mps, include_rep_wip_receipts from msc_atp_rules where rule_id = &ATP_Rule_id and sr_instance_id = &Instance_id; Use &ATP_Rule_id = rule id determined using query in the section above &Instance_id = instance id of the source instance Note: For any supply and demand types that have values returned as 1, ATP only considers the past due demand and supply for that many days.For example: for Past Due Demand Days of 5 days, ATP only considers past due demands that fall under the sysdate of 5 days. To consider all past due demands, these fields should be left blank. Other Data Error: Some supplies and demands are missing. Note: The inventory_item_id must be obtained from msc_system_items when querying on msc_sales_orders and msc_supplies, because the Source Inventory_item_id is not used in these tables. For details, see the Basic Queries. Sales Order Demand Query for ATP based on Collected Data Select demand_id, primary_uom_quantity, Reservation_quantity, completed_quantity,

requirement_date, sales_order_number, available_to_mrp, demand_visible from msc_sales_orders where sr_instance_id = &Instance_id and organization_id = &Organization_id and inventory_item_id = &Inventory_item_id; order by requirement_date Use &Inventory_item_id = inventory item id from msc_system_items &Instance_id = instance id of the source instance &Organization_id = organization id of the item Supply Query Select inventory_item_id, order_type, new_schedule_date, new_order_quantity from msc_supplies where sr_instance_id = &Instance_id and organization_id = &Organization_id and inventory_item_id = &Inventory_item_id and plan_id = &plan_id order by new_schedule_date; Use &Inventory_item_id = inventory item id from msc_system_items &Instance_id = instance id of the source instance &Organization_id = organization id of the item &plan_id = -1 when ATP is based on collected data. It is the actual plan, id if ATP is based on planning output Notes: If a supply is missing, run Data Collections again using a Complete Refresh.

Verify that the Planning Manager is running if the profile MRP: Consume MPS is set to yes. If this is a Purchase Order, the problem may be that the Purchase Order was awaiting approval during the first run of Data Collections.

Você também pode gostar