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;--更改百分比
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_