cancel
Showing results for 
Search instead for 
Did you mean: 

Problem Adding BOM using Product Trees Object

Former Member
0 Kudos

Hey I am having problems with the following code:


qProductTree = (SAPbobsCOM.ProductTrees)this.m_SboAddon.SboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductTrees);

int RetVal = 0;
qProductTree.TreeCode = "productTree1";
qProductTree.TreeType = SAPbobsCOM.BoItemTreeTypes.iProductionTree;
qProductTree.Quantity  = 5;
qProductTree.Items.ItemCode = "test1";
qProductTree.Items.Price = 20;
qProductTree.Items.Quantity = 1;
qProductTree.Items.Currency = "Eur";
qProductTree.Items.Comment = "test comment";
qProductTree.Items.IssueMethod = SAPbobsCOM.BoIssueMethod.im_Manual;
	
RetVal = qProductTree.Add();

string errMsg;
int errCode;
if (RetVal != 0 )
{
     this.m_SboAddon.SboCompany.GetLastError(out errCode, out errMsg);
	MessageBox.Show(errMsg);
}

I get an error message with ID 2028 which when I look it up in the SDK it states DataSource - No Data found.

Any ideas?

Accepted Solutions (1)

Accepted Solutions (1)

barend_morkel2
Active Contributor
0 Kudos

Hi Laura,

Try Adding the Item before you add the Object.

qProductTree.Items.Add;

THEN

RetVal = qProductTree.Add();

Answers (2)

Answers (2)

AlexGrebennikov
Active Contributor
0 Kudos

Hi Laura!

In DI reference you can find topic 'Add a Bill Of Material sample', hope it'll help you.

Note, that there are some lines in that sample:

    Dim vItem As SAPbobsCOM.Items
    <b>Set vItem = vCmp.GetBusinessObject(oItems)</b>
    Dim vProdTree As SAPbobsCOM.ProductTrees
    Set vProdTree = vCmp.GetBusinessObject(oProductTrees)
           'Get the Item I want to create as Product Tree
    <b>RetVal = vItem.GetByKey("MyProdTree")</b>
    'Set Values to the fields
    vProdTree.TreeCode = <b>"MyProdTree"</b>
    vProdTree.TreeType = iProductionTree

In my mind, you should find an existing Item (via GetByKey) before you create ProductTree.

AlexGrebennikov
Active Contributor
0 Kudos

Hi again!

i have seen that you solve problem!

could you explain us what was wrong?

thanx.

Former Member
0 Kudos

Yeah sorry I have been busy I have not had time to repost. I was just not adding the items properly. I did not understand that all the items had to be exisiting master data items.

Thanks everyone for your help

Former Member
0 Kudos

Hi,

you're not adding the the items in the BOM, so you must write the command qProductTree.Items.Add() after every item definition.

In your code you must write this command just before the RetVal = qProductTree.Add()

Hope this helps.

Kind Regards,

Fabio Salucci

Former Member
0 Kudos

Thanks for the help Fabio. I am still getting the same data error even when I added the Items.Add method call. It is error code 2028 with no error message. Help files say something about data source no data found.

Anyone else got any ideas?

barend_morkel2
Active Contributor
0 Kudos

Hi Laura,

1. Are you sure "test1" exists as an inventory item in the company DB you are connecting to?

2. Try NOT setting the currency (the system will assign it by default) - thus do not reference the currency parameter when setting up the item.

Former Member
0 Kudos

Hi

If you set the price, you must set pricelist and currency

properties.

Too Warehouse is necessary

qProductTree.Items.Add: is necessary if there are some lines

Andrea