cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with adding Bill of Materials to Order

Former Member
0 Kudos
84

Hey,

I hope someone can help me with this problem. I have created a product tree (BOM) using the SDK. I can successfully add this item to the matrix on the sales quotation form in Business One. I also want to allow the user to have the same function on the Order form. I use the exact same code, product tree etc.. but the application simply hangs when I try to add the BOM itemcode to the matrix on the order form. Is there something different that I must do in order to add this on the order form?

Has anyone been able to add a BOM to the order form through the SDK?

Here is a snippet of code I am using:

SAPbouiCOM.Column col= null;
SAPbouiCOM.Columns cols;
OItem = m_ParentForm.SboForm.Items.Item(matrixId.ToString());
OMatrix = (SAPbouiCOM.Matrix)OItem.Specific;
cols = OMatrix.Columns;	
SAPbouiCOM.EditText temp;
				
m_ParentForm.SboForm.Freeze(true);

//set ItemCode of BOM
col = cols.Item(v33_QUOT_MATRIXITEMCODE);
temp = (SAPbouiCOM.EditText)col.Cells.Item(numRows).Specific;
temp.Value = bomCode;

Does anyone have any ideas?

Accepted Solutions (1)

Accepted Solutions (1)

barend_morkel2
Active Contributor
0 Kudos

If you can't add a BOM to the order - why don't you add the items (and quantities) of the BOM to the order. You can add some kind of reference to notify the user that certain item lines of an order pertains to the BOM

Former Member
0 Kudos

Thanks for the reply Barend but that is not an option with this client. As I said the user wants the same function that I have given them with the sales quotation.

Does anyone know why I would not be able to add the BOM to the sales order, even though I can add it to a quote and then I can import the quote to the sales order. That will work fine.

Any help would be appreciated?

FOA
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Laura,

I'm posting some code I use to create a sales order. I have no problem at all:

Try

oSalesOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)

oProdTree = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductTrees)

oSalesOrder.CardCode = "C40005"

oSalesOrder.DocDate = Now

oSalesOrder.DocDueDate = Now

oSalesOrder.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items

oSalesLines = oSalesOrder.Lines

oSalesLines.AccountCode = "_SYS00000000010"

oSalesLines.ItemCode = "C7689"

oSalesLines.Quantity = 7

'Line added to test adding value in notactive cell.

oSalesLines.SerialNum = "12345"

Dim oTree As SAPbobsCOM.ProductTrees

Dim oTreeLines As SAPbobsCOM.ProductTrees_Lines

Dim l_long As Long

Dim i As Integer

oTree = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductTrees)

If oTree.GetByKey("C7689") Then

oTreeLines = oTree.Items()

l_long = oTreeLines.Count

If l_long > 0 Then

For i = 0 To l_long - 1

'From the 2nd line we have too add the row first and then fill data.

oSalesLines.Add()

oTreeLines.SetCurrentLine(i)

oSalesLines.ItemCode = oTreeLines.ItemCode

'oSalesLines.AccountCode = "_SYS00000000010"

Next

End If

End If

Now, regarding the usage of Form.Freeze. Are you using exactly the same code? I think you have to release it by setting it to false. Might be that this is causing the problem. You can read more about it in the following thread:

HTH,

Felipe

Answers (0)