CellPutN erase other elements value

Post Reply
creahui
Posts: 4
Joined: Thu Jul 28, 2016 10:33 am
OLAP Product: TM1
Version: 11.7
Excel Version: 2016

CellPutN erase other elements value

Post by creahui »

Hi all,

I'd like to transfer, say two Account figures from one scenario to another.
in Prolog, the Account view already limited to

Code: Select all

#Account
sDim = cDimAccount;
If (SubsetExists(sDim, cSub) = 0);
    SubsetCreate(sDim, cSub);
Endif;
SubsetDeleteAllElements(sDim, cSub);
SubsetElementInsert(sDim, cSub, cAccount1, 1);
SubsetElementInsert(sDim, cSub, cAccount2, 2);
ViewSubsetAssign(cCube, cViewSource, sDim, cSub);
Then in Data, it is even as-if hardcoded to limit to write into these two account only. However after running the process, all other Accounts figures are cleared, except the two Accounts figures remain. I am confused because isn't CellPutN will only affect the intersection of all dimension only? Thank you very much

Code: Select all

If (vAccount @= cAccount1);
    If (CellIsUpdateable(cCube, cTargetScenario, 'WIP', ..., vMonth, ..., cAccount1, vMeasure) = 1);
    CellPutN(vValue, cCube, cTargetScenario, 'WIP', ..., vMonth, ..., cAccount1, vMeasure) ;
    Endif;
        Itemskip;
Endif;

If (vAccount @= cAccount2);
    If (CellIsUpdateable(cCube, cTargetScenario, 'WIP', ..., vMonth, ..., cAccount2, vMeasure) = 1);
    CellPutN(vValue, cCube, cTargetScenario, 'WIP', ..., vMonth, ..., cAccount2, vMeasure) ;
    Endif;
        Itemskip;
Endif;
creahui
Posts: 4
Joined: Thu Jul 28, 2016 10:33 am
OLAP Product: TM1
Version: 11.7
Excel Version: 2016

Re: CellPutN erase other elements value

Post by creahui »

Sorry for my problem raised here, it seems it is a 'common sense' for developers out there but I just learn and would like to share.

After spending some time checking the prolog, there are defined 'cVeiwSource' and 'cViewTarget'
I was simply ignoring the 'cViewTarget' as I did not know its purpose in the code.

At the end of the Prolog there is a Bedrock.Cube.Data.Clear, I wonder what it is used for then I googled it
According to this page,
If no view (pView) or filter (pFilter) is specified, the entire cube(s) will be cleared out.
So I added the pfilter to include dim Account and it works fine now, the figures in other dimension remains, and my intended figures with that Account are transferred from other scenario.

But I got a question, does the pfilter means in Bedrock.Cube.Data.Clear, will clear that particular filtered dimension, and write back data from 'Data' tab? And also preserve other intersections not specific in that pfilter? Thanks a lot again
User avatar
Alan Kirk
Site Admin
Posts: 6606
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: CellPutN erase other elements value

Post by Alan Kirk »

creahui wrote: Fri Aug 28, 2020 6:49 am
If no view (pView) or filter (pFilter) is specified, the entire cube(s) will be cleared out.
But I got a question, does the pfilter means in Bedrock.Cube.Data.Clear, will clear that particular filtered dimension, and write back data from 'Data' tab? And also preserve other intersections not specific in that pfilter? Thanks a lot again
I have to start with a disclaimer that I'm moving away from using Bedrock. {Edit: For reasons now discussed in this thread}

On which point... you'd need to look at the code to see what it does. You've given the name as Bedrock.Cube.Data.Clear which, you will doubtless be advised, is not the current version. It could be version 2, or it could be version 3. It won't be version 4 because that is }bedrock.cube.data.clear, note the leading brace and the lower case syntax for Linux types. The help page that you've pointed to relates to version 4.

Interestingly in version 3 (or the copy that I have) the absence of a pFilter argument leads to a ProcessQuit statement, not to the clearing of the entire cube. If you want to clear out the entire cube you need to pass to the parameter the text "Clear Cube"... which is a sensible precaution. This is different in V4 but to be honest I haven't looked much at V4 since I decided to move to my own set of generic processes. In the V4 process it looks like it was SUPPOSED to quit if there was no view AND no filter, but the ProcessBreak line is commented out. However that's academic since from the process name you're clearly using an earlier version.

Just to be clear, though, when you're talking about it writing back in the Data tab, this is something quite separate to the Bedrock process. You make the call to the Bedrock process in the Prolog, and the Bedrock process is a "black box" which "does something"; in this case zero out some data. Any code that you have in the Data tab will execute and write whatever you've defined (the code in your first post) regardless of whether the Bedrock process succeeds or not.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
Post Reply