on 04-13-2010 6:53 AM
Hi,
I've got error code -5002 and error meessage as below.
[OITM.Shght1Unit], "Linked 0 value 0 does not exist" when I ran below code.
Source ItemCode does not have Height/length/Weight values.
I hope someone can help me.
Thanks
sboItem.SaveXML(sFileName)
sboItem = oSBO.SboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)
oSBO.SboCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xetExportImportMode
sboNewItem = _oSBO.SboCompany.GetBusinessObjectFromXML(sFileName, 0)
sboNewItem.ItemCode = sItemCode
iRet = sboNewItem.Add()
If iRet <> 0 Then
'_oSBO.SboCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
_oSBO.SboCompany.GetLastError(iRet, sErrMsg)
_oSBO.SboCompany.MessageBox(sErrMsg & vbCrLf & "Failed to duplicate item record")
Return ""
Else
Return sboNewItem.ItemCode
End If
Hello,
1. Change the itemcode to the new one before you save the xml file.
2. Move the oSBO.SboCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xetExportImportMode before you save the xml file.
Here is my working sample
Dim sboItem As SAPbobsCOM.Items = oCompany.GetBusinessObject(BoObjectTypes.oItems)
If sboItem.GetByKey(itemcode) = False Then
Exit Sub
End If
oCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode
sboItem.ItemCode = itemcode + "_d"
sboItem.SaveToFile(String.Format("c:\temp\{0}.xml", itemcode))
Dim sboNewItem As SAPbobsCOM.Items = oCompany.GetBusinessObjectFromXML(String.Format("c:\temp\{0}.xml", itemcode), 0)
If sboNewItem.Add() <> 0 Then
sbo_application.MessageBox(oCompany.GetLastErrorCode.ToString + Space(1) + oCompany.GetLastErrorDescription)
Else
sbo_application.MessageBox("Item added")
End If
Your code should be
sboItem = oSBO.SboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)
_oSBO.SboCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode
sboItem.ItemCode = sItemCode
sboItem.SaveXML(sFileName)
sboNewItem = _oSBO.SboCompany.GetBusinessObjectFromXML(sFileName, 0)
iRet = sboNewItem.Add()
If iRet 0 Then
'_oSBO.SboCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
_oSBO.SboCompany.GetLastError(iRet, sErrMsg)
_oSBO.SboCompany.MessageBox(sErrMsg & vbCrLf & "Failed to duplicate item record")
Return ""
Else
Return sboNewItem.ItemCode
End If
Regards
J
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Janos,
Thanks for testing this issue.
I added new function to change xml details( original itemcode to new itemcode).
Then I could create new item record.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Janos,
I've compared with PL0 xml and PL9 xml results.
They are same to have Source ItemCode for ITW1 and OITW table.
PL0 can create new item record but not PL9.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Janos,
Thank you very much for your help.
Your solution is working B1 8.8 PL0 (Sometimes I had same error message but most of time I could add new item record).
I've upgraded B1 8.8 PL9 this morning to avoid some other SDK problem.
But creating new item record had failed again with different error message.
I've got
Enter valid code [OITW.ItemCode] error message
Also I found xml details are not correct.
- <OITM>
- <row>
<ItemCode>PKCODE33</ItemCode>
......
- <OITW>
- <row>
<ItemCode>PKCODE</ItemCode>
<WhsCode>01</WhsCode>
ItemCode of OITW and ITM1 table are wrong.
Is this B1 8.8 PL9 bug?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
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.