Is it even possible to reverse a Landed Cost using the SDK? (Using Version 9 PL11)
Using the client I can reverse the Landed Cost by choosing the partner (RDF500$), picking the currency (UGX) and the using Copy From and selecting the original landed Cost. After setting the costs to 0 and saving, the original Landed Cost is reversed and the stock costs updated accordingly.
However trying this in SDK produces the error "Source and target landed costs should have same currency":
Private Sub reverseLC()
Dim svrLandedCost As SAPbobsCOM.LandedCostsService = oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.LandedCostsService)
Dim oLandedCost As SAPbobsCOM.LandedCost = svrLandedCost.GetDataInterface(SAPbobsCOM.LandedCostsServiceDataInterfaces.lcsLandedCost)
Dim oLandedCostParams As SAPbobsCOM.LandedCostParams = svrLandedCost.GetDataInterface(SAPbobsCOM.LandedCostsServiceDataInterfaces.lcsLandedCostParams)
Dim oLandedCostsParams As SAPbobsCOM.LandedCostsParams = svrLandedCost.GetDataInterface(SAPbobsCOM.LandedCostsServiceDataInterfaces.lcsLandedCostsParams)
Dim itemline As SAPbobsCOM.LandedCost_ItemLine '= oLandedCost.LandedCost_ItemLines.Add()
'Dim itemlines(100) As SAPbobsCOM.LandedCost_ItemLine
Dim oLandedCost_CostLine(100) As SAPbobsCOM.LandedCost_CostLine
oLandedCost.VendorCode = "RDF500$"
'oLandedCost.Reference = 82 'A/P Invoice
oLandedCost.DocumentCurrency = "UGX"
oLandedCost.PostingDate = #9/29/2012#
For i As Integer = 1 To 12 '# of lines in the A/P invoice
itemline = oLandedCost.LandedCost_ItemLines.Add()
itemline.BaseDocumentType = SAPbobsCOM.LandedCostBaseDocumentTypeEnum.asLandedCosts
'itemline.BaseDocumentType = SAPbobsCOM.LandedCostBaseDocumentTypeEnum.asPurchaseInvoice
itemline.BaseEntry = 8 'Original landed Cost doc
itemline.BaseLine = i - 1
Next
oLandedCost_CostLine(0) = oLandedCost.LandedCost_CostLines.Add
oLandedCost_CostLine(0).LandedCostCode = "14" 'Agency IDF
oLandedCost_CostLine(0).amount = 0
oLandedCost_CostLine(0).AmountFC = 0
oLandedCost_CostLine(1) = oLandedCost.LandedCost_CostLines.Add
oLandedCost_CostLine(1).LandedCostCode = "17" 'Agency
oLandedCost_CostLine(1).amount = 0
oLandedCost_CostLine(0).AmountFC = 0
Dim oLandedCostEntry As Long
Try
setCurrencyRate(oSBObob, "UGX", #9/29/2012#, 2500)
oLandedCostParams = svrLandedCost.AddLandedCost(oLandedCost)
oLandedCostEntry = oLandedCostParams.LandedCostNumber
Catch ex As Exception
'exception process here
myError(False, ex.Message)
End Try
End Sub
The underlying Landed Cost has currency UGX so I do not understand what is wrong. Please assist. Thanks.