cancel
Showing results for 
Search instead for 
Did you mean: 

9.1 error adding BOM with SAPbobsCOM.ProductionItemType.pit_Resource

0 Kudos

Hi,

I'm working on 9.1 sapb1 version.

I'm trying to add a new BOM. All is ok until my itemType is SAPbobsCOM.ProductionItemType.pit_Item.

If I try to change this using the new properties of the BOM SAPbobsCOM.ProductionItemType.pit_Resource i retrieve an error: Errore nella creazione della distinta TEST (No matching records found (ODBC -2028)).

This is my simple code:

//

    Private distinta As SAPbobsCOM.ProductTrees

    Private distinta_riga As SAPbobsCOM.ProductTrees_Lines

distinta = myDB.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductTrees)

distinta.TreeCode = itemCodePadre

distinta.Quantity = 1 'qta

distinta.TreeType = SAPbobsCOM.BoItemTreeTypes.iProductionTree

distinta.PriceList = idListino

distinta_riga = distinta.Items

For line As Integer = 0 To dt.Rows.Count - 1

                        itemType = dt.GetValue("itemType", line)

                        itemCodeFiglio = dt.GetValue("itemCode", line)

                        qta = dt.GetValue("qty", line)

                        If line > 0 Then

                            distinta_riga.Add()

                        End If

                        distinta_riga.SetCurrentLine(distinta_riga.Count - 1)

                        Select itemType.ToLower

                            Case "articolo"

                                distinta_riga.ItemType = SAPbobsCOM.ProductionItemType.pit_Item

                                Case "risorsa"

                                distinta_riga.ItemType = SAPbobsCOM.ProductionItemType.pit_Resource

                        End Select

                            distinta_riga.ItemCode = itemCodeFiglio

                             distinta_riga.Quantity = qta

                    Next

                    ret = distinta.Add()

//

I have find no examle in sdk, so i don't know if, mabe, there is a mandatory field that i don't set.

Someone can help me?

Regards

Marco

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

chek if the itemCodePadre don't exist in the item master data (oitm table).

regards

0 Kudos

Hi Alessandro,

yes, the itemCodePadre exist.

All the code that I have wrote is inside the condition

//

If not distinta.GetByKey(itemCodePadre) Then

etc etc

end if

//

Another helpful information:

in the datatable I have 10 line, with 9 item and the lastone resource.

If i jump the last line, the BOM is created correct with 9 item line.

If i loop all the line, with 9 item and 1 resource, i retireve the error...very strange...

Marco

Former Member
0 Kudos

try

For line As Integer = 0 To dt.Rows.Count - 1

                        itemType = dt.GetValue("itemType", line)

                        itemCodeFiglio = dt.GetValue("itemCode", line)

                        qta = dt.GetValue("qty", line)

                       If line > 0 Then

                            distinta_riga.Add()

                        End If

                        distinta_riga.SetCurrentLine(distinta_riga.Count - 1)

                        Select itemType.ToLower

                            Case "articolo"

                                distinta_riga.ItemType = SAPbobsCOM.ProductionItemType.pit_Item

                                Case "risorsa"

                                distinta_riga.ItemType = SAPbobsCOM.ProductionItemType.pit_Resource

                        End Select

                            distinta_riga.ItemCode = itemCodeFiglio

                             distinta_riga.Quantity = qta

                       If line > 0 Then

                            distinta_riga.Add()

                        End If

                    Next

regards, alessandro

Former Member
0 Kudos

p.s.

if you have problem in the post wrote before use  only distinta_riga.Add()

                       If line > 0 Then

                            distinta_riga.Add()

                        End If

                        distinta_riga.Add()

regards, alsessandro

0 Kudos

Hi Alessandro,

I have test it, but the error is still present (I use the second post cause in the first they don't create the first line of the datatable).

Marco

Former Member
0 Kudos

hi,

maybe you have to do :

For line As Integer = 0 To dt.Rows.Count - 1

                        itemType = dt.GetValue("itemType", line)

                        itemCodeFiglio = dt.GetValue("itemCode", line)

                        qta = dt.GetValue("qty", line)

                       If line > 0 Then

                            distinta_riga.Add()

                        End If

                        distinta_riga.SetCurrentLine(distinta_riga.Count - 1)

                        Select itemType.ToLower

                            Case "articolo"

                                distinta_riga.ItemType = SAPbobsCOM.ProductionItemType.pit_Item

                                Case "risorsa"

                                distinta_riga.ItemType = SAPbobsCOM.ProductionItemType.pit_Resource

                        End Select

                            distinta_riga.ItemCode = itemCodeFiglio

                             distinta_riga.Quantity = qta

                       If line = 0 Then

                       ''''''''----because the firs row exist, so update data

                            distinta_riga.Update()

                       else

                             distinta_riga.Add()

                        End If

                    Next

regards, alessandro

Former Member
0 Kudos

try this too, add a row like you do the first time and after populate it update the data.

For line As Integer = 0 To dt.Rows.Count - 1

                        itemType = dt.GetValue("itemType", line)

                        itemCodeFiglio = dt.GetValue("itemCode", line)

                        qta = dt.GetValue("qty", line)

                        If line > 0 Then

                            distinta_riga.Add()

                        End If

                        distinta_riga.SetCurrentLine(distinta_riga.Count - 1)

                        Select itemType.ToLower

                            Case "articolo"

                                distinta_riga.ItemType = SAPbobsCOM.ProductionItemType.pit_Item

                                Case "risorsa"

                                distinta_riga.ItemType = SAPbobsCOM.ProductionItemType.pit_Resource

                        End Select

                            distinta_riga.ItemCode = itemCodeFiglio

                             distinta_riga.Quantity = qta

                            distinta_riga.Update()

                    Next

                    ret = distinta.Add()

regards, alessandro

0 Kudos

Hi Alessandro,

I dont' find the .Update method in the SAPbobsCOM.ProductTrees_Lines object...

Marco

Former Member
0 Kudos

Sorry for update i'm wrong,

maybe the problem is in the SetCurrentLine that start from 1 and not from 0; maybe you can try:

For line As Integer = 0 To dt.Rows.Count - 1

                        itemType = dt.GetValue("itemType", line)

                        itemCodeFiglio = dt.GetValue("itemCode", line)

                        qta = dt.GetValue("qty", line)

                        If line > 0 Then

                            distinta_riga.Add()

                        End If

                       distinta_riga.SetCurrentLine(distinta_riga.Count)

                        distinta_riga.SetCurrentLine(distinta_riga.Count - 1)

                        Select itemType.ToLower

                            Case "articolo"

                                distinta_riga.ItemType = SAPbobsCOM.ProductionItemType.pit_Item

                                Case "risorsa"

                                distinta_riga.ItemType = SAPbobsCOM.ProductionItemType.pit_Resource

                        End Select

                            distinta_riga.ItemCode = itemCodeFiglio

                             distinta_riga.Quantity = qta

                    Next

                    ret = distinta.Add()

regards, alessandro

0 Kudos

No..."Invalid row" error....

Former Member
0 Kudos

Hi,

Strange this object is different by other objectlines...

you can try to don't use SetCurrentLine

Dim oPT As SAPbobsCOM.ProductTrees = Nothing

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

oPT.TreeCode = "XXXXX"

oPT.TreeType = SAPbobsCOM.BoItemTreeTypes.iProductionTree

'1st row you don't add lines

oPT.Items.ItemCode = "YYYYYY"

oPT.Items.Warehouse = "W10"

oPT.Items.Quantity = "2"

oPT.Items.PriceList = 2

---------

-------

'2nd row add lines and not setcurrentline

oPT.Items.Add()

oPT.Items.ItemCode = "ZZZZZZ"

oPT.Items.Warehouse = "W10"

oPT.Items.Quantity = "2"

oPT.Items.PriceList = 2

--------

--------

oPT.Add()

0 Kudos

Hi Alessandro,

follow your suggest, I have found the problem.

When I add the Resource line, I don't set the warehouse, and in the Resource Master Data there is no a Default warehouse, so when I add the row i retrieve the erro r. If set the .warehouse property the error is not prsent.

The strange is that if I try to add the resource line directly in SAPB1 and i don't put the warehouse, I'm able to create correctly the BOM.

Thank you for the help

Regards

Marco