Skip to Content
0
Former Member
Jan 12, 2011 at 09:30 AM

Adding a new item to an already existing BOM

292 Views

Hi,

I am having a problem adding a new item to an already existing parent BOM.I excute the following code (as per the SDK).

Dim vProdTree As SAPbobsCOM.ProductTrees

Set vProdTree = vCmp.GetBusinessObject(oProductTrees)

'Set Values to the fields

vProdTree.TreeCode = "Item1"

vProdTree.TreeType = iProductionTree

'Set Values to the Assembly parts of the

'First Assembly

vProdTree.Items.ItemCode = Excel.Row(Cell1)

vProdTree.Items.Price = 20

vProdTree.Items.Quantity = 1

vProdTree.Items.Currency = "Eur"

'Adding the Product Tree

RetVal = vProdTree.Add

If (RetVal <> 0) Then

vCmp.GetLastError ErrCode, ErrMsg

MsgBox ErrCode & " " & ErrMsg

End If

If there is no parent BOM production tree with keycode Item1, then when the above code is run for the first time, it works.The issue occurs when I run change my excel, Cell1 to a different value and run the program again. The error states that the code already exists, which is correct, but does not append the item to the existing BOM.

I have tried vProdTree.Update, but this line overwrites the original child item in the BOM, rather than appending a new item, which is what I want it to do.

Any help is appreciated.

- Adrian.V