21: -- HISTORY
22: --=============================================================================================================*/
23:
24: PROCEDURE Migrate_opm_om_open_lines( p_migration_run_id IN NUMBER
25: , p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE
26: , x_failure_count OUT NOCOPY NUMBER) IS
27:
28: /* Migration specific variables */
29: l_failure_count NUMBER := 0;
53:
54: /* MTL Move order line */
55: l_trolin_tbl INV_Move_Order_PUB.Trolin_Tbl_Type;
56: l_trolin_val_tbl INV_Move_Order_PUB.Trolin_Val_Tbl_Type;
57: l_commit VARCHAR2(1) := FND_API.G_TRUE;
58: l_line_num Number := 0;
59: l_order_count NUMBER := 1;
60:
61: /* Item Controls */
359: p_migration_run_id => p_migration_run_id,
360: p_item_id => allocations_for_line_rec.item_id,
361: p_organization_id => l_organization_id,
362: p_mode => NULL,
363: p_commit => FND_API.G_TRUE,
364: x_inventory_item_id => l_inventory_item_id,
365: x_failure_count => l_failure_count1);
366:
367: IF (l_failure_count1 > 0) THEN
380: p_param5 => NULL,
381: p_db_error => NULL,
382: p_app_short_name => 'GMI');
383: l_failure_count := l_failure_count + l_failure_count1;
384: raise FND_API.G_EXC_ERROR;
385: END IF; -- IF (l_failure_count1 > 0) THEN
386:
387: /* possibly multiple delivery details are updated */
388: update wsh_delivery_details
437: p_subinventory_code => allocations_for_line_rec.whse_code,
438: p_location => allocations_for_line_rec.location,
439: p_loct_desc => allocations_for_line_rec.location,
440: p_start_date_active => sysdate,
441: p_commit => FND_API.G_TRUE,
442: x_location_id => l_locator_id,
443: x_failure_count => l_failure_count1,
444: p_segment2 => NULL,
445: p_segment3 => NULL,
477: p_param5 => NULL,
478: p_db_error => NULL,
479: p_app_short_name => 'GMI');
480: l_failure_count := l_failure_count + l_failure_count1;
481: raise FND_API.G_EXC_ERROR;
482: END IF; -- IF (l_failure_count1 > 0) THEN
483: GMI_RESERVATION_UTIL.Println('after calling inv_migrate_process_org.create_location - locator_id '|| l_locator_id);
484:
485: END IF; -- IF (l_locator_id is NULL) THEN
521: P_LOT_NO => l_lot_no,
522: P_SUBLOT_NO => l_sublot_no,
523: P_ORGANIZATION_ID => l_organization_id, -- 5574631 instead of open_order_line_rec.ship_from_org_id,
524: P_LOCATOR_ID => l_inventory_location_id, -- 5574631 use instead of l_locator_id
525: P_COMMIT => FND_API.G_TRUE,
526: X_LOT_NUMBER => l_odm_lot_num,
527: X_PARENT_LOT_NUMBER => l_parent_lot_num,
528: X_FAILURE_COUNT => l_count
529: );
547: p_param4 => l_locator_id,
548: p_param5 => NULL,
549: p_db_error => NULL,
550: p_app_short_name => 'GMI');
551: raise FND_API.G_EXC_ERROR;
552: ELSE
553: GMI_RESERVATION_UTIL.Println('get odm_lot succes: l_odm_lot_num is '||l_odm_lot_num);
554:
555: END IF;
596:
597: fnd_msg_pub.initialize;
598: INV_RESERVATION_PUB.create_reservation(
599: p_api_version_number => 1.0
600: , p_init_msg_lst => fnd_api.g_false
601: , x_return_status => l_api_return_status
602: , x_msg_count => l_msg_count
603: , x_msg_data => l_msg_data
604: , p_rsv_rec => l_insert_rsv_rec
603: , x_msg_data => l_msg_data
604: , p_rsv_rec => l_insert_rsv_rec
605: , p_serial_number => l_dummy_sn
606: , x_serial_number => l_dummy_sn
607: , p_partial_reservation_flag => fnd_api.g_true
608: , p_force_reservation_flag => fnd_api.g_false
609: , p_validation_flag => 'Q'
610: , x_quantity_reserved => l_qty_reserved
611: , x_secondary_quantity_reserved=> l_sec_qty_reserved
604: , p_rsv_rec => l_insert_rsv_rec
605: , p_serial_number => l_dummy_sn
606: , x_serial_number => l_dummy_sn
607: , p_partial_reservation_flag => fnd_api.g_true
608: , p_force_reservation_flag => fnd_api.g_false
609: , p_validation_flag => 'Q'
610: , x_quantity_reserved => l_qty_reserved
611: , x_secondary_quantity_reserved=> l_sec_qty_reserved
612: , x_reservation_id => l_reservation_id
612: , x_reservation_id => l_reservation_id
613: );
614:
615: -- Return an error if the create reservation call failed
616: IF l_api_return_status <> fnd_api.g_ret_sts_success THEN
617: GMI_RESERVATION_UTIL.PrintLn(' Create reservation failed');
618: GMI_RESERVATION_UTIL.PrintLn(l_msg_data);
619: FND_MSG_PUB.Count_AND_GET (p_count => l_msg_count, p_data => l_msg_data);
620: FOR i in 1..l_msg_count LOOP
651: p_app_short_name => 'GMI');
652:
653: fnd_message.set_name('INV', 'INV_CREATE_RSV_FAILED');
654: fnd_msg_pub.ADD;
655: RAISE fnd_api.g_exc_unexpected_error;
656: ELSE
657: GMI_RESERVATION_UTIL.PrintLn(' Create reservation succeeded - Reservation_id : '|| l_reservation_id);
658: GMI_RESERVATION_UTIL.PrintLn(' l_qty_reserved : '|| l_qty_reserved);
659: GMI_RESERVATION_UTIL.PrintLn(' l_sec_qty_reserved : '|| l_sec_qty_reserved);
659: GMI_RESERVATION_UTIL.PrintLn(' l_sec_qty_reserved : '|| l_sec_qty_reserved);
660: GMI_RESERVATION_UTIL.PrintLn(' Created at least one detailed reservation ');
661: /* Created atleast one detailed reservation */
662: l_detail_reservations := 1;
663: END IF; -- IF l_api_return_status <> fnd_api.g_ret_sts_success THEN
664:
665:
666: EXCEPTION
667: --WHEN NON_INV_ITEM THEN
667: --WHEN NON_INV_ITEM THEN
668: -- GMI_RESERVATION_UTIL.PrintLn('Non inventory item..doing nothing');
669: -- NULL;
670:
671: WHEN FND_API.g_exc_unexpected_error THEN
672: l_failure_count := l_failure_count + 1;
673:
674:
675: WHEN OTHERS THEN
762: l_trohdr_rec.organization_id := l_ic_mo_header_rec.organization_id;
763: l_trohdr_rec.status_date := sysdate;
764: l_trohdr_rec.to_subinventory_code := l_ic_mo_header_rec.to_subinventory_code;
765: --l_trohdr_rec.transaction_type_id := INV_GLOBALS.G_TYPE_TRANSFER_ORDER_ISSUE; -- not sure of this
766: l_trohdr_rec.db_flag := FND_API.G_TRUE;
767: l_trohdr_rec.operation := INV_GLOBALS.G_OPR_CREATE;
768: l_trohdr_rec.move_order_type := INV_GLOBALS.G_MOVE_ORDER_PICK_WAVE; -- 5601081 type changed
769: l_trohdr_rec.grouping_rule_id := l_grouping_rule_id ; -- 5601081
770: GMI_RESERVATION_UTIL.PrintLn('before call to INV_Move_Order_PUB.Create_move_order_header');
771:
772: fnd_msg_pub.initialize;
773: INV_Move_Order_PUB.Create_move_order_header ( p_api_version_number => 1.0 ,
774: p_init_msg_list => 'T',
775: p_commit => FND_API.G_FALSE,
776: p_return_values => FND_API.G_TRUE,
777: x_return_status => l_return_status,
778: x_msg_count => l_msg_count,
779: x_msg_data => l_msg_data,
772: fnd_msg_pub.initialize;
773: INV_Move_Order_PUB.Create_move_order_header ( p_api_version_number => 1.0 ,
774: p_init_msg_list => 'T',
775: p_commit => FND_API.G_FALSE,
776: p_return_values => FND_API.G_TRUE,
777: x_return_status => l_return_status,
778: x_msg_count => l_msg_count,
779: x_msg_data => l_msg_data,
780: p_trohdr_rec => l_trohdr_rec,
782: x_trohdr_rec => l_trohdr_rec,
783: x_trohdr_val_rec => l_trohdr_val_rec
784: );
785:
786: IF l_return_status <> fnd_api.g_ret_sts_success THEN
787: GMI_RESERVATION_UTIL.PrintLn(' Create_move_order_header failed ');
788: GMI_RESERVATION_UTIL.PrintLn(l_msg_data);
789: FND_MSG_PUB.Count_AND_GET (p_count => l_msg_count, p_data => l_msg_data);
790: FOR i in 1..l_msg_count LOOP
821: p_app_short_name => 'INV');
822:
823: fnd_message.set_name('INV', 'INV_ERROR_CREATING_MO');
824: fnd_msg_pub.ADD;
825: RAISE fnd_api.g_exc_unexpected_error;
826: ELSE
827: GMI_RESERVATION_UTIL.PrintLn(' Create_move_order_header succeeded - header_id : '|| l_trohdr_rec.header_id);
828: l_mo_header_id := l_trohdr_rec.header_id;
829: -- only do this if the create move order header above suceeded
835: WHERE header_id = l_ic_mo_header_rec.header_id;
836:
837: GMI_RESERVATION_UTIL.PrintLn(' after update to attribute15 of in ic_txn_request_headers');
838:
839: END IF; -- IF l_api_return_status <> fnd_api.g_ret_sts_success THEN
840:
841: END IF; -- IF(l_ic_mo_header_rec.attribute15 IS NOT NULL) THEN
842:
843: /* Now Create a line */
898: l_trolin_tbl(l_order_count).inventory_item_id := move_order_line_rec.inventory_item_id;
899: l_trolin_tbl(l_order_count).last_updated_by := FND_GLOBAL.USER_ID;
900: l_trolin_tbl(l_order_count).last_update_date := sysdate;
901: l_trolin_tbl(l_order_count).last_update_login := FND_GLOBAL.LOGIN_ID;
902: l_trolin_tbl(l_order_count).line_id := FND_API.G_MISS_NUM;
903: l_trolin_tbl(l_order_count).line_number := l_line_num;
904: l_trolin_tbl(l_order_count).line_status := INV_Globals.G_TO_STATUS_PREAPPROVED;
905: l_trolin_tbl(l_order_count).organization_id := move_order_line_rec.organization_id; -- pal this needs to be right if suborg mapping
906: l_trolin_tbl(l_order_count).quantity := move_order_line_rec.quantity;
923: l_trolin_tbl(l_order_count).txn_source_line_detail_id := l_delivery_detail_id; -- 5601081
924:
925: l_trolin_tbl(l_order_count).grade_code := move_order_line_rec.qc_grade; -- 5703365
926:
927: l_trolin_tbl(l_order_count).db_flag := FND_API.G_TRUE;
928: l_trolin_tbl(l_order_count).operation := INV_GLOBALS.G_OPR_CREATE;
929:
930:
931: fnd_msg_pub.initialize;
931: fnd_msg_pub.initialize;
932: INV_Move_Order_PUB.Create_Move_Order_Lines (
933: p_api_version_number => 1.0 ,
934: p_init_msg_list => 'T',
935: p_commit => FND_API.G_FALSE,
936: x_return_status => l_return_status,
937: x_msg_count => l_msg_count,
938: x_msg_data => l_msg_data,
939: p_trolin_tbl => l_trolin_tbl,
940: p_trolin_val_tbl => l_trolin_val_tbl,
941: x_trolin_tbl => l_trolin_tbl,
942: x_trolin_val_tbl => l_trolin_val_tbl);
943:
944: IF l_return_status <> fnd_api.g_ret_sts_success THEN
945: GMI_RESERVATION_UTIL.PrintLn(' Create_Move_Order_Lines failed ');
946: GMI_RESERVATION_UTIL.PrintLn(l_msg_data);
947: FND_MSG_PUB.Count_AND_GET (p_count => l_msg_count, p_data => l_msg_data);
948: FOR i in 1..l_msg_count LOOP
979: p_app_short_name => 'INV');
980:
981: fnd_message.set_name('INV', 'INV_ERROR_CREATING_MO');
982: fnd_msg_pub.ADD;
983: RAISE fnd_api.g_exc_unexpected_error;
984: ELSE
985: GMI_RESERVATION_UTIL.PrintLn(' Create_move_order_lines succeeded - line_id : '|| to_char(l_trolin_tbl(l_order_count).line_id));
986:
987: /* Update OPM move order line attribute15 */
1006: WHERE line_id = l_line_id;
1007: GMI_RESERVATION_UTIL.PrintLn(' newly created move_order_line :-' || l_line_id);
1008: GMI_RESERVATION_UTIL.PrintLn(' locator_id updated to :- ' || l_to_locator_id);
1009:
1010: END IF; -- IF l_return_status <> fnd_api.g_ret_sts_success THEN
1011:
1012:
1013:
1014:
1099: , p_param2 => l_failure_count );
1100: end if; -- if L_FAILURE_COUNT < 1 THEN
1101:
1102: --Lets save the changes now based on the commit parameter
1103: IF p_commit = FND_API.G_TRUE THEN
1104: COMMIT;
1105: END IF;
1106:
1107: