Quantcast
Channel: SQL Server Analysis Services Forum
Viewing all articles
Browse latest Browse all 2472

Ignore Dimension Key Errors in AMO

$
0
0

Hello,

I am trying to process all partitions of a measure group using AMO VB.Net script. I used the below code from one of the online blogs:

http://www.ssas-info.com/VidasMatelisBlog/11_ssis-package-that-process-all-partitionsmeasure-groupscubes-in-one-database

The xmla captured using the below code inserts a line of code " <KeyErrorLimit>-1</KeyErrorLimit>" for each object in the batch, but SSAS accepts this code only once for a batch. Is there a way to modify this xmla? Please help.

Thanks

Public Sub Main()
        '
        ' Add your code here
        Dim objServer As Server
        Dim objDatabase As Database
        Dim oMeasureGroup As Microsoft.AnalysisServices.MeasureGroup
        Dim oPartition As Microsoft.AnalysisServices.Partition
        Dim oCube As Microsoft.AnalysisServices.Cube
        Dim ExecutionSuccessfull As Boolean = True ' If true, package executed without errors
        objServer = New Server
        Dim objErrorConfig As New ErrorConfiguration
        objErrorConfig.KeyErrorAction = KeyErrorAction.ConvertToUnknown
        objErrorConfig.KeyErrorLimitAction = KeyErrorLimitAction.StopProcessing
        objErrorConfig.KeyErrorLimit = -1
        objErrorConfig.KeyDuplicate = ErrorOption.IgnoreError
        objErrorConfig.KeyNotFound = ErrorOption.ReportAndContinue
        objErrorConfig.NullKeyConvertedToUnknown = ErrorOption.IgnoreError
        objErrorConfig.NullKeyNotAllowed = ErrorOption.ReportAndContinue



        objServer.Connect("Cube_Server")
        objDatabase = objServer.Databases("OMNI_F04__AJ")
        oCube = objDatabase.Cubes("Item_Weekly")
        'For Each oCube In objDatabase.Cubes
        ' oCube.Process(Microsoft.AnalysisServices.ProcessType.ProcessFull) ‘ Process all cubes
        objServer.CaptureXml() = True ' Start capturing XML.
        For Each oMeasureGroup In oCube.MeasureGroups
            ' oMeasureGroup.Process(Microsoft.AnalysisServices.ProcessType.ProcessFull) ‘ Process all measure groups
            MsgBox(oMeasureGroup.Name)
            If oMeasureGroup.Name.ToString.Contains("Inventory") Then

                For Each oPartition In oMeasureGroup.Partitions
                    If oPartition.Name.ToString.Contains("LY") Then

                        oPartition.Process(Microsoft.AnalysisServices.ProcessType.ProcessFull, objErrorConfig)  ' Process all partitions
                    End If
                Next
            End If
        Next
        objServer.CaptureXml() = False ' Stop capturing XML

        Dim oResults As Microsoft.AnalysisServices.XmlaResultCollection
        Dim oResult As Microsoft.AnalysisServices.XmlaResult

        oResults = objServer.ExecuteCaptureLog(True, True)

        Dim oMessage As Microsoft.AnalysisServices.XmlaMessage

        'Log the errors and warnings
        For Each oResult In oResults
            For Each oMessage In oResult.Messages
                If oMessage.GetType.Name = "XmlaError" Then
                    'The processing failed
                    ExecutionSuccessfull = False
                Else
                    'It’s just a warning.
                    ExecutionSuccessfull = True ' if you want to fail on warning, change this to False
                End If
            Next oMessage
        Next oResult

        

Viewing all articles
Browse latest Browse all 2472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>