Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

I have a problem when try to update Item (DI API)

I created a program and i can to add a Item but can't modify a existing item. I show my code:

..............

oItSBO = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)

oItSBO.ItemCode = ItemCode

oItSBO.ItemName = ItemDescription

.......... ...

If oItSBO.GetByKey(ItemCode) Then

lErrCode = oItSBO.Update()

If lErrCode <>0 The

oCompany.GetLastError(lErrCode, sErrMsg)

End If

Else

lErrCode = oItSBO.Add()

If lErrCode <> 0 Then

oCompany.GetLastError(lErrCode, sErrMsg)

End If

End If

..................

IS THERE ANY ERROR????

Thanks.

Former Member
Former Member replied

try the code as - the problem in your code was, that you with getbykey overwtited all sets properties at the end and the product stays same.

oItSBO = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)

dim edit as integer

edit = 1

If not oItSBO.GetByKey(ItemCode) Then

edit = 1

end if

oItSBO.ItemCode = ItemCode

oItSBO.ItemName = ItemDescription

.......... ...

if edit = 1 then

lErrCode = oItSBO.Update()

else

lErrCode = oItSBO.Add()

end if

If lErrCode 0 Then

oCompany.GetLastError(lErrCode, sErrMsg)

End If

End

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question