Dear,
I want to use the "UpdateDistributionRule" method for updating (add new line) the existing distribution rules. I have tried the code from SDK help, but it does not work.
Here is the code from SDK help as below:
oCmpSrv = oCompany.GetCompanyService()
Dim oDLservice As SAPbobsCOM.DistributionRulesService = oCmpSrv.GetBusinessService(SAPbobsCOM.ServiceTypes.DistributionRulesService)
Dim oDL As SAPbobsCOM.DistributionRule
Dim oDLParams As SAPbobsCOM.IDistributionRuleParams
' Get distribution rule
oDLParams = oDLservice.GetDataInterface(SAPbobsCOM.DistributionRulesServiceDataInterfaces.drsDistributionRuleParams)
oDLParams.FactorCode = "1"
Try
oDL = oDLservice.GetDistributionRule(oDLParams)
Catch ex As Exception
MsgBox(ex.Message)
End Try
' Update distribution rule
oDL = oDLservice.GetDataInterface(SAPbobsCOM.DistributionRulesServiceDataInterfaces.drsDistributionRule)
oDL.FactorCode = "1"
oDL.FactorDescription = "Desc 1"
oDL.InWhichDimension = 1
oDL.TotalFactor = 40
oDL.DistributionRuleLines.Add()
oDL.DistributionRuleLines.Item(0).CenterCode = "1"
oDL.DistributionRuleLines.Item(0).TotalInCenter = "10"
oDL.DistributionRuleLines.Add()
oDL.DistributionRuleLines.Item(1).CenterCode = "2"
oDL.DistributionRuleLines.Item(1).TotalInCenter = "30"
Try
oDLservice.UpdateDistributionRule(oDL)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Regards,
On