cancel
Showing results for 
Search instead for 
Did you mean: 

Template BOM in the invoice when removing childeren

Former Member
0 Kudos

Dear Experts,

I am facing a red hairing issue which i'd very much appriciated your input.

I created an item master data.

I set up a template BOM for this newly created item.

Add this item to the invoice doc in SAP.

Remove the children which were already loaded as soon as i added my BOM type item.

and click on the ADD button.

when i go back to this invoice i only see one line which is the parent item(item master with no BOM listed) as expected.

BUT when i add the same invoice doc manually through SDK , althought i am adding just one line to the invoice doc at runtime but somehow SAP adds all the BOM listed items to the invoice.

Could you think of any field setting that i then would be able to get the same result in my addon as what does happen in SAP.

Many thanks in advance.

Regards,

Maryam Gharib.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Dear Maryam Gharib,

What is your B1 version and PL? Have you tried UI instead?

Thanks,

Gordon

Former Member
0 Kudos

Hi Gordon,

Thanks for considering my question.

SAP 8.81 PL:9

I am not sure sure what you mean by UI doc?

the code is as below:

Dim oInvoice As SAPbobsCOM.Documents
               oedit = oForm.Items.Item("4").Specific 'Cardcode
 
                oInvoice.CardCode = oedit.Value
                oInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items

                oedit = oForm.Items.Item("10").Specific
                'oInvoice.DocDate = oedit.

                For i = 1 To oMatrix.RowCount - 1
                    oedit = oMatrix.Columns.Item("1").Cells.Item(i).Specific 'item code
                    oInvoice.Lines.ItemCode = oedit.Value

                    oedit = oMatrix.Columns.Item("14").Cells.Item(i).Specific 'price
                    If oedit.Value = "" Then
                        oInvoice.Lines.Price = 0
                    Else
                        oInvoice.Lines.Price = Right(oedit.Value, Len(oedit.Value) - 3)
                    End If

                    oedit = oMatrix.Columns.Item("11").Cells.Item(i).Specific 'Quantity
                    oInvoice.Lines.Quantity = oedit.Value
                    ocombo = oMatrix.Columns.Item("18").Cells.Item(i).Specific 'Taxcode
                    oInvoice.Lines.TaxCode = ocombo.Value
                    '  oInvoice.Lines.VatGroup = Vat Code If needed

                    If i = oMatrix.RowCount - 1 Then
                    Else

                        oInvoice.Lines.Add()
                    End If
                Next

                ' Add invoice

                oInvoice.SalesPersonCode = m_slpCode
                '  oInvoice.SaveToFile("C:\invoice.xml")

                lRetCode = oInvoice.Add()

if i save the invoice into a file the file content is corrent. but as soon as it gets added, calling the GetNewobject will return all the original BOM lines as well!

Regards,

Maryam.

Edited by: Maryam Gharib on Dec 6, 2011 3:46 PM

Former Member
0 Kudos

UI API allows you to imitate what you can do through front end.

Former Member
0 Kudos

Hi Gordon,

Due to the business requirement of the job, I can't use the UI functioanalities as I need to create some mix payment records upon creating the invoice and this means i have to use the BatchTransactions (e.g. start,commit,rollback transactions.) this gives me the ability to roll back if it needs be.

Thanks and regards,

Maryam.

Former Member
0 Kudos

In that case, consult SAP support to see if that is possible.

Former Member
0 Kudos

Dear Gordon,

Many thanks for your inputs, after more debates and reconsideratins i ended up using UI APIs to meet the requirements.

Regards,

Maryam.