Skip to Content

Save batch in draft document

Hi,

We try to create a draft stocktransfer with batches without success. We tried to create or update but the answer always is "DIAPI Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)"

We tried to add new draft, update existing draft without success.

Our code is:

protected override COMOperationResult OnExecute(Company company)
        {
            SAPbobsCOM.StockTransfer oStockTransferDraft = company.GetBusinessObject(BoObjectTypes.oStockTransferDraft);
            oStockTransferDraft.DocObjectCode = BoObjectTypes.oStockTransfer;
 
            string fromWarehouse = "KOZPONT";
            string toWarehouse = "DOLGOZO";
            int toBinlocation = 26;
 
            string itemCode = "111462";
 
            //string itemCode = "111058";
 
            string batch = "64191K";
            int quantity = 1;
            string projectCode = "DESIGN";
 
            try
            {
                oStockTransferDraft.FromWarehouse = fromWarehouse;
                oStockTransferDraft.ToWarehouse = toWarehouse;
 
                oStockTransferDraft.DocDate = DateTime.Now;
 
                oStockTransferDraft.Lines.ItemCode = itemCode;
                oStockTransferDraft.Lines.FromWarehouseCode = fromWarehouse;
 
                oStockTransferDraft.Lines.WarehouseCode = toWarehouse;
                oStockTransferDraft.Lines.Quantity = quantity;
                oStockTransferDraft.Lines.ProjectCode = projectCode;
 
                oStockTransferDraft.Lines.BatchNumbers.BaseLineNumber = 0;
                oStockTransferDraft.Lines.BatchNumbers.Quantity = 0;
                oStockTransferDraft.Lines.BatchNumbers.BatchNumber = batch;
 
                //oStockTransferDraft.Lines.BinAllocations.BinActionType = SAPbobsCOM.BinActionTypeEnum.batToWarehouse;
                //oStockTransferDraft.Lines.BinAllocations.BinAbsEntry = toBinlocation;
                //oStockTransferDraft.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 0;
                //oStockTransferDraft.Lines.BinAllocations.Quantity = 1;
                //oStockTransferDraft.Lines.BinAllocations.Add();
 
                oStockTransferDraft.Lines.BatchNumbers.Add();
 
                //oStockTransferDraft.Lines.BatchNumbers.BatchNumber = batch;
                //oStockTransferDraft.Lines.BatchNumbers.Quantity = quantity;
                oStockTransferDraft.Lines.Add();
                int lRetCode = oStockTransferDraft.Add();
                Console.WriteLine(lRetCode + " " + company.GetLastErrorDescription());
 
                SAPbobsCOM.Documents created = company.GetBusinessObject(BoObjectTypes.oDrafts);
                created.DocObjectCode = BoObjectTypes.oStockTransfer;
                created.GetByKey(1405);
 
                created.Lines.BaseType = 67;
                created.Lines.BatchNumbers.BaseLineNumber = 0;
                //created.Lines.BatchNumbers.Quantity = 1;
                created.Comments = "asdd";
                created.Lines.BatchNumbers.BatchNumber = batch;
                created.Update();
 
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return new COMOperationResult(null);
 
        }
}
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Aug 10, 2017 at 01:21 PM

    Hi Marton,

    It appears that you are having the same scenario as mentioned in SAP Note 2442090. In order to resolve the issue, please check the same on SAP Business One Version 9.2 PL08 or higher.

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks your answer.

      We upgraded the database and tested. The RPC server failure is solved, we can save the batches, but we still do not can save the bins in draft. The productive document is still work. So we are closer with the draft but not there.

  • Aug 16, 2017 at 09:53 AM

    Or code now is:

    It's work as final but not work with draft.

    SAPbobsCOM.StockTransfer oStockTransferDraft = company.GetBusinessObject(BoObjectTypes.oStockTransferDraft);
                oStockTransferDraft.DocObjectCode = BoObjectTypes.oStockTransfer;
    
    
                string fromWarehouse = "KOZPONT";
                string toWarehouse = "DOLGOZO";
                int toBinlocation = 25;
                string itemCode = "111462";
                string batch = "456";
                int quantity = 1;
                string projectCode = "DESIGN";
    
    
                try
                { 
                    oStockTransferDraft.FromWarehouse = fromWarehouse;
                    oStockTransferDraft.ToWarehouse = toWarehouse;
    
                    oStockTransferDraft.DocDate = DateTime.Now;
    
                    oStockTransferDraft.Lines.ItemCode = itemCode;
                    oStockTransferDraft.Lines.FromWarehouseCode = fromWarehouse;
    
                    oStockTransferDraft.Lines.WarehouseCode = toWarehouse;
                    oStockTransferDraft.Lines.Quantity = quantity;
                    oStockTransferDraft.Lines.ProjectCode = projectCode;
    
                    oStockTransferDraft.Lines.BatchNumbers.BatchNumber = batch;
                    oStockTransferDraft.Lines.BatchNumbers.Quantity = quantity;
                    oStockTransferDraft.Lines.BatchNumbers.Add();
    
                    oStockTransferDraft.Lines.BinAllocations.BinActionType = SAPbobsCOM.BinActionTypeEnum.batToWarehouse;
                    oStockTransferDraft.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 0;
                    oStockTransferDraft.Lines.BinAllocations.BinAbsEntry = toBinlocation;
                    oStockTransferDraft.Lines.BinAllocations.Quantity = quantity;
                    oStockTransferDraft.Lines.BinAllocations.Add();
    
                    oStockTransferDraft.Lines.Add();
                    int lRetCode = oStockTransferDraft.Add();
                    Console.WriteLine(lRetCode + " " + company.GetLastErrorDescription());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
    

    The error is:

    -‎5002 1470000465 You cannot allocate bin locations in document row 1

    Add comment
    10|10000 characters needed characters exceeded