Forum Discussion

Krishna's avatar
Krishna
Valued Contributor
3 months ago

Finance Rule using DBCL

Hi All - I have the below rule, which calculating 30% on NI and Copying it to the InvestmentinSub account from one entity to another. The rule is executing without any issues, but data is not copying to the target entity. Any Help would be appreciated.  I was able to see the correct value in the log Buffer, but the data is not writing to the DB.  

 

 

 

Select Case api.FunctionType




Case Is = FinanceFunctionType.Calculate

'api.Data.Calculate("A#Profit = A#Sales - A#Costs")

Dim resultDataBuffer As DataBuffer = New DataBuffer()

'Data will be written to the Destination.

Dim destinationInfo As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo("")

'Consol Member

Dim parentCurrencyName As String = "Local"

'Source Data POV

Dim sourcePOV As String = "V#YTD:C#" & parentCurrencyName & ":F#EndBalInput:O#Top:U1#No_CostCenter:U2#10:U3#No_Projects:U5#OracleDataLoad:U8#No_UD8"

'Filter for BalanceSheet Accounts which has text1 as Investments.

Dim filterMembersString As String = "[A#" & topBalShtAcctName & ".Base.Where(Text1 = '" & invSubsAcctText1 & "')]"

'Source Data Stored in the Data Buffer

Dim sourceDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("RemoveZeros(FilterMembers(" & sourcePOV & ", " & filterMembersString & "))")

'Check the Source data Value is greater than 0

If sourceDataBuffer.DataBufferCells.Count > 0 Then

'Loop through the Data Buffer Cells

For Each bCell As DataBufferCell In sourceDataBuffer.DataBufferCells.Values

If (Not bCell.CellStatus.IsNoData) And bCell.CellAmount <> 0 Then

Dim subsidEntName As String = bCell.DataBufferCellPk.GetICName(api)

api.LogMessage(subsidEntName & "ICP")

'Checking ICP is Not Equal to None

If subsidEntName <> "None" Then

api.LogMessage("Inside If and ICP Not None")

Dim subsidEntId As Integer = api.Members.GetMemberId(DimTypeId.Entity,subsidEntName)

Dim subidConsMethod As String = api.Entity.OwnershipType(subsidEntId,api.Pov.Parent.MemberId).ToString

Dim subsidPctCon As Decimal = api.Entity.PercentConsolidation(subsidEntId,api.Pov.Parent.MemberId) * 0.01

Dim subsidPctOwn As Decimal = api.Entity.PercentOwnership(subsidEntId,api.Pov.Parent.MemberId) * 0.01

If subidConsMethod = "Equity" AndAlso subsidPctCon = 0 AndAlso subsidPctOwn > 0 Then

api.LogMessage(subidConsMethod)

api.LogMessage(subsidPctCon)

api.LogMessage(subsidPctOwn)




' Dim nidataCell As DataCell 

' nidataCell = api.Data.GetDataCell("A#" & netIncAcctName & ":F#EndBalInput:O#Top:U1#No_CostCenter:U2#10:U3#No_Projects:U5#OracleDataLoad:U8#No_UD8")

' api.LogMessage(nidataCell.CellAmount & "NetIncome")










Dim sourceNIPov As String = ":F#EndBalInput:O#Top:U1#No_CostCenter:U2#10:U3#No_Projects:U5#OracleDataLoad:U8#No_UD8"

Dim parentCurrencyName1 As String = "Local"

Dim netIncSubsidAmt As Decimal = api.Data.GetDataCell("V#Periodic:C#" & parentCurrencyName1 & ":E#" & subsidEntName & ":A#" & netIncAcctName & sourceNIPov).CellAmount




Dim resultCell1 As New DataBufferCell(bCell)

resultCell1.DataBufferCellPk.FlowId = api.Members.GetMemberId(DimTypeId.Flow, "EndBalInput")

resultCell1.DataBufferCellPk.OriginId = DimConstants.Import

resultCell1.DataBufferCellPk.UD1Id = api.Members.GetMemberId(DimTypeId.UD1,"No_CostCenter")

resultCell1.DataBufferCellPk.UD2Id = api.Members.GetMemberId(DimTypeId.UD2,"10")

resultCell1.DataBufferCellPk.UD3Id = api.Members.GetMemberId(DimTypeId.UD3,"No_Projects")

resultCell1.DataBufferCellPk.UD4Id = DimConstants.None

resultCell1.DataBufferCellPk.UD5Id = api.Members.GetMemberId(DimTypeId.UD5,"EPU")

resultCell1.DataBufferCellPk.UD6Id = DimConstants.None

    resultCell1.DataBufferCellPk.UD7Id = DimConstants.None

resultCell1.DataBufferCellPk.UD8Id = api.Members.GetMemberId(DimTypeId.UD8,"No_UD8")

resultCell1.CellAmount = netIncSubsidAmt * subsidPctOwn

resultDataBuffer.SetCell(si,resultCell1,True)

resultDataBuffer.LogDataBuffer(api,"InvinSub",100)










End If




End If




End If




Next




If resultDataBuffer.DataBufferCells.Count > 0 Then

api.Data.SetDataBuffer(resultDataBuffer,destinationInfo,,,,,,,,,,,,,True)

api.LogMessage("Data is not Zero")

resultDataBuffer.LogDataBuffer(api,"resultbuffer",100)

End If

End If

End Select
  • Thanks. I was able to fix the issue. I gave the flow member as Parent vs Base. It is working now.

  • Krishna's avatar
    Krishna
    Valued Contributor

    Thanks. I was able to fix the issue. I gave the flow member as Parent vs Base. It is working now.