Hi,
When you add document you first have to check if the item in the document row have sufficient batchNumber and batchquantity, if you have this quantityBatch add the document via DI normally
But in the lines you have to set the exat batchnumber and batcquantity for each item.
maybe this help you
For i = 0 to orderrow.count -1 do
oOrd.Lines.SetCurrentLine(i)
oOrd.Lines.ItemCode=....
oOrd.Lines.Price=...
....
......
j=0
'''''Repeat until item quantity is satisfy by batch quantity(you can have 1 batcnumber or more)
For batchnumberofItem in (OBTNjoinOBTQwithqnty>0) do
oOrd.Lines.BatchNumbers.SetCurrentLine(j)
oOrd.Lines.BatchNumbers.BatchNumber = BatchNumber
oOrd.Lines.BatchNumbers.Quantity = Quantity
oOrd.Lines.BatchNumbers.Add()
oOrd.Lines.Quantity = oOrd.Lines.Quantity + oOrd.Lines.BatchNumbers.Quantity
j+=1
next batchnumberofItem
oOrd.Lines.Add()
Next i
Regards, Alessandro