Oracle EBS OPM 子库存转移

	
--子库存转移
--created by jenrry
DECLARE

  l_mtl_txn_rec              mtl_transactions_interface%ROWTYPE;
  l_mtl_txn_lot_rec          mtl_transaction_lots_interface%ROWTYPE;
  l_transaction_interface_id NUMBER;
  l_transaction_header_id    NUMBER;
  x_retval                   NUMBER;
  x_return_status            varchar2(20);
  x_msg_data                 varchar2(2000);
  x_trans_count              NUMBER;
  l_user_id                  NUMBER := 0;
  x_msg_count                number;

BEGIN
  sELECT mtl_material_transactions_s.nextval
    INTO l_transaction_header_id
    FROM dual;

  SELECT mtl_material_transactions_s.nextval
    INTO l_transaction_interface_id
    FROM dual;

  l_mtl_txn_rec.transaction_interface_id := l_transaction_interface_id;
  l_mtl_txn_rec.process_flag             := 1;
  l_mtl_txn_rec.transaction_mode         := 3;
  l_mtl_txn_rec.source_code              := 'WOW';
  l_mtl_txn_rec.source_header_id         := 987654321;
  l_mtl_txn_rec.source_line_id           := 987654321;
  l_mtl_txn_rec.transaction_date         := SYSDATE;
  l_mtl_txn_rec.transaction_type_id      := 2;
  l_mtl_txn_rec.transaction_header_id    := l_transaction_header_id;

  l_mtl_txn_rec.inventory_item_id := 623;
  l_mtl_txn_rec.organization_id   := 127;
  l_mtl_txn_rec.subinventory_code := 'Y02';
  l_mtl_txn_rec.transaction_uom   := '个';
  l_mtl_txn_rec.locator_id        := 3;

  l_mtl_txn_rec.transaction_action_id := 2;

  l_mtl_txn_rec.transfer_subinventory          := 'Y01';
  l_mtl_txn_rec.transfer_locator               := 1;
  l_mtl_txn_rec.transaction_quantity           := 1;
  l_mtl_txn_rec.secondary_uom_code             := '个';
  l_mtl_txn_rec.secondary_transaction_quantity := 1;

  l_mtl_txn_rec.last_update_date  := SYSDATE;
  l_mtl_txn_rec.last_updated_by   := l_user_id;
  l_mtl_txn_rec.creation_date     := SYSDATE;
  l_mtl_txn_rec.created_by        := l_user_id;
  l_mtl_txn_rec.last_update_login := l_user_id;
  INSERT INTO mtl_transactions_interface VALUES l_mtl_txn_rec;

  l_mtl_txn_lot_rec.transaction_interface_id := l_transaction_interface_id;
  l_mtl_txn_lot_rec.lot_number               := '201308-001';
  l_mtl_txn_lot_rec.transaction_quantity     := 1;
  l_mtl_txn_lot_rec.source_code              := 'WOW';
  l_mtl_txn_lot_rec.source_line_id           := 987654321;
  l_mtl_txn_lot_rec.last_update_date         := SYSDATE;
  l_mtl_txn_lot_rec.last_updated_by          := l_user_id;
  l_mtl_txn_lot_rec.creation_date            := SYSDATE;
  l_mtl_txn_lot_rec.created_by               := l_user_id;
  l_mtl_txn_lot_rec.last_update_login        := l_user_id;

  INSERT INTO mtl_transaction_lots_interface VALUES l_mtl_txn_lot_rec;
  x_retval := inv_txn_manager_pub.process_transactions(p_api_version      => 1.0,
                                                       p_init_msg_list    => fnd_api.g_true,
                                                       p_commit           => fnd_api.g_false, --not commit
                                                       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      => x_trans_count,
                                                       p_table            => 1,
                                                       p_header_id        => l_transaction_header_id);
  IF x_retval = -1 THEN
    dbms_output.put_line('Failed to process the transaction');
    dbms_output.put_line('Error code: ' || x_return_status);
    dbms_output.put_line('Error message: ' || x_msg_data);
  else
   dbms_output.put_line('x_return_status: ' || x_return_status);
  end if;
END;

  

posted on 2018-11-26 16:30  Jenrry  阅读(776)  评论(0编辑  收藏  举报