Skip to Content
0

Save batch in draft document

Aug 07, 2017 at 04:11 PM

171

avatar image

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);
 
        }
}
10 |10000 characters needed characters left characters exceeded

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

0

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

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
ANKIT CHAUHAN
Aug 10, 2017 at 01:21 PM
1

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

Show 1 Share
10 |10000 characters needed characters left 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.

0
Marton Kiraly Aug 16, 2017 at 09:53 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded