Skip to Content
0
Former Member
May 05, 2010 at 11:47 AM

DI API question, add item failed after 200 - 300 items

65 Views

hello all,

I would like to ask DI API question

In the code below I want to add 1000 items via DI API, but the code always

failed after about 200-300 loop executed.

First loop until 200nd loop are success, the item added successfully.

Dim oItm As SAPbobsCOM.Items
Dim lretval As Long
oItm = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)
For i As Integer = 0 To 1000
    oItm.ItemCode = "iteme-" & i
    oItm.ItemName = "Iteme-" & i
    lretval = oItm.Add
    If (lretval <> 0) Then
        Throw New Exception(oCompany.GetLastErrorDescription)
    End If
Next

Error message is:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I use SBO 8.8 DI API version 8.80.228 , is there anything wrong with the code?

This code works fine in SBO 2007.

Thanks,

Robby