Архив

Публикации с меткой ‘delete_reservation’

OEBS API INV – Удаление резервирований для позиции

10 Декабрь 2014 Нет комментариев

Пример использования API для удаления резервирований позиции:

declare
  l_rsv_rec                inv_reservation_global.mtl_reservation_rec_type;
  l_serial_number_tbl_type inv_reservation_global.serial_number_tbl_type;
  --
  lx_return_status varchar2(1);
  lx_msg_data      varchar2(4000);
  lx_msg_count     number;
begin
  fnd_global.apps_initialize(-1, 20634, 401); --Запасы - Запасы
  for i_cur in (select * from mtl_reservations t
                where 1=1
                      and rownum=1
                      -- and ...
           )
  loop
    l_rsv_rec.reservation_id               := i_cur.reservation_id;
    l_rsv_rec.organization_id              := i_cur.organization_id;          
    l_rsv_rec.inventory_item_id            := i_cur.inventory_item_id;
    l_rsv_rec.demand_source_type_id        := i_cur.demand_source_type_id; 
    l_rsv_rec.demand_source_header_id      := i_cur.demand_source_header_id; 
    l_rsv_rec.demand_source_line_id        := i_cur.demand_source_line_id;  
    l_rsv_rec.primary_uom_code             := i_cur.primary_uom_code;    
    l_rsv_rec.reservation_uom_code         := i_cur.reservation_uom_code;       
  -- l_rsv_rec.reservation_quantity         := 1;--i_cur.reservation_quantity;     
  -- l_rsv_rec.primary_reservation_quantity := 1;--i_cur.primary_reservation_quantity;
    l_rsv_rec.supply_source_type_id        := i_cur.supply_source_type_id;
        
    inv_reservation_pub.delete_reservation(p_api_version_number => 1.0
                                          ,p_rsv_rec            => l_rsv_rec
                                          ,p_serial_number      => l_serial_number_tbl_type
                                          ,x_return_status      => lx_return_status
                                          ,x_msg_count          => lx_msg_count 
                                          ,x_msg_data           => lx_msg_data
                                          );
                                          
    dbms_output.put_line(lx_return_status);   
    if (lx_return_status <> 'S') then    
      fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,                               
                                p_count   => lx_msg_count,                               
                                p_data    => lx_msg_data);       
      dbms_output.put_line('ERROR delete_reservation for reservation_id ='
                           ||l_rsv_rec.reservation_id ||':');       
      if lx_msg_count = 1 then      
        dbms_output.put_line(lx_msg_data);    
      else      
        FOR i IN 1 .. lx_msg_count 
        LOOP         
          dbms_output.put_line(fnd_msg_pub.get(fnd_msg_pub.g_next,fnd_api.g_false));
        END LOOP;     
      end if; 
    end if;
    commit;        
  end loop;                                  
                                          
end;