on 09-19-2014 11:54 AM
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
Hi,
chek if the itemCodePadre don't exist in the item master data (oitm table).
regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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
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
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()
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
User | Count |
---|---|
92 | |
11 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.