[Home] [Help]
1204: --dbms_output.put_line('At 4');
1205:
1206: -------------------------------------------------------------------------------------
1207:
1208: --If it is the first record, then insert safety stock into MSC_SUP_DEM_ENTRIES OR
1209: --If the current record = the prev record (same plan_id, sr_instance_id, org_id and item_id)
1210: -- and no need to fill the gap between, then insert safety stock into MSC_SUP_DEM_ENTRIES OR
1211: --If it it a new record (the plan_id is different from the prev record plan_id or
1212: -- Sr_instance_id of the current is different from the previous sr_instance_id or
1206: -------------------------------------------------------------------------------------
1207:
1208: --If it is the first record, then insert safety stock into MSC_SUP_DEM_ENTRIES OR
1209: --If the current record = the prev record (same plan_id, sr_instance_id, org_id and item_id)
1210: -- and no need to fill the gap between, then insert safety stock into MSC_SUP_DEM_ENTRIES OR
1211: --If it it a new record (the plan_id is different from the prev record plan_id or
1212: -- Sr_instance_id of the current is different from the previous sr_instance_id or
1213: -- Org_id of the current record is different from the previous org_id or
1214: -- Item_id of the current record is different from the previous item_id)
1211: --If it it a new record (the plan_id is different from the prev record plan_id or
1212: -- Sr_instance_id of the current is different from the previous sr_instance_id or
1213: -- Org_id of the current record is different from the previous org_id or
1214: -- Item_id of the current record is different from the previous item_id)
1215: -- then insert safety stocks into MSC_SUP_DEM_ENTRIES
1216: --------------------------------------------------------------------------------------
1217:
1218: IF t_org_id IS NOT NULL AND t_org_id.COUNT > 0 THEN
1219:
1439: BEGIN
1440: SELECT 1 INTO l_records_exist
1441: FROM dual
1442: WHERE exists ( SELECT 1
1443: FROM msc_sup_dem_entries
1444: WHERE plan_id = -1
1445: AND publisher_order_type = 2
1446: AND designator = p_designator
1447: AND version = l_version);
1992:
1993: -- IF (l_next_work_date = t_key_date(j)) THEN
1994: IF (t_key_date(j) >= p_horizon_start and t_key_date(j) <= p_horizon_end ) THEN
1995:
1996: insert into msc_sup_dem_entries (
1997: transaction_id,
1998: plan_id,
1999: sr_instance_id,
2000: publisher_name,
2033: planner_code,
2034: version,
2035: designator
2036: ) values (
2037: msc_sup_dem_entries_s.nextval,
2038: -1,
2039: -1,
2040: t_pub(j),
2041: t_pub_id(j),
2137: --dbms_output.put_line('Start ' || b_bkt_start_date(k) || ' End ' || b_bkt_end_date(k) );
2138: --dbms_output.put_line(' prev ' || l_prev_work_date );
2139: IF (b_bkt_end_date(k) >= p_horizon_start and b_bkt_end_date(k) <= p_horizon_end ) THEN
2140:
2141: insert into msc_sup_dem_entries (
2142: transaction_id,
2143: plan_id,
2144: sr_instance_id,
2145: publisher_name,
2178: planner_code,
2179: version,
2180: designator
2181: ) values (
2182: msc_sup_dem_entries_s.nextval,
2183: -1,
2184: -1,
2185: t_pub(j),
2186: t_pub_id(j),
2261: l_order_type_desc := msc_x_util.get_lookup_meaning ('MSC_X_ORDER_TYPE', SAFETY_STOCK);
2262: l_bucket_type_desc := msc_x_util.get_lookup_meaning('MSC_X_BUCKET_TYPE',b_bkt_type(k));
2263:
2264: IF (b_bkt_end_date(k) >= p_horizon_start and b_bkt_end_date(k) <= p_horizon_end ) THEN
2265: insert into msc_sup_dem_entries (
2266: transaction_id,
2267: plan_id,
2268: sr_instance_id,
2269: publisher_name,
2302: planner_code,
2303: version,
2304: designator
2305: ) values (
2306: msc_sup_dem_entries_s.nextval,
2307: -1,
2308: -1,
2309: t_pub(j-1),
2310: t_pub_id(j-1),
2380: l_order_type_desc := msc_x_util.get_lookup_meaning ('MSC_X_ORDER_TYPE', SAFETY_STOCK);
2381: l_bucket_type_desc := msc_x_util.get_lookup_meaning('MSC_X_BUCKET_TYPE',b_bkt_type(k));
2382:
2383: IF (b_bkt_end_date(k) >= p_horizon_start and b_bkt_end_date(k) <= p_horizon_end ) THEN
2384: insert into msc_sup_dem_entries (
2385: transaction_id,
2386: plan_id,
2387: sr_instance_id,
2388: publisher_name,
2421: planner_code,
2422: version,
2423: designator
2424: ) values (
2425: msc_sup_dem_entries_s.nextval,
2426: -1,
2427: -1,
2428: t_pub(j),
2429: t_pub_id(j),
2511: FND_FILE.PUT_LINE(FND_FILE.LOG, 'total ' || l_total || ' item ' || t_item_id(j) || ' Key date ' || t_key_date(j));
2512: l_bucket_type_desc := msc_x_util.get_lookup_meaning('MSC_X_BUCKET_TYPE',1);
2513:
2514: IF (trunc(t_key_date(j)) >= trunc(p_horizon_start)) THEN
2515: update msc_sup_dem_entries
2516: set quantity = l_total,
2517: primary_quantity = l_total
2518: where publisher_id = t_pub_id(j)
2519: and publisher_site_id = t_pub_site_id(j)
2527: l_bucket_type_desc := msc_x_util.get_lookup_meaning('MSC_X_BUCKET_TYPE',t_bucket_type(j));
2528: IF l_rowcount = 0 THEN
2529: FND_FILE.PUT_LINE(FND_FILE.LOG, 'row count = 0' || 'Pub ' || t_pub(j) || 'Pub id ' || t_pub_id(j));
2530: --dbms_output.put_line('row count = 0'|| 'Pub ' || t_pub(j) || 'Pub id ' || t_pub_id(j));
2531: insert into msc_sup_dem_entries (
2532: transaction_id,
2533: plan_id,
2534: sr_instance_id,
2535: publisher_name,
2568: planner_code,
2569: version,
2570: designator
2571: ) values (
2572: msc_sup_dem_entries_s.nextval,
2573: -1,
2574: -1,
2575: t_pub(j),
2576: t_pub_id(j),
2689: --dbms_output.put_line(' End ' || b_bkt_end_date(k) || ' prev ' || l_prev_work_date);
2690:
2691: IF (b_bkt_end_date(k) >= p_horizon_start ) THEN
2692:
2693: insert into msc_sup_dem_entries (
2694: transaction_id,
2695: plan_id,
2696: sr_instance_id,
2697: publisher_name,
2730: planner_code,
2731: version,
2732: designator
2733: ) values (
2734: msc_sup_dem_entries_s.nextval,
2735: -1,
2736: -1,
2737: t_pub(j),
2738: t_pub_id(j),
2798:
2799: l_bucket_type_desc := msc_x_util.get_lookup_meaning('MSC_X_BUCKET_TYPE',t_bucket_type(j));
2800:
2801: IF ( t_key_date(j) >= p_horizon_start) THEN
2802: insert into msc_sup_dem_entries (
2803: transaction_id,
2804: plan_id,
2805: sr_instance_id,
2806: publisher_name,
2839: planner_code,
2840: version,
2841: designator
2842: ) values (
2843: msc_sup_dem_entries_s.nextval,
2844: -1,
2845: -1,
2846: t_pub(j),
2847: t_pub_id(j),
2901:
2902: --dbms_output.put_line('update date ' || t_key_date(j) || ' qty ' || l_total || ' t tol ' || t_total_qty(j) || ' ex ' || l_exp_qty);
2903: --dbms_output.put_line('update');
2904: IF (t_key_date(j) >= p_horizon_start) THEN
2905: update msc_sup_dem_entries
2906: set quantity = l_total,
2907: primary_quantity = l_total
2908: where publisher_id = t_pub_id(j)
2909: and publisher_site_id = t_pub_site_id(j)
2917: l_bucket_type_desc := msc_x_util.get_lookup_meaning('MSC_X_BUCKET_TYPE',t_bucket_type(j));
2918: IF l_rowcount = 0 THEN
2919: FND_FILE.PUT_LINE(FND_FILE.LOG, 'row count = 0' || 'Pub ' || t_pub(j) || 'Pub id ' || t_pub_id(j));
2920: --dbms_output.put_line('row count = 0'|| 'Pub ' || t_pub(j) || 'Pub id ' || t_pub_id(j));
2921: insert into msc_sup_dem_entries (
2922: transaction_id,
2923: plan_id,
2924: sr_instance_id,
2925: publisher_name,
2958: planner_code,
2959: version,
2960: designator
2961: ) values (
2962: msc_sup_dem_entries_s.nextval,
2963: -1,
2964: -1,
2965: t_pub(j),
2966: t_pub_id(j),
3043: l_bucket_type_desc := msc_x_util.get_lookup_meaning('MSC_X_BUCKET_TYPE',b_bkt_type(k));
3044:
3045: IF (b_bkt_end_date(k) >= p_horizon_start and b_bkt_end_date(k) <= p_horizon_end ) THEN
3046:
3047: insert into msc_sup_dem_entries (
3048: transaction_id,
3049: plan_id,
3050: sr_instance_id,
3051: publisher_name,
3084: planner_code,
3085: version,
3086: designator
3087: ) values (
3088: msc_sup_dem_entries_s.nextval,
3089: -1,
3090: -1,
3091: t_pub(j-1),
3092: t_pub_id(j-1),
3171: l_bucket_type_desc := msc_x_util.get_lookup_meaning('MSC_X_BUCKET_TYPE',b_bkt_type(k));
3172:
3173: IF (b_bkt_end_date(k) >= p_horizon_start and b_bkt_end_date(k) <= p_horizon_end ) THEN
3174:
3175: insert into msc_sup_dem_entries (
3176: transaction_id,
3177: plan_id,
3178: sr_instance_id,
3179: publisher_name,
3212: planner_code,
3213: version,
3214: designator
3215: ) values (
3216: msc_sup_dem_entries_s.nextval,
3217: -1,
3218: -1,
3219: t_pub(j),
3220: t_pub_id(j),
3301: --dbms_output.put_line('In delete_old_safety stock');
3302:
3303:
3304: IF ( p_overwrite = 1) THEN --delete all
3305: delete from msc_sup_dem_entries sd
3306: where sd.publisher_order_type in (SAFETY_STOCK, PROJECTED_AVAILABLE_BALANCE) and
3307: sd.plan_id = -1 and
3308: sd.publisher_id = 1 and
3309: exists (select cs.company_site_id
3331: l_row := SQL%ROWCOUNT;
3332: FND_FILE.PUT_LINE(FND_FILE.LOG, 'Deleted number records: ' || l_row);
3333: --dbms_output.put_line('Deleted number records: ' || l_row);
3334: ELSIF ( p_overwrite = 2) THEN --delete by overwritten
3335: delete from msc_sup_dem_entries sd
3336: where sd.publisher_order_type in (SAFETY_STOCK, PROJECTED_AVAILABLE_BALANCE) and
3337: sd.plan_id = -1 and
3338: sd.publisher_id = 1 and
3339: exists (select cs.company_site_id