PAC成本更新交易處理
DECLARE l_itfs_rec mtl_transactions_interface% ROWTYPE;BEGIN --插入介面表 SELECT mtl_material_transactions_s.nextval INTO l_txn_header_id FROM dual;
v_date := p_end_date - 1 || ' 06:00:00'; l_end_date := to_date(v_date, 'dd/mm/yy hh24:mi:ss'); l_itfs_rec.transaction_header_id := l_txn_header_id; l_itfs_rec.source_code := 'CUXPACIP'; l_itfs_rec.source_line_id := 0; l_itfs_rec.source_header_id := 0; l_itfs_rec.process_flag := 1; l_itfs_rec.transaction_mode := 2; l_itfs_rec.validation_required := 1; l_itfs_rec.transaction_type_id := 26; --固定 l_itfs_rec.transaction_source_type_id := 14; --固定 l_itfs_rec.organization_id := get_mst_organization_id; --主組織 SELECT cst.cost_type_id INTO l_itfs_rec.cost_type_id FROM cst_cost_types cst WHERE cst.cost_type = 'PAC'; --成本類型PAC l_itfs_rec.org_cost_group_id := l_cost_group_id; --組織成本組 l_itfs_rec.transaction_date := l_end_date; --交易處理日期 l_itfs_rec.inventory_item_id := rec_i.inventory_item_id; l_itfs_rec.transaction_quantity := 0; l_itfs_rec.transaction_uom := 'kg'; --物料主組織單位 --l_itfs_rec.new_average_cost := p_new_avg_cst;--新期間成本 --l_itfs_rec.percentage_change := p_percent_chage;--更改百分比
l_value_chage := 30; l_itfs_rec.value_change := l_value_chage; --庫存值更改 l_itfs_rec.material_account := l_ap_accrual_account; --物料賬戶 l_itfs_rec.material_overhead_account := l_ap_accrual_account; --物料間接費用賬戶 l_itfs_rec.resource_account := l_ap_accrual_account; --資源賬戶 l_itfs_rec.outside_processing_account := l_ap_accrual_account; --外協加工賬戶 l_itfs_rec.overhead_account := l_ap_accrual_account; --製造費用 --l_itfs_rec.reason_id := p_reason_id; --l_itfs_rec.transaction_reference := p_txn_ref; /* l_itfs_rec.attribute_category := p_att_cat; l_itfs_rec.attribute1 := p_att1; l_itfs_rec.attribute2 := p_att2; l_itfs_rec.attribute3 := p_att3; l_itfs_rec.attribute4 := p_att4; l_itfs_rec.attribute5 := p_att5; l_itfs_rec.attribute6 := p_att6; l_itfs_rec.attribute7 := p_att7; l_itfs_rec.attribute8 := p_att8; l_itfs_rec.attribute9 := p_att9; l_itfs_rec.attribute10 := p_att10; l_itfs_rec.attribute11 := p_att11; l_itfs_rec.attribute12 := p_att12; l_itfs_rec.attribute13 := p_att13; l_itfs_rec.attribute14 := p_att14; l_itfs_rec.attribute15 := p_att15;*/ --set who l_itfs_rec.created_by := g_user_id; l_itfs_rec.creation_date := SYSDATE; l_itfs_rec.last_updated_by := g_user_id; l_itfs_rec.last_update_date := SYSDATE; l_itfs_rec.last_update_login := g_login_id; l_itfs_rec.request_id := g_request_id; l_itfs_rec.program_id := g_prog_id; l_itfs_rec.program_application_id := g_prog_appl_id; l_itfs_rec.program_update_date := SYSDATE;
INSERT INTO mtl_transactions_interface VALUES l_itfs_rec;END LOOP ;--新增交易處理IF x_return_status = fnd_api.g_ret_sts_success THEN l_api_flag := inv_txn_manager_pub.process_transactions(p_api_version => 1.0, p_init_msg_list => fnd_api.g_false, p_commit => fnd_api.g_false, p_validation_level => fnd_api.g_valid_level_full, x_return_status => x_return_status, x_msg_count => x_msg_count, x_msg_data => x_msg_data, x_trans_count => l_api_trans_cnt, p_table => 1, p_header_id => l_txn_header_id); IF nvl(l_api_flag, -1 ) <> 0 OR nvl (x_return_status, 'X') <> 'S' THEN fnd_message.set_name( 'FND', 'FND_GENERIC_MESSAGE' ); fnd_message.set_token( 'MESSAGE', '成本更新失敗' ); fnd_msg_pub.add; fnd_message.set_name( 'FND', 'FND_GENERIC_MESSAGE' ); fnd_message.set_token( 'MESSAGE', 'x_return_status : ' || x_return_status); fnd_msg_pub.add; fnd_message.set_name( 'FND', 'FND_GENERIC_MESSAGE' ); fnd_message.set_token( 'MESSAGE', 'x_msg_data : ' || x_msg_data); fnd_msg_pub.add; RAISE fnd_api.g_exc_error; --RAISE e_itfs_fail; END IF;END IF ;END;