Onestreamer92
11 days agoNew Contributor II
Parser rule to compare attribute data between current month load and last year Dec load
HI Experts,
I have a parser rule that looks at current attribute 9 and compares it with attribute 9 of last year December load and returns it as attribute 10 which helps me map the differences in Tiering.
My issue is - the file is huge around 15k lines and its taking ages for this comparison. How can i make it run a bit faster ? Any help would be appreciated.
PARSER RULE BELOW FOR YOUR INFORMATION:
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As ParserDimension, ByVal args As ParserArgs) As Object
Try
Dim Time As String = BRApi.Finance.Time.GetNameFromId(si,si.WorkflowClusterPk.TimeKey)
Dim WfYear As String = Time.Substring(0,4)
Dim WfYearPrior As Integer = WfYear - 1
'
'Get the fields for comparison
Dim AttrColPosition As Integer = 97
Dim CurrString As String = api.Parser.DelimitedParsedValues(AttrColPosition)
'Brapi.ErrorLog.LogMessage(si,"My Currr A8 is " &CurrString)
Dim EntColPosition As Integer = 2
Dim EntString As String = api.Parser.DelimitedParsedValues(EntColPosition)
'Brapi.ErrorLog.LogMessage(si,"My Currr Entity is " &EntString)
Dim ISINColPosition As Integer = 23
Dim ISINString As String = api.Parser.DelimitedParsedValues(ISINColPosition)
'Brapi.ErrorLog.LogMessage(si,"My Currr Entity is " &EntString)
'SQL ----------------------
Dim sql As New Text.StringBuilder
Dim dt As DataTable
sql.AppendLine("Select TOP 1 A9 ")
sql.AppendLine("From vStageSourceAndTargetDataWithAttributes ")
sql.AppendLine("Where Si = 'AnalystPackLoad' and TmT = '"& WfYearPrior &"M12' and A18 = '"& ISINString &"' and Et = '"& EntString &"' ")
Using dbConnApp As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
dt = BrApi.Database.ExecuteSql(dbConnApp,sql.ToString,True)
End Using
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
Dim Att10 As String = dt.Rows(0)("A9").ToString()
Return Att10
End If
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace