Page 1 of 1

CellGetN and CellPutN issue

Posted: Wed Mar 05, 2014 5:53 am
by BariAbdul
I am using CellGetN and CellPutN to add a numeric value in the Cube.When cube is empty and although I have defined variable value 500 ,When it should show '0+500' as 500 it still shows 0 when I open the Cube view,But when I enter manually 1 in the targeted cells and runs again It shows 1001 taking in to account the previous value. Could someone Please help me what could be the reason? Thanks.

Code: Select all

nVariable= 500;
NewElement=CellGetN('CellCube','ProductA','CustomerA','RegionA',cmeasures);
CreatedVariable=nVariable +NewElement ;
CellPutN( CreatedVariable , 'CellCube','ProductA','CustomerA','RegionA',cmeasures); 

Re: CellGetN and CellPutN issue

Posted: Wed Mar 05, 2014 6:04 am
by Alan Kirk
BariAbdul wrote:I am using CellGetN and CellPutN to add a numeric value in the Cube.When cube is empty and although I have defined variable value 500 ,When it should show '0+500' as 500 it still shows 0 when I open the Cube view,But when I enter manually 1 in the targeted cells and runs again It shows 1001 taking in to account the previous value. Could someone Please help me what could be the reason? Thanks.

Code: Select all

nVariable= 500;
NewElement=CellGetN('CellCube','ProductA','CustomerA','RegionA',cmeasures);
CreatedVariable=nVariable +NewElement ;
CellPutN( CreatedVariable , 'CellCube','ProductA','CustomerA','RegionA',cmeasures); 
The obvious issues:
(a) There's no way that the code that you're describing is going to create a value of 1001 from a base value of 1 unless you're either running it twice or you have the same code on both the Metadata and Data tabs. Or haven't supplied the real code in your question. Speaking of which, you haven't indicated which tab(s) you do have the code on.
(b) The fact that it doesn't do anything when the value is 0 but does when the value is 1 suggests that you have a data source issue. Speaking of which, you haven't indicated the data source either but I'm betting that it's a cube view. If that is indeed the case you most likely have zeroes suppressed on the view. (And if you don't, that's probably unwise given the number of possible combinations.) If that's the case, then when the original value is 0 it's probably not part of your data source. When it's 1, it is.

If it's not part of the data source, then your code will never be executed for that combination.

Re: CellGetN and CellPutN issue

Posted: Wed Mar 05, 2014 7:20 am
by BariAbdul
[quote(a) There's no way that the code that you're describing is going to create a value of 1001 from a base value of 1 unless you're either running it twice or you have the same code on both the Metadata and Data tabs. Or haven't supplied the real code in your question. Speaking of which, you haven't indicated which tab(s) you do have the code on][/quote]

Thanks a lot ,Alan,As always you are spot on.
You are right I have to run it twice to get 1001 and I did had it in metadata and data tab but when eliminated from metadata tab I was still having the same issue.Now the code is in the Data tab.
(b) The fact that it doesn't do anything when the value is 0 but does when the value is 1 suggests that you have a data source issue. Speaking of which, you haven't indicated the data source either but I'm betting that it's a cube view. If that is indeed the case you most likely have zeroes suppressed on the view
b)You are also correct that it is View as a source,In fact I have created the view from the same cube and used it as a source.It has no zero suppressed on, Could it be due to the fact this cube was empty with zero values is cause of the issue.
If that's the case, then when the original value is 0 it's probably not part of your data source. When it's 1, it is.

If it's not part of the data source, then your code will never be executed for that combination.
My apologies,I am not getting what you are actually trying to say here.Thanks a lot again.

Re: CellGetN and CellPutN issue

Posted: Wed Mar 05, 2014 9:19 pm
by Steve Rowe
What I think Alan is getting at is the following.

A. You have the cell that you are updating set to the data source of your TI.
B. The Metadata and Data tab is processed once for every (usually non-zero) row in the data source.

So if you start off with your cell =0 and then run the TI then the data and metadata tab is not executed at all and so your cell =0 at the end.

If you start off with the cell = 1 then your code executes twice, once each on the metadata and data tabs, leaving you with 1001.

You say "It has no zero suppressed on", I'm guessing that you suffering from the difference between a cube viewer view and a data source view, although they are broadly similar they are fundamentally different objects. So if your cube viewer view has been set as a data source and you have saved it with zero suppression off, this does not mean that your data source is zero suppressed.

To access the view as a data source definition you need to right click on the view object and select "Export as Text " (or maybe ASCII) and set the view up in this dialogue box. To set up a brand new one right click on the cube object itself.

The above view confusion is a long standing issue that IBM (and Applix and Cognos) have not addressed.

Anyway, hope this helps you understand what is going on.

Cheers,

Re: CellGetN and CellPutN issue

Posted: Thu Mar 06, 2014 4:19 am
by BariAbdul
Thanks Alan and Steve,It makes sense now,Appreciate your help.

Re: CellGetN and CellPutN issue

Posted: Thu Mar 06, 2014 4:47 am
by PlanningDev
FYI you no longer need to peform a CellGetN to variable and then use (Value + CellGetN Variable). There is a new function as of version 10 called CellIncrementN which will peform this operation for you.

1 less line of code right!