Forum Discussion
Krishna
3 years agoValued Contributor
Data Buffer to delete the data on the LHS (Target Account) ?????
All - Could you please review code is make sense from performance. I am trying to be checking the target Account is <> 0 then it will delete the source value and overwrite the target value. PLease re...
- 3 years ago
Hi Krishna,
First off, the main api.data.calculate call isn't balanced where you have F#EndBalInput on the left side of the equation but not on the right. The right side should be A#Source:F#EndBalInput so that the data buffers align on both sides of the equation.
Second, I'm assuming that in this exercise, you are only want to modify Target intersections if the same intersection in Source has a non-zero value? If this is the case, I don't think you even need to run an Eval at all since you are using the RemoveZeros function on the right side of the equation. Target will only be updated with the Source data buffer that already excludes cells with 0 value.
Third, in the Eval sub, the line api.Data.ClearCalculatedData doesn't make sense in the context of you looping through each databuffer cell for Source account. You are basically clearing all calculated data cells for A#Target regardless of the current cell you're loop is evaluating. I think you would need to refine the member filter to include members of other dimensions so as to clear the intersection that is aligned with the source cell. For example:
For Each Cell As DataBufferCell In EventArgs.DataBuffer1.DataBufferCells.Values If Cell.CellAmount <> 0 Then Dim ud1Member as String = cell.GetUD1Name(api) Dim ud2Member as String = cell.GetUD2Name(api) api.Data.ClearCalculatedData(True,True,True,"A#Target:UD1#" & ud1Member & ":UD2#" & ud2Member) eventargs.DataBufferResult.SetCell(api.SI,cell) End If NextHope this helps!
Cosimo
3 years agoContributor II
Hi Krishna,
First off, the main api.data.calculate call isn't balanced where you have F#EndBalInput on the left side of the equation but not on the right. The right side should be A#Source:F#EndBalInput so that the data buffers align on both sides of the equation.
Second, I'm assuming that in this exercise, you are only want to modify Target intersections if the same intersection in Source has a non-zero value? If this is the case, I don't think you even need to run an Eval at all since you are using the RemoveZeros function on the right side of the equation. Target will only be updated with the Source data buffer that already excludes cells with 0 value.
Third, in the Eval sub, the line api.Data.ClearCalculatedData doesn't make sense in the context of you looping through each databuffer cell for Source account. You are basically clearing all calculated data cells for A#Target regardless of the current cell you're loop is evaluating. I think you would need to refine the member filter to include members of other dimensions so as to clear the intersection that is aligned with the source cell. For example:
For Each Cell As DataBufferCell In EventArgs.DataBuffer1.DataBufferCells.Values
If Cell.CellAmount <> 0 Then
Dim ud1Member as String = cell.GetUD1Name(api)
Dim ud2Member as String = cell.GetUD2Name(api)
api.Data.ClearCalculatedData(True,True,True,"A#Target:UD1#" & ud1Member & ":UD2#" & ud2Member)
eventargs.DataBufferResult.SetCell(api.SI,cell)
End If
Next
Hope this helps!
- Krishna3 years agoValued Contributor
Thanks Cosimo Make sense to me. I have to expand UD's & Eval is not required since RenoveZeros is being used. I will try this and keep you posted. Appreciated.
Related Content
- 3 years ago
- 2 years ago
- 2 years ago