107: l_plan_type NUMBER := 1;
108:
109: -- --------------------------------------------
110: -- This cursor selects the snapshot activity in
111: -- MSC_DEMANDS and MSC_SUPPLIES
112: -- for the items per organizatio for a plan..
113: -- --------------------------------------------
114:
115: -- Ship To Values
144: md.using_assembly_demand_date old_date,
145: sum(md.using_requirement_quantity) new_quantity,
146: sum(nvl(md.UNMET_QUANTITY,0)) unmet_quantity
147: FROM msc_form_query list,
148: msc_demands md
149: WHERE md.plan_id = list.number4
150: AND md.inventory_item_id = list.number1
151: AND md.organization_id = list.number2
152: AND md.sr_instance_id = list.number3
226: forecast.sales_order_id)),
227: CONSUMED, CONSUMED_OFF,
228: forecast.consumption_date
229: UNION ALL -- substitution in
230: SELECT /*+ INDEX(MD MSC_DEMANDS_N3) */
231: list.number5 item_id,
232: list.number6 org_id,
233: list.number3 inst_id,
234: decode(list.number8, 4, nvl(to_char(md.customer_id), '-99'),
249: md.using_assembly_demand_date old_date,
250: sum(nvl(md.using_requirement_quantity,0)) new_quantity,
251: sum(nvl(md.UNMET_QUANTITY,0)) unmet_quantity
252: FROM msc_form_query list,
253: msc_demands md
254: WHERE md.plan_id = list.number4
255: AND md.inventory_item_id = list.number1
256: AND md.organization_id = list.number2
257: AND md.sr_instance_id = list.number3
279: decode(md.origination_type, 6, SO_SUBS_IN_OFF, 30, SO_SUBS_IN_OFF,
280: FCST_SUBS_IN_OFF),
281: md.using_assembly_demand_date
282: UNION ALL -- substitution out
283: SELECT /*+ INDEX(MD MSC_DEMANDS_N3) */ -- bug 11817966
284: list.number5 item_id,
285: list.number6 org_id,
286: list.number3 inst_id,
287: decode(list.number8, 4, nvl(to_char(md.customer_id), '-99'),
302: md.using_assembly_demand_date old_date,
303: sum(nvl(md.using_requirement_quantity,0)) new_quantity,
304: sum(nvl(md.UNMET_QUANTITY,0)) unmet_quantity
305: FROM msc_form_query list,
306: msc_demands md
307: WHERE md.plan_id = list.number4
308: AND md.original_item_id = list.number1
309: AND md.organization_id = list.number2
310: AND md.sr_instance_id = list.number3
873:
874: cursor local_forecasting(p_org number, p_inst number, p_item number) is
875: select mde.update_type
876: from msc_designators mde,
877: msc_demands md
878: where md.plan_id = p_plan_id
879: and md.organization_id = p_org
880: and md.sr_instance_id = p_inst
881: and md.inventory_item_id = p_item
1128: IF p_rowtype = CONSUMED THEN -- Forecast Consumed Row
1129:
1130: sql_stmt := sql_stmt ||
1131: ' md.demand_id '||
1132: ' FROM msc_forecast_updates mfu, msc_demands md'||
1133: ' WHERE mfu.plan_id = :p_plan_id' ||
1134: ' AND mfu.sr_instance_id = :p_inst_id'||
1135: ' and mfu.organization_id =:p_org_id '||
1136: ' and mfu.inventory_item_id = :p_item_id' ||
1143: FCST_SUBS_IN, SO_SUBS_IN) THEN
1144: if p_org_id = -1 then
1145: sql_stmt := sql_stmt ||
1146: ' md2.demand_id '||
1147: ' FROM msc_demands md,'||
1148: ' msc_demands md2 '||
1149: ' WHERE md.plan_id = :p_plan_id' ||
1150: ' AND md.sr_instance_id = :p_inst_id'||
1151: ' and md.organization_id =:p_org_id '||
1144: if p_org_id = -1 then
1145: sql_stmt := sql_stmt ||
1146: ' md2.demand_id '||
1147: ' FROM msc_demands md,'||
1148: ' msc_demands md2 '||
1149: ' WHERE md.plan_id = :p_plan_id' ||
1150: ' AND md.sr_instance_id = :p_inst_id'||
1151: ' and md.organization_id =:p_org_id '||
1152: ' and trunc(md.using_assembly_demand_date) BETWEEN '''||
1157: else
1158:
1159: sql_stmt := sql_stmt ||
1160: ' md.demand_id ' ||
1161: ' FROM msc_demands md'||
1162: ' WHERE md.plan_id = :p_plan_id' ||
1163: ' AND md.sr_instance_id = :p_inst_id'||
1164: ' and md.organization_id =:p_org_id '||
1165: ' and trunc(md.using_assembly_demand_date) BETWEEN '''||
1188: ELSIF p_rowtype in (CURRENT, SO_CURRENT) THEN -- Current Row
1189: IF p_org_id = -1 then
1190: sql_stmt := sql_stmt ||
1191: ' orig_md.demand_id ' ||
1192: ' FROM msc_demands md,'||
1193: ' msc_demands orig_md'||
1194: ' WHERE md.plan_id = :p_plan_id' ||
1195: ' and md.sr_instance_id = :p_inst_id' ||
1196: ' and md.organization_id =:p_org_id '||
1189: IF p_org_id = -1 then
1190: sql_stmt := sql_stmt ||
1191: ' orig_md.demand_id ' ||
1192: ' FROM msc_demands md,'||
1193: ' msc_demands orig_md'||
1194: ' WHERE md.plan_id = :p_plan_id' ||
1195: ' and md.sr_instance_id = :p_inst_id' ||
1196: ' and md.organization_id =:p_org_id '||
1197: ' and md.inventory_item_id = :p_item_id' ||
1201: ' and md.demand_id = nvl(orig_md.original_demand_id, orig_md.demand_id) ';
1202: ELSE -- IF p_org_id <> -1 then
1203: sql_stmt := sql_stmt ||
1204: ' md.demand_id ' ||
1205: ' FROM msc_demands md'||
1206: ' WHERE md.plan_id = :p_plan_id' ||
1207: ' and md.sr_instance_id = :p_inst_id' ||
1208: ' and md.organization_id =:p_org_id '||
1209: ' and md.inventory_item_id = :p_item_id' ||
1264: CURSOR ship_to_c IS
1265: select to_char(md.customer_id),
1266: to_char(md.customer_site_id),
1267: to_char(md.zone_id)
1268: from msc_demands md
1269: where plan_id = p_plan_id
1270: and demand_id = p_sales_order_id;
1271:
1272: v_customer varchar2(100);