Hello TM1 forum,I am struggling with this particular issue for sometime and quite obvious I am not getting how cellputN really works,Here is my scenerio :I am trying to copy data from Budget version1 to Budget version 2 across the cube(Please find attached )
Now I have this basic question If I have to copy the data between the versions and If I have hundreds of elements do I have to define each intersection for i.e CellPutN(Value,Cube,Element1,Element2,....),Couldn't I simply pass on the variables declared in variables tab.I would be extremely grateful for the your help.
My Dimensions are :
Customer Product_copy
Customers(Consolidate) Produts(Consolidated)
CustomerA ProductA
CustomerB ProductB
CustomerC ProductC
CellPutN not copying the data
-
- Posts: 43
- Joined: Fri Aug 01, 2014 5:17 pm
- OLAP Product: Cognos
- Version: 10.1.1
- Excel Version: 2010
CellPutN not copying the data
- Attachments
-
- Script.docx
- (41.97 KiB) Downloaded 166 times
-
- Site Admin
- Posts: 6667
- 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 not copying the data
Better to put the code in the body of the question; some people aren't apt to download attachments for obvious reasons (unless for some reason you need to put the whole process in) and it's easier and clearer for everyone who reads the thread to understand what's being talked about.Moh wrote:Hello TM1 forum,I am struggling with this particular issue for sometime and quite obvious I am not getting how cellputN really works,Here is my scenerio :I am trying to copy data from Budget version1 to Budget version 2 across the cube(Please find attached )
Now I have this basic question If I have to copy the data between the versions and If I have hundreds of elements do I have to define each intersection for i.e CellPutN(Value,Cube,Element1,Element2,....),Couldn't I simply pass on the variables declared in variables tab.I would be extremely grateful for the your help.
My Dimensions are :
Customer Product_copy
Customers(Consolidate) Produts(Consolidated)
CustomerA ProductA
CustomerB ProductB
CustomerC ProductC
The code that you have is:
Code: Select all
#****Begin: Generated Statements***
#****End: Generated Statements****
vCube='cpyCube';
sView='View';
Ver='Versions';
IF
(VIEWEXISTS(vCube,sView)=1);
VIEWDESTROY(vCube,sView);
ENDIF;
VIEWCREATE(vCube,sView);
IF(SubsetExists('Versions', 'sSub')=1);
SubsetDestroy('Versions', 'sSub');
ENDIF;
Subsetcreate ('Versions', 'sSub');
SubsetElementInsert ('Versions', 'sSub','BudgetVersion2' ,1);
#ViewSubsetAssign(Cube, ViewName, DimName, SubName);
VIEWSUBSETASSIGN(vCube,'View', 'Versions', 'sSub');
ViewZeroOut(vCube,sView);
tview= 'FromVersion';
tsub='FromSubset';
IF
(VIEWEXISTS(vCube,tView)=1);
VIEWDESTROY(vCube,tView);
ENDIF;
VIEWCREATE(vCube,tView);
If
(SUBSETEXISTS('Versions','tsub')=0);
SUBSETCREATE('Versions','tsub');
ENDIF;
VIEWSUBSETASSIGN(vCube,tview, 'Versions', 'tSub');
CellPutN(Value,'cpyCube','vCustomer','vProduct_copy','Budget version 2', 'Quantity' );
There are a couple of things happening here.
One is that it isn't clear which tab or tabs you're doing this on. On the one hand you shouldn't be constantly breaking down and recreating views and subsets in the Data or Metadata tab; you do that in the Prolog. On the other hand you don't do a CellPutN in the Prolog since it has no context there; you do that on the Data tab, typically.
The main thing that you're missing seems to be an understanding of the difference between a variable and a literal string.
The data tab will read through each line of your data source one by one.
For each line, it will assign each column to a separate variable such as, in this case, vCustomer, vProduct and so on. This variable is simply a container (for want of a better term) for the element that is being read, just as the variable Value presumably contains the value.
However by putting quotes around those in your CellPutN you aren't using the variables, you're using literal expressions. So instead of telling the CellPutN to "write to whatever customer element is contained in the variable vCustomer", you're telling it "write to the customer element that is actually named 'vCustomer'". And of course there is no such element, which is why you're getting an error.
Get rid of the quote marks around the variable names like vCustomer and vProduct_Copy. But not things which really ARE literal strings which state element names like (I'm guessing) 'Budget version 2' and 'Quantity'.) That should rid you of the first problem that you have at least.
"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.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-
- Posts: 43
- Joined: Fri Aug 01, 2014 5:17 pm
- OLAP Product: Cognos
- Version: 10.1.1
- Excel Version: 2010
Re: CellPutN not copying the data
Great,It did resolved my problem,Thanks.Sorry, I should have mentioned before, the whole code except CellPUTN was in prolog and CellPutN was in data tab.