Архив

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

OEBS API INV: Создание заказа на перемещение

Пример использования API для создания заказа на перемещение

declare 
  lx_doc_hdr    inv_move_order_pub.Trohdr_Rec_Type;
  lx_doc_lines  inv_move_order_pub.Trolin_Tbl_Type;    
  --
  lx_doc_hdr_vals   inv_move_order_pub.Trohdr_Val_Rec_Type;
  lx_doc_lines_vals inv_move_order_pub.Trolin_Val_Tbl_Type;
  lx_return_status  varchar2(1);
  lx_msg_data       varchar2(4000);
  lx_msg_count      number;
begin
  -- тип заказа на перемещение = заявка
  lx_doc_hdr.move_order_type        := inv_globals.G_MOVE_ORDER_REQUISITION;
  lx_doc_hdr.organization_id        := 1775;
  lx_doc_hdr.date_required          := sysdate;
  
  lx_doc_hdr.operation              := inv_globals.G_OPR_CREATE;
  lx_doc_hdr.header_status          := inv_globals.G_TO_STATUS_PREAPPROVED;
    
  -- создание заголовка заказа на перемещение
  inv_move_order_pub.create_move_order_header(
    p_api_version_number => 1,
    p_init_msg_list      => fnd_api.G_TRUE,
    p_return_values      => fnd_api.G_TRUE,
    p_commit             => fnd_api.G_FALSE,
    x_return_status      => lx_return_status,
    x_msg_count          => lx_msg_count,
    x_msg_data           => lx_msg_data,
    p_trohdr_rec         => lx_doc_hdr,
    p_trohdr_val_rec     => lx_doc_hdr_vals,
    x_trohdr_rec         => lx_doc_hdr,
    x_trohdr_val_rec     => lx_doc_hdr_vals
  );
  
  dbms_output.put_line('create_move_order_header='||lx_return_status);
  dbms_output.put_line('header_id='||lx_doc_hdr.header_id);

  if (lx_return_status!='S') then
    FOR j IN 1 .. lx_msg_count LOOP
      dbms_output.put_line('error('||j||')= ' ||fnd_msg_pub.get(j,fnd_api.g_false));
    END LOOP;  
  else

    lx_doc_lines(1).header_id      := lx_doc_hdr.header_id;
    
    lx_doc_lines(1).operation      := inv_globals.G_OPR_CREATE;
    lx_doc_lines(1).line_status    := inv_globals.G_TO_STATUS_PREAPPROVED;
    lx_doc_lines(1).date_required  := sysdate;       
    lx_doc_lines(1).status_date    := sysdate;
    -- 64 Перенос заказа на перемещение    
    lx_doc_lines(1).transaction_type_id := inv_globals.g_type_transfer_order_subxfr;
    --
    lx_doc_lines(1).from_subinventory_code := 'ttttttt';
    lx_doc_lines(1).organization_id        := 1775;
    lx_doc_lines(1).to_subinventory_code   := 'fffffff';      
    lx_doc_lines(1).to_organization_id     := 1775;
          
    lx_doc_lines(1).inventory_item_id      := 57878;
    lx_doc_lines(1).uom_code               := 'шт'; 
    lx_doc_lines(1).quantity               := 5;    
    
    -- создание строки заказа на перемещение
    inv_move_order_pub.create_move_order_lines(
      p_api_version_number       => 1,
      p_init_msg_list            => fnd_api.G_TRUE,
      p_return_values            => fnd_api.G_TRUE,      
      p_commit                   => fnd_api.G_FALSE,
      x_return_status            => lx_return_status,
      x_msg_count                => lx_msg_count,
      x_msg_data                 => lx_msg_data,
      p_trolin_tbl               => lx_doc_lines,
      p_trolin_val_tbl           => lx_doc_lines_vals,
      x_trolin_tbl               => lx_doc_lines,
      x_trolin_val_tbl           => lx_doc_lines_vals
    );    
    
    dbms_output.put_line('create_move_order_lines='||lx_return_status);
    if (lx_return_status!='S') then
      FOR j IN 1 .. lx_msg_count LOOP
        dbms_output.put_line('error('||j||')='||fnd_msg_pub.get(j,fnd_api.g_false));
      END LOOP;  
    else
      dbms_output.put_line('line_id='||lx_doc_lines(1).line_id);      
    end if;    

  end if;
  
end;

Модуль INV — Текущее количество для позиции

Select moq.organization_id                   as org_id,
       sysdate                               as date_val,
       moq.inventory_item_id                 as item_id,
       moq.subinventory_code                 as subinventory_code,
       moq.locator_id                        as locator_id,
       moq.lot_number                        as lot_number,
       msi.segment1                          as item,
       msi.primary_uom_code                  as uom_code,
       sum(moq.primary_transaction_quantity) as actual_qty
  from mtl_onhand_quantities_detail moq,
       mtl_system_items_b           msi
where 1=1
      -- msi
      and msi.inventory_item_id  = moq.inventory_item_id
      and msi.organization_id    = moq.organization_id
      --and moq.inventory_item_id  = :1
      --and moq.organization_id    = :2
      --and moq.subinventory_code  = :3
      --and moq.lot_number         = :4
group by moq.organization_id ,
         sysdate,
         moq.inventory_item_id,
         msi.segment1,
         msi.primary_uom_code,
         moq.subinventory_code,
         moq.locator_id,
         moq.lot_number
order by moq.organization_id, moq.inventory_item_id

Так же есть API для просмотра текущего количества OEBS API INV – Текущее количество для позиции (ONHAND)