Hi - I know the below code is not a good practice but is there is an alternative way to set the data =0 because I want to clear all Origin Base member and UD2 base. Any help would be appreciated ?
...
Hi Kris, thank you very much for asking this question as you already point out that this is not recommended.
What is the reason that you need to clear that data? Is this data calculated so that you can use a api.data.clearcalculateddata? Is it loaded, then it would be best to reload that data with an adjusted dataset prior to loading? Etc.?
The thing is with a Business Rule, you remove all of that data (and really, please do not set to zero!), also in periods that have been closed and locked already if they get reconsolidated. So you are tapping into serious audit issues here in my view.
I have modified as below and let me know if this good. All I am doing is to if there is a data in USD Account then I am clearing the other account at USD and copying the data.
If Not api.Entity.HasChildren Then
Dim destAcct As String = "A#OCI_PensionOPEB"
Dim destDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(A#OCI_PensionOPEB:F#EndBalInput:C#USD)")
'USD ACCOUNT
Dim srcAcct As String = "A#USDOCI_PensionOPEB"
Dim srcDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(A#USDOCI_PensionOPEB:F#EndBalInput)")
If Not srcDataBuffer Is Nothing Then
For Each srccell As DataBufferCell In srcDataBuffer.DataBufferCells.Values
If srccell.CellAmount <> 0 Then
Dim ud1Member As String = srccell.GetUD1Name(api)
Dim ud3Member As String = srccell.GetUD3Name(api)
Dim icp As String = srccell.GetICName(api)
If Not destDataBuffer Is Nothing Then
For Each sourcecell As DataBufferCell In destDataBuffer.DataBufferCells.Values
If Not sourcecell.CellStatus.IsNoData Then
api.Data.ClearCalculatedData(True, True, True, destAcct,,, "I#" & icp, "U1#" & ud1Member,, "U3#" & ud3Member,,,,,)
End If
Next
End If
End If
Next
api.Data.Calculate("A#OCI_PensionOPEB:F#EndBalInput=A#USDOCI_PensionOPEB:F#EndBalInput")
End If
End If
I am still not 100% sure what you are trying to achieve here. When you want to copy data from account A to B, account B is a calculated account, I assume? That is why I asked if the data you wish to clear is calculated.
With regards to your script, you are looping within a loop, which I would not recommend as this will have an impact on performance.
I will assume that there is calculated data on the target account that is being calculated during each calculation. Ideally, data is not copied to an account where it has to be deleted later on. If that cannot be avoided one may clear it afterwards, of course. In that case, (something like) these two rows may be all you need.
1. When Account B has data then Copy the Data from B to A USD and A Local should not be cleared. 2. If the B has no data, then A should translate naturally.