1299:
1300:
1301: PROCEDURE insert_wip_move_txn
1302: (
1303: p_wip_move_txn_interface_rec IN wip_move_txn_interface%ROWTYPE,
1304: x_return_status OUT NOCOPY VARCHAR2
1305: )
1306: IS
1307:
1361: l_last_update_login := fnd_global.login_id;
1362:
1363:
1364:
1365: --insert into table wip_move_txn_interface
1366: BEGIN
1367: insert into wip_move_txn_interface(
1368: transaction_id,
1369: last_update_date,
1363:
1364:
1365: --insert into table wip_move_txn_interface
1366: BEGIN
1367: insert into wip_move_txn_interface(
1368: transaction_id,
1369: last_update_date,
1370: last_updated_by,
1371: last_updated_by_name,
1384: to_intraoperation_step_type,
1385: transaction_quantity,
1386: transaction_uom
1387: ) values (
1388: p_wip_move_txn_interface_rec.transaction_id,
1389: l_last_update_date, /* last_update_date */
1390: l_last_updated_by, /* last_updated_by */
1391: l_last_updated_by_name, /* last_updated_by_name */
1392: l_creation_date, /* creation_date */
1391: l_last_updated_by_name, /* last_updated_by_name */
1392: l_creation_date, /* creation_date */
1393: l_created_by, /* created_by */
1394: l_created_by_name, /* created_by_name */
1395: p_wip_move_txn_interface_rec.group_id, /* group_id */
1396: l_process_phase, /* process phase */
1397: l_process_status, /* process status */
1398: p_wip_move_txn_interface_rec.organization_id,
1399: p_wip_move_txn_interface_rec.wip_entity_name,
1394: l_created_by_name, /* created_by_name */
1395: p_wip_move_txn_interface_rec.group_id, /* group_id */
1396: l_process_phase, /* process phase */
1397: l_process_status, /* process status */
1398: p_wip_move_txn_interface_rec.organization_id,
1399: p_wip_move_txn_interface_rec.wip_entity_name,
1400: p_wip_move_txn_interface_rec.transaction_date,
1401: p_wip_move_txn_interface_rec.fm_operation_seq_num,
1402: p_wip_move_txn_interface_rec.fm_intraoperation_step_type,
1395: p_wip_move_txn_interface_rec.group_id, /* group_id */
1396: l_process_phase, /* process phase */
1397: l_process_status, /* process status */
1398: p_wip_move_txn_interface_rec.organization_id,
1399: p_wip_move_txn_interface_rec.wip_entity_name,
1400: p_wip_move_txn_interface_rec.transaction_date,
1401: p_wip_move_txn_interface_rec.fm_operation_seq_num,
1402: p_wip_move_txn_interface_rec.fm_intraoperation_step_type,
1403: p_wip_move_txn_interface_rec.to_operation_seq_num,
1396: l_process_phase, /* process phase */
1397: l_process_status, /* process status */
1398: p_wip_move_txn_interface_rec.organization_id,
1399: p_wip_move_txn_interface_rec.wip_entity_name,
1400: p_wip_move_txn_interface_rec.transaction_date,
1401: p_wip_move_txn_interface_rec.fm_operation_seq_num,
1402: p_wip_move_txn_interface_rec.fm_intraoperation_step_type,
1403: p_wip_move_txn_interface_rec.to_operation_seq_num,
1404: p_wip_move_txn_interface_rec.to_intraoperation_step_type,
1397: l_process_status, /* process status */
1398: p_wip_move_txn_interface_rec.organization_id,
1399: p_wip_move_txn_interface_rec.wip_entity_name,
1400: p_wip_move_txn_interface_rec.transaction_date,
1401: p_wip_move_txn_interface_rec.fm_operation_seq_num,
1402: p_wip_move_txn_interface_rec.fm_intraoperation_step_type,
1403: p_wip_move_txn_interface_rec.to_operation_seq_num,
1404: p_wip_move_txn_interface_rec.to_intraoperation_step_type,
1405: p_wip_move_txn_interface_rec.transaction_quantity,
1398: p_wip_move_txn_interface_rec.organization_id,
1399: p_wip_move_txn_interface_rec.wip_entity_name,
1400: p_wip_move_txn_interface_rec.transaction_date,
1401: p_wip_move_txn_interface_rec.fm_operation_seq_num,
1402: p_wip_move_txn_interface_rec.fm_intraoperation_step_type,
1403: p_wip_move_txn_interface_rec.to_operation_seq_num,
1404: p_wip_move_txn_interface_rec.to_intraoperation_step_type,
1405: p_wip_move_txn_interface_rec.transaction_quantity,
1406: p_wip_move_txn_interface_rec.transaction_uom
1399: p_wip_move_txn_interface_rec.wip_entity_name,
1400: p_wip_move_txn_interface_rec.transaction_date,
1401: p_wip_move_txn_interface_rec.fm_operation_seq_num,
1402: p_wip_move_txn_interface_rec.fm_intraoperation_step_type,
1403: p_wip_move_txn_interface_rec.to_operation_seq_num,
1404: p_wip_move_txn_interface_rec.to_intraoperation_step_type,
1405: p_wip_move_txn_interface_rec.transaction_quantity,
1406: p_wip_move_txn_interface_rec.transaction_uom
1407: );
1400: p_wip_move_txn_interface_rec.transaction_date,
1401: p_wip_move_txn_interface_rec.fm_operation_seq_num,
1402: p_wip_move_txn_interface_rec.fm_intraoperation_step_type,
1403: p_wip_move_txn_interface_rec.to_operation_seq_num,
1404: p_wip_move_txn_interface_rec.to_intraoperation_step_type,
1405: p_wip_move_txn_interface_rec.transaction_quantity,
1406: p_wip_move_txn_interface_rec.transaction_uom
1407: );
1408:
1401: p_wip_move_txn_interface_rec.fm_operation_seq_num,
1402: p_wip_move_txn_interface_rec.fm_intraoperation_step_type,
1403: p_wip_move_txn_interface_rec.to_operation_seq_num,
1404: p_wip_move_txn_interface_rec.to_intraoperation_step_type,
1405: p_wip_move_txn_interface_rec.transaction_quantity,
1406: p_wip_move_txn_interface_rec.transaction_uom
1407: );
1408:
1409:
1402: p_wip_move_txn_interface_rec.fm_intraoperation_step_type,
1403: p_wip_move_txn_interface_rec.to_operation_seq_num,
1404: p_wip_move_txn_interface_rec.to_intraoperation_step_type,
1405: p_wip_move_txn_interface_rec.transaction_quantity,
1406: p_wip_move_txn_interface_rec.transaction_uom
1407: );
1408:
1409:
1410: EXCEPTION
2475: -- lc_validation_phase CONSTANT NUMBER := 1;
2476:
2477:
2478:
2479: -- Constants used for inserting into wip_move_txn_interface
2480:
2481: lc_queue CONSTANT NUMBER := 1;
2482: lc_to_move CONSTANT NUMBER := 3;
2483: lc_error_process_status CONSTANT NUMBER := 3;
2482: lc_to_move CONSTANT NUMBER := 3;
2483: lc_error_process_status CONSTANT NUMBER := 3;
2484:
2485:
2486: -- Record to hold wip_move_txn_interface
2487:
2488: l_wip_move_txn_interface_rec wip_move_txn_interface%ROWTYPE;
2489:
2490:
2484:
2485:
2486: -- Record to hold wip_move_txn_interface
2487:
2488: l_wip_move_txn_interface_rec wip_move_txn_interface%ROWTYPE;
2489:
2490:
2491: /* l_process_phase NUMBER;
2492: l_material_transaction_id NUMBER; */
2509:
2510:
2511: Cursor check_mv_interface_errors ( c_group_id NUMBER ) IS
2512: select wip.wip_entity_name, mv.fm_operation_seq_num
2513: from wip_move_txn_interface mv, wip_entities wip
2514: where mv.group_id = c_group_id
2515: and mv.process_status = lc_error_process_status
2516: and mv.wip_entity_id = wip.wip_entity_id;
2517:
2573:
2574:
2575: -- generate transaction_id
2576: open get_transaction_id;
2577: -- fetch get_transaction_id into l_wip_move_txn_interface_rec.transaction_id;
2578: fetch get_transaction_id into l_wip_move_txn_interface_rec.group_id;
2579: close get_transaction_id;
2580:
2581: -- l_wip_move_txn_interface_rec.group_id := l_wip_move_txn_interface_rec.transaction_id;
2574:
2575: -- generate transaction_id
2576: open get_transaction_id;
2577: -- fetch get_transaction_id into l_wip_move_txn_interface_rec.transaction_id;
2578: fetch get_transaction_id into l_wip_move_txn_interface_rec.group_id;
2579: close get_transaction_id;
2580:
2581: -- l_wip_move_txn_interface_rec.group_id := l_wip_move_txn_interface_rec.transaction_id;
2582: l_wip_move_txn_interface_rec.transaction_date := sysdate;
2577: -- fetch get_transaction_id into l_wip_move_txn_interface_rec.transaction_id;
2578: fetch get_transaction_id into l_wip_move_txn_interface_rec.group_id;
2579: close get_transaction_id;
2580:
2581: -- l_wip_move_txn_interface_rec.group_id := l_wip_move_txn_interface_rec.transaction_id;
2582: l_wip_move_txn_interface_rec.transaction_date := sysdate;
2583: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_queue;
2584:
2585:
2578: fetch get_transaction_id into l_wip_move_txn_interface_rec.group_id;
2579: close get_transaction_id;
2580:
2581: -- l_wip_move_txn_interface_rec.group_id := l_wip_move_txn_interface_rec.transaction_id;
2582: l_wip_move_txn_interface_rec.transaction_date := sysdate;
2583: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_queue;
2584:
2585:
2586: -- swai: bug 5330060
2579: close get_transaction_id;
2580:
2581: -- l_wip_move_txn_interface_rec.group_id := l_wip_move_txn_interface_rec.transaction_id;
2582: l_wip_move_txn_interface_rec.transaction_date := sysdate;
2583: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_queue;
2584:
2585:
2586: -- swai: bug 5330060
2587: -- updated logic within for loop
2587: -- updated logic within for loop
2588: FOR mv_ctr in p_mv_txn_dtls_tbl.FIRST.. p_mv_txn_dtls_tbl.LAST
2589: LOOP
2590:
2591: l_wip_move_txn_interface_rec.organization_id := p_mv_txn_dtls_tbl(mv_ctr).organization_id;
2592: l_wip_move_txn_interface_rec.wip_entity_name := p_mv_txn_dtls_tbl(mv_ctr).wip_entity_name;
2593: l_wip_move_txn_interface_rec.transaction_uom := p_mv_txn_dtls_tbl(mv_ctr).transaction_uom;
2594: l_wip_move_txn_interface_rec.to_operation_seq_num := nvl(p_mv_txn_dtls_tbl(mv_ctr).to_operation_seq_num,
2595: p_mv_txn_dtls_tbl(mv_ctr).fm_operation_seq_num ) ;
2588: FOR mv_ctr in p_mv_txn_dtls_tbl.FIRST.. p_mv_txn_dtls_tbl.LAST
2589: LOOP
2590:
2591: l_wip_move_txn_interface_rec.organization_id := p_mv_txn_dtls_tbl(mv_ctr).organization_id;
2592: l_wip_move_txn_interface_rec.wip_entity_name := p_mv_txn_dtls_tbl(mv_ctr).wip_entity_name;
2593: l_wip_move_txn_interface_rec.transaction_uom := p_mv_txn_dtls_tbl(mv_ctr).transaction_uom;
2594: l_wip_move_txn_interface_rec.to_operation_seq_num := nvl(p_mv_txn_dtls_tbl(mv_ctr).to_operation_seq_num,
2595: p_mv_txn_dtls_tbl(mv_ctr).fm_operation_seq_num ) ;
2596: -- if the to operation seq is 0, then it's the last operation,
2589: LOOP
2590:
2591: l_wip_move_txn_interface_rec.organization_id := p_mv_txn_dtls_tbl(mv_ctr).organization_id;
2592: l_wip_move_txn_interface_rec.wip_entity_name := p_mv_txn_dtls_tbl(mv_ctr).wip_entity_name;
2593: l_wip_move_txn_interface_rec.transaction_uom := p_mv_txn_dtls_tbl(mv_ctr).transaction_uom;
2594: l_wip_move_txn_interface_rec.to_operation_seq_num := nvl(p_mv_txn_dtls_tbl(mv_ctr).to_operation_seq_num,
2595: p_mv_txn_dtls_tbl(mv_ctr).fm_operation_seq_num ) ;
2596: -- if the to operation seq is 0, then it's the last operation,
2597: -- make sure the to step type is to_move, otherwise, it's in queue.
2590:
2591: l_wip_move_txn_interface_rec.organization_id := p_mv_txn_dtls_tbl(mv_ctr).organization_id;
2592: l_wip_move_txn_interface_rec.wip_entity_name := p_mv_txn_dtls_tbl(mv_ctr).wip_entity_name;
2593: l_wip_move_txn_interface_rec.transaction_uom := p_mv_txn_dtls_tbl(mv_ctr).transaction_uom;
2594: l_wip_move_txn_interface_rec.to_operation_seq_num := nvl(p_mv_txn_dtls_tbl(mv_ctr).to_operation_seq_num,
2595: p_mv_txn_dtls_tbl(mv_ctr).fm_operation_seq_num ) ;
2596: -- if the to operation seq is 0, then it's the last operation,
2597: -- make sure the to step type is to_move, otherwise, it's in queue.
2598: if (p_mv_txn_dtls_tbl(mv_ctr).to_operation_seq_num is null) then
2595: p_mv_txn_dtls_tbl(mv_ctr).fm_operation_seq_num ) ;
2596: -- if the to operation seq is 0, then it's the last operation,
2597: -- make sure the to step type is to_move, otherwise, it's in queue.
2598: if (p_mv_txn_dtls_tbl(mv_ctr).to_operation_seq_num is null) then
2599: l_wip_move_txn_interface_rec.to_intraoperation_step_type := lc_to_move;
2600: else
2601: l_wip_move_txn_interface_rec.to_intraoperation_step_type := lc_queue;
2602: end if;
2603:
2597: -- make sure the to step type is to_move, otherwise, it's in queue.
2598: if (p_mv_txn_dtls_tbl(mv_ctr).to_operation_seq_num is null) then
2599: l_wip_move_txn_interface_rec.to_intraoperation_step_type := lc_to_move;
2600: else
2601: l_wip_move_txn_interface_rec.to_intraoperation_step_type := lc_queue;
2602: end if;
2603:
2604: -- if we are completing more than one operation for the same job, make
2605: -- the quantities are passed forward. Currently, do not allow the user
2609: FND_MESSAGE.SET_NAME('CSD','CSD_OP_COMP_SEQ_ERROR');
2610: FND_MSG_PUB.ADD;
2611: RAISE FND_API.G_EXC_ERROR;
2612: ELSE
2613: l_wip_move_txn_interface_rec.transaction_quantity := p_mv_txn_dtls_tbl(mv_ctr).transaction_quantity +
2614: l_prev_transaction_quantity;
2615: END IF;
2616: ELSE
2617: l_wip_move_txn_interface_rec.transaction_quantity := p_mv_txn_dtls_tbl(mv_ctr).transaction_quantity;
2613: l_wip_move_txn_interface_rec.transaction_quantity := p_mv_txn_dtls_tbl(mv_ctr).transaction_quantity +
2614: l_prev_transaction_quantity;
2615: END IF;
2616: ELSE
2617: l_wip_move_txn_interface_rec.transaction_quantity := p_mv_txn_dtls_tbl(mv_ctr).transaction_quantity;
2618: END IF;
2619:
2620: -- use the values passed in if there are items to be transacted. Otherwise,
2621: -- we will attempt to find the appropriate from operation with an item that
2619:
2620: -- use the values passed in if there are items to be transacted. Otherwise,
2621: -- we will attempt to find the appropriate from operation with an item that
2622: -- can be moved
2623: IF (l_wip_move_txn_interface_rec.transaction_quantity > 0) then
2624: l_wip_move_txn_interface_rec.fm_operation_seq_num := p_mv_txn_dtls_tbl(mv_ctr).fm_operation_seq_num;
2625: ELSE
2626: -- find the operation with a qty to complete, set the from operation to this
2627: open get_valid_previous_op (p_mv_txn_dtls_tbl(mv_ctr).wip_entity_id,
2620: -- use the values passed in if there are items to be transacted. Otherwise,
2621: -- we will attempt to find the appropriate from operation with an item that
2622: -- can be moved
2623: IF (l_wip_move_txn_interface_rec.transaction_quantity > 0) then
2624: l_wip_move_txn_interface_rec.fm_operation_seq_num := p_mv_txn_dtls_tbl(mv_ctr).fm_operation_seq_num;
2625: ELSE
2626: -- find the operation with a qty to complete, set the from operation to this
2627: open get_valid_previous_op (p_mv_txn_dtls_tbl(mv_ctr).wip_entity_id,
2628: p_mv_txn_dtls_tbl(mv_ctr).fm_operation_seq_num);
2626: -- find the operation with a qty to complete, set the from operation to this
2627: open get_valid_previous_op (p_mv_txn_dtls_tbl(mv_ctr).wip_entity_id,
2628: p_mv_txn_dtls_tbl(mv_ctr).fm_operation_seq_num);
2629: fetch get_valid_previous_op into
2630: l_wip_move_txn_interface_rec.fm_operation_seq_num,
2631: l_qty_in_queue,
2632: l_qty_to_move;
2633: close get_valid_previous_op;
2634:
2633: close get_valid_previous_op;
2634:
2635: -- depending on where the item is, set the qty and from step type accordingly.
2636: if l_qty_in_queue > 0 then
2637: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_queue;
2638: l_wip_move_txn_interface_rec.transaction_quantity := l_qty_in_queue;
2639: elsif (l_qty_to_move > 0) then
2640: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_to_move;
2641: l_wip_move_txn_interface_rec.transaction_quantity := l_qty_to_move;
2634:
2635: -- depending on where the item is, set the qty and from step type accordingly.
2636: if l_qty_in_queue > 0 then
2637: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_queue;
2638: l_wip_move_txn_interface_rec.transaction_quantity := l_qty_in_queue;
2639: elsif (l_qty_to_move > 0) then
2640: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_to_move;
2641: l_wip_move_txn_interface_rec.transaction_quantity := l_qty_to_move;
2642: end if;
2636: if l_qty_in_queue > 0 then
2637: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_queue;
2638: l_wip_move_txn_interface_rec.transaction_quantity := l_qty_in_queue;
2639: elsif (l_qty_to_move > 0) then
2640: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_to_move;
2641: l_wip_move_txn_interface_rec.transaction_quantity := l_qty_to_move;
2642: end if;
2643: END IF;
2644:
2637: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_queue;
2638: l_wip_move_txn_interface_rec.transaction_quantity := l_qty_in_queue;
2639: elsif (l_qty_to_move > 0) then
2640: l_wip_move_txn_interface_rec.fm_intraoperation_step_type := lc_to_move;
2641: l_wip_move_txn_interface_rec.transaction_quantity := l_qty_to_move;
2642: end if;
2643: END IF;
2644:
2645: -- set the variables to compare in the next loop iteration
2643: END IF;
2644:
2645: -- set the variables to compare in the next loop iteration
2646: l_prev_wip_entity_id := p_mv_txn_dtls_tbl(mv_ctr).wip_entity_id;
2647: l_prev_to_operation_seq_num := l_wip_move_txn_interface_rec.to_operation_seq_num;
2648: l_prev_transaction_quantity := l_wip_move_txn_interface_rec.transaction_quantity;
2649:
2650: --insert into table wip_move_txn_interface
2651: IF ( FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
2644:
2645: -- set the variables to compare in the next loop iteration
2646: l_prev_wip_entity_id := p_mv_txn_dtls_tbl(mv_ctr).wip_entity_id;
2647: l_prev_to_operation_seq_num := l_wip_move_txn_interface_rec.to_operation_seq_num;
2648: l_prev_transaction_quantity := l_wip_move_txn_interface_rec.transaction_quantity;
2649:
2650: --insert into table wip_move_txn_interface
2651: IF ( FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
2652: FND_LOG.STRING( FND_LOG.LEVEL_EVENT,
2646: l_prev_wip_entity_id := p_mv_txn_dtls_tbl(mv_ctr).wip_entity_id;
2647: l_prev_to_operation_seq_num := l_wip_move_txn_interface_rec.to_operation_seq_num;
2648: l_prev_transaction_quantity := l_wip_move_txn_interface_rec.transaction_quantity;
2649:
2650: --insert into table wip_move_txn_interface
2651: IF ( FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
2652: FND_LOG.STRING( FND_LOG.LEVEL_EVENT,
2653: lc_mod_name||'beforecallinsertwipmvtxn',
2654: 'Just before calling insert_wip_move_txn');
2653: lc_mod_name||'beforecallinsertwipmvtxn',
2654: 'Just before calling insert_wip_move_txn');
2655: END IF;
2656:
2657: insert_wip_move_txn( p_wip_move_txn_interface_rec => l_wip_move_txn_interface_rec,
2658: x_return_status => x_return_status );
2659:
2660: IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2661: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2676: 'Just before calling INV_TXN_MANAGER_PUB.process_Transactions');
2677: END IF;
2678:
2679: /*
2680: wip_movProc_grp.processInterface(p_movTxnID => l_wip_move_txn_interface_rec.transaction_id,
2681: p_procPhase => l_process_phase,
2682: p_txnHdrID => l_material_transaction_id,
2683: p_mtlMode => WIP_CONSTANTS.ONLINE,
2684: p_cplTxnID => NULL,
2687: x_errorMsg => x_msg_data);
2688:
2689: */
2690:
2691: wip_movProc_grp.processInterface(p_groupID => l_wip_move_txn_interface_rec.group_id,
2692: p_commit => FND_API.G_FALSE,
2693: x_returnStatus => x_return_status ) ;
2694:
2695: -- Need to get errors from error table and pass it back
2692: p_commit => FND_API.G_FALSE,
2693: x_returnStatus => x_return_status ) ;
2694:
2695: -- Need to get errors from error table and pass it back
2696: open check_mv_interface_errors ( l_wip_move_txn_interface_rec.group_id );
2697: fetch check_mv_interface_errors into l_err_wip_entity_name, l_err_op_seq_num;
2698:
2699: If (( x_return_status <> FND_API.G_RET_STS_SUCCESS) or
2700: (l_err_op_seq_num is not null)) THEN