cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Batch for an Item in AR Invoice using DI API

former_member458725
Active Participant
0 Kudos

Hi All,

I am trying add an AR Invoice with two item. Both Item have two batch to select,

Item code          Qty

ITM0001            160

ITM0002              90

for  ITEM001 - >      Batch  X001 -> Qty 5

                                        X002 -> Qty 155

     ITM002     ->     Batch  Z001 -> Qty  60

                                        z002 -> Qty 60

How to post invoice using DI API with the batches selected with BIN Location properly.

Please provide sample code, if possible.

Thank You

Accepted Solutions (0)

Answers (1)

Answers (1)

maik_delly
Active Contributor
0 Kudos

Hi Vibin,

the following code is working for me :


SAPbobsCOM.Documents oInvoice = SBO_Company.GetBusinessObject(BoObjectTypes.oInvoices);

oInvoice.CardCode = "C20000";

oInvoice.DocDueDate = DateTime.Today;

oInvoice.Lines.ItemCode = "ITM0001";

oInvoice.Lines.Quantity = 160;

oInvoice.Lines.WarehouseCode = "05";

oInvoice.Lines.BatchNumbers.BatchNumber = "X001";

oInvoice.Lines.BatchNumbers.Quantity = 5;

oInvoice.Lines.BatchNumbers.Add();

oInvoice.Lines.BatchNumbers.BatchNumber = "X002";

oInvoice.Lines.BatchNumbers.Quantity = 155;

oInvoice.Lines.BinAllocations.BinAbsEntry = 1;

oInvoice.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 0;

oInvoice.Lines.BinAllocations.Quantity = 5;

oInvoice.Lines.BinAllocations.Add();

oInvoice.Lines.BinAllocations.BinAbsEntry = 1;

oInvoice.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 1;

oInvoice.Lines.BinAllocations.Quantity = 155;

oInvoice.Lines.Add();

oInvoice.Lines.ItemCode = "ITM0002";

oInvoice.Lines.Quantity = 90;

oInvoice.Lines.WarehouseCode = "05";

oInvoice.Lines.BatchNumbers.BatchNumber = "Z001";

oInvoice.Lines.BatchNumbers.Quantity = 60;

oInvoice.Lines.BatchNumbers.Add();

oInvoice.Lines.BatchNumbers.BatchNumber = "Z002";

oInvoice.Lines.BatchNumbers.Quantity = 30;

oInvoice.Lines.BinAllocations.BinAbsEntry = 1;

oInvoice.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 0;

oInvoice.Lines.BinAllocations.Quantity = 60;

oInvoice.Lines.BinAllocations.Add();

oInvoice.Lines.BinAllocations.BinAbsEntry = 1;

oInvoice.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 1;

oInvoice.Lines.BinAllocations.Quantity = 30;

if (oInvoice.Add() != 0)

{

    MessageBox.Show("Error : "+SBO_Company.GetLastErrorDescription());

}

else

    MessageBox.Show("Success");

The important thing is that all quantities add up and bin allocations reference the correct batches.

regards,

Maik