cancel
Showing results for 
Search instead for 
Did you mean: 

Save batch in draft document

Former Member
0 Kudos

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);
 
        }
}
former_member233854
Active Contributor
0 Kudos

Does the error happens to add or to update the created draft?

Former Member
0 Kudos

When add. We can't add the stock transfer draft.

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

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

Former Member
0 Kudos

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.

Answers (1)

Answers (1)

Former Member
0 Kudos

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