📚 SAP Business One SDK Help

UpdateDistributionRule Method
See Also  Example
pIDistributionRule
The data for the distribution rule to be updated. The DistributionRule object must contain the key of the object to be updated.

Description

Updates an existing distribution rule.

The data for the distribution rule, including the key of the distribution rule to be updated, is contained in the DistributionRule object passed to the method. To update a distribution rule, you must first retrieve it using the GetDistributionRule method.

Syntax

Visual Basic
Public Sub UpdateDistributionRule( _
   ByVal pIDistributionRule As DistributionRule _
) 

Parameters

pIDistributionRule
The data for the distribution rule to be updated. The DistributionRule object must contain the key of the object to be updated.

Example

Updating a distribution rule (Visual Basic)Copy Code
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

See Also