Hi people.
I have a problem about an AccessViolationException with StockTransfer.FromWarehouseCode property when I try to set a value.
The real problem is that the exception occur if the addon run under UI. If it runs as external addon, just DI, it works fine.
The code is this
Public Sub trasferimento()
Dim _b1Maga As SAPbobsCOM.StockTransfer = _cmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer)
With _b1Maga
.DocDate = DocDate
.TaxDate = DocDate
.Comments = Comments1 + vbCrLf + Comments2
End With
With _b1Maga.Lines
.ItemCode = ItemCode
.Quantity = Quantity
.FromWarehouseCode = FromWH <<< THIS FAILS UNDER UI
.WarehouseCode = WHCode
End With
With _b1Maga.Lines.BinAllocations
.BinAbsEntry = getIdUbicazione(FromBinAE)
.Quantity = _b1Maga.Lines.Quantity
.BinActionType = SAPbobsCOM.BinActionTypeEnum.batFromWarehouse
.BinAbsEntry = getIdUbicazione(BinAbsEntry)
.BinActionType = SAPbobsCOM.BinActionTypeEnum.batToWarehouse
End With
Dim lErr As Long = 0
Dim sErr As String = ""
Dim ret As Long = _b1Maga.Add()
If ret <> 0 Then
_cmp.GetLastError(lErr, sErr)
If lErr <> 0 Then
Throw New WarehouseMovementException(lErr & " " & sErr)
End If
End If
End Sub
The properties before and after are setted correctly.
The addon runs under SAP Business One 9.1 PL 09.
In my opinion is a SDK bug and so I searched about it under SAP notes but I'm not a lucky man.
Someone can confirm if it is a SDK bug? and, especially, is there a workaround?
Thanks a lot
Nicola