Skip to Content
0
Former Member
Jan 31, 2012 at 02:19 PM

Manual Distribution Rule

269 Views

Hi!

I need to create a MANUAL distribution rule from the SDK to associate then with a line of an Invoice.

I've already used the object SAPbobsCOM.DistributionRule but when I add is displayed in the master data of the distribution rules, in this way:

Dim oCmpSrv As SAPbobsCOM.CompanyService = oCompany.GetCompanyService()
        Dim oDLservice As SAPbobsCOM.DistributionRulesService = oCmpSrv.GetBusinessService(SAPbobsCOM.ServiceTypes.DistributionRulesService)
        Dim oDL As SAPbobsCOM.DistributionRule
  
  

            ' Add distribution rule
        oDL = oDLservice.GetDataInterface(SAPbobsCOM.DistributionRulesServiceDataInterfaces.drsDistributionRule)
        oDL.FactorCode = _Code
        oDL.FactorDescription = _Code
        oDL.InWhichDimension = 1
        Dim TotalFactor As Double = 0

        For i As Integer = 0 To (ProfitCenters.Length \ 2) - 1
            oDL.DistributionRuleLines.Add()
            oDL.DistributionRuleLines.Item(i).CenterCode = ProfitCenters(i, 0)
            oDL.DistributionRuleLines.Item(i).TotalInCenter = ProfitCenters(i, 1)
            oDL.DistributionRuleLines.Item(i).Effectivefrom = Date.Now
            TotalFactor += ProfitCenters(i, 1)
        Next
        
        oDL.TotalFactor = TotalFactor


        Try
            oDLservice.AddDistributionRule(oDL)
        Catch ex As Exception
            oLog.Errore(ex.Message, ex)
            _return = ""
        End Try

I would use a manual distribution rule.

How can I do?

Thanks!