PROCEDURE process_rcv_online(p_api_version IN NUMBER, p_init_msg_list IN VARCHAR2 DEFAULT fnd_api.g_false, p_commit IN VARCHAR2 DEFAULT fnd_api.g_false, x_return_status OUT NOCOPY VARCHAR2, x_msg_count OUT NOCOPY NUMBER, x_msg_data OUT NOCOPY VARCHAR2, p_group_id IN NUMBER) IS l_api_name CONSTANT VARCHAR2(30) := 'process_rcv_online'; l_api_version CONSTANT NUMBER := 1.0; l_return_code NUMBER := 0; --** E_SUCCESS constant number := 0; -- e_code is success --** E_TIMEOUT constant number := 1; -- e_code is timeout --** E_NOMGR constant number := 2; -- e_code is no manager --** E_OTHER constant number := 3; -- e_code is other l_timeout NUMBER := fnd_profile.VALUE('INV_RPC_TIMEOUT'); -- 1分钟 l_outcome VARCHAR2(200); l_message VARCHAR2(200); l_str VARCHAR2(4000); r_val1 VARCHAR2(200) := NULL; r_val2 VARCHAR2(200) := NULL; r_val3 VARCHAR2(200) := NULL; r_val4 VARCHAR2(200) := NULL; r_val5 VARCHAR2(200) := NULL; r_val6 VARCHAR2(200) := NULL; r_val7 VARCHAR2(200) := NULL; r_val8 VARCHAR2(200) := NULL; r_val9 VARCHAR2(200) := NULL; r_val10 VARCHAR2(200) := NULL; r_val11 VARCHAR2(200) := NULL; r_val12 VARCHAR2(200) := NULL; r_val13 VARCHAR2(200) := NULL; r_val14 VARCHAR2(200) := NULL; r_val15 VARCHAR2(200) := NULL; r_val16 VARCHAR2(200) := NULL; r_val17 VARCHAR2(200) := NULL; r_val18 VARCHAR2(200) := NULL; r_val19 VARCHAR2(200) := NULL; r_val20 VARCHAR2(200) := NULL; l_rec_count NUMBER; BEGIN -- start activity to savepoint, check compatibility -- and initialize message list, include debug message hint to enter api x_return_status := cux_api.start_activity(p_pkg_name => g_pkg_name, p_api_name => l_api_name, p_api_type => g_api_type, p_init_msg_list => p_init_msg_list, l_api_version => l_api_version, p_api_version => p_api_version); -- check if activity started successfully IF (x_return_status = fnd_api.g_ret_sts_unexp_error) THEN RAISE fnd_api.g_exc_unexpected_error; ELSIF (x_return_status = fnd_api.g_ret_sts_error) THEN RAISE fnd_api.g_exc_error; END IF; IF l_debug = 'Y' THEN cux_debug.log('p_group_id' || p_group_id); END IF; SELECT COUNT(*) INTO l_rec_count FROM rcv_transactions_interface t WHERE t.group_id = p_group_id; IF l_debug = 'Y' THEN cux_debug.log('l_rec_count :' || l_rec_count); END IF; -- API body IF l_timeout IS NULL THEN l_timeout := 300; END IF; l_return_code := fnd_transaction.synchronous(timeout => l_timeout, outcome => l_outcome, message => l_message, application => 'PO', program => 'RCVTPO', arg_1 => 'ONLINE', arg_2 => p_group_id); IF l_debug = 'Y' THEN cux_debug.log('l_return_code =' || l_return_code); cux_debug.log('l_outcome =' || l_outcome); cux_debug.log('l_message =' || l_message); END IF; IF (l_return_code = 0 AND (l_outcome NOT IN ('WARNING', 'ERROR'))) THEN -- 成功 IF l_debug = 'Y' THEN cux_debug.log('fnd_transaction.synchronous success'); END IF; delete_rcv_interface(p_group_id); ELSIF l_return_code = 1 THEN IF check_group_id(p_group_id) THEN fnd_message.set_name('FND', 'TM-TIMEOUT'); l_str := fnd_message.get; IF l_debug = 'Y' THEN cux_debug.log('l_str =' || l_str); END IF; -- fnd_message.clear; fnd_message.set_name(application => 'FND', NAME => 'CONC-Error running standalone'); fnd_message.set_token(token => 'PROGRAM', VALUE => 'Receiving Transaction Manager - RCVOLTM'); fnd_message.set_token(token => 'REQUEST', VALUE => p_group_id); fnd_message.set_token(token => 'REASON', VALUE => l_str); fnd_msg_pub.add; RAISE fnd_api.g_exc_error; END IF; ELSIF l_return_code = 2 THEN IF check_group_id(p_group_id) THEN fnd_message.set_name('FND', 'TM-SVC LOCK HANDLE FAILED'); l_str := fnd_message.get; fnd_message.clear; fnd_message.set_name(application => 'FND', NAME => 'CONC-Error running standalone'); fnd_message.set_token(token => 'PROGRAM', VALUE => 'Receiving Transaction Manager - RCVOLTM'); fnd_message.set_token(token => 'REQUEST', VALUE => p_group_id); fnd_message.set_token(token => 'REASON', VALUE => l_str); fnd_msg_pub.add; RAISE fnd_api.g_exc_error; END IF; ELSIF (l_return_code = 3 OR (l_outcome IN ('WARNING', 'ERROR'))) THEN IF check_group_id(p_group_id) THEN l_return_code := fnd_transaction.get_values(r_val1, r_val2, r_val3, r_val4, r_val5, r_val6, r_val7, r_val8, r_val9, r_val10, r_val11, r_val12, r_val13, r_val14, r_val15, r_val16, r_val17, r_val18, r_val19, r_val20); l_str := r_val1; IF (r_val2 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val2; END IF; IF (r_val3 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val3; END IF; IF (r_val4 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val4; END IF; IF (r_val5 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val5; END IF; IF (r_val6 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val6; END IF; IF (r_val7 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val7; END IF; IF (r_val8 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val8; END IF; IF (r_val9 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val9; END IF; IF (r_val10 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val10; END IF; IF (r_val11 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val11; END IF; IF (r_val12 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val12; END IF; IF (r_val13 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val13; END IF; IF (r_val14 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val14; END IF; IF (r_val15 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val15; END IF; IF (r_val16 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val16; END IF; IF (r_val17 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val17; END IF; IF (r_val18 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val18; END IF; IF (r_val19 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val19; END IF; IF (r_val20 IS NOT NULL) THEN l_str := l_str || chr(10) || r_val20; END IF; IF l_debug = 'Y' THEN cux_debug.log('error or warnning '); cux_debug.log('l_str =' || l_str); END IF; SELECT COUNT(*) INTO l_rec_count FROM po_interface_errors t WHERE t.batch_id = p_group_id; IF l_debug = 'Y' THEN cux_debug.log('errors count :' || l_rec_count); END IF; cux_api.set_message('CUX', 'CUX_TXN_SHIP_RCV_UNEXP', 'MESSAGE', l_str); RAISE fnd_api.g_exc_error; END IF; -- API end body ELSE l_str := fnd_message.get; IF l_debug = 'Y' THEN cux_debug.log('l_str =' || l_str); END IF; cux_api.set_message('CUX', 'CUX_TXN_SHIP_RCV_UNEXP', 'MESSAGE', l_str); RAISE fnd_api.g_exc_error; END IF; -- end activity, include debug message hint to exit api cux_api.end_activity(p_pkg_name => g_pkg_name, p_api_name => l_api_name, p_commit => p_commit, x_msg_count => x_msg_count, x_msg_data => x_msg_data); EXCEPTION WHEN fnd_api.g_exc_error THEN delete_rcv_interface(p_group_id); x_return_status := cux_api.handle_exceptions(p_pkg_name => g_pkg_name, p_api_name => l_api_name, p_api_type => g_api_type, p_exc_name => cux_api.g_exc_name_error, x_msg_count => x_msg_count, x_msg_data => x_msg_data); WHEN fnd_api.g_exc_unexpected_error THEN delete_rcv_interface(p_group_id); x_return_status := cux_api.handle_exceptions(p_pkg_name => g_pkg_name, p_api_name => l_api_name, p_api_type => g_api_type, p_exc_name => cux_api.g_exc_name_unexp, x_msg_count => x_msg_count, x_msg_data => x_msg_data); WHEN OTHERS THEN delete_rcv_interface(p_group_id); x_return_status := cux_api.handle_exceptions(p_pkg_name => g_pkg_name, p_api_name => l_api_name, p_api_type => g_api_type, p_exc_name => cux_api.g_exc_name_others, x_msg_count => x_msg_count, x_msg_data => x_msg_data); END process_rcv_online;