Using datasource as parameter for ZeroOut

Post Reply
telula
Posts: 99
Joined: Tue Nov 18, 2008 5:40 am

Using datasource as parameter for ZeroOut

Post by telula »

Hello,
I have the code snippet below in Prolog.
I have a text file as datasource with Period_Name, Account, Project, Amount in the Variables tab.

I have tried to use the Period_Name from the Variables tab but it doesnt seem to work.I get a "Dimension Element not found" at SubsetElementInsert(vDimName2, vSubName, CurYr, 1); line.

How can use solve this problem?


CurYr=’20’|SUBST(Period_Name,5,2);
CurMth= SUBST(Period_Name,1,3);


vCube = 'Reporting';
vDimName1 = 'Month';
vDimName2 = 'Year';
vTemp = 'SystemUseOnly_Load' | STR(RAND, 10, 8);
vViewName = vTemp;
vSubName = vTemp;

SubsetCreate(vDimName1, vSubName);
SubsetCreate(vDimName2, vSubName);
SubsetElementInsert(vDimName1, vSubName, CurMth, 1);
SubsetElementInsert(vDimName2, vSubName, CurYr, 1);

ViewCreate(vCube, vViewName);
ViewSubsetAssign(vCube, vViewName, vDimName1, vSubName);
ViewSubsetAssign(vCube, vViewName, vDimName2, vSubName);
ViewZeroOut(vCube, vViewName);
ViewDestroy(vCube, vViewName);
SubsetDestroy(vDimName1, vSubName);
SubsetDestroy(vDimName2, vSubName);
bskalli
Posts: 21
Joined: Wed May 14, 2008 7:53 am

Re: Using datasource as parameter for ZeroOut

Post by bskalli »

you can not read the Datasource in prolog.
ajain86
Community Contributor
Posts: 132
Joined: Thu Oct 15, 2009 7:45 pm
OLAP Product: TM1
Version: 9.4.1 9.5 9.5.1
Excel Version: 2003 2007

Re: Using datasource as parameter for ZeroOut

Post by ajain86 »

I would just split out your code into the prolog, data, and the epilog tabs.

Prolog:

Code: Select all

CurYr=’20’|SUBST(Period_Name,5,2);
CurMth= SUBST(Period_Name,1,3);

vCube = 'Reporting';
vDimName1 = 'Month';
vDimName2 = 'Year';
vTemp = 'SystemUseOnly_Load' | STR(RAND, 10, 8);
vViewName = vTemp;
vSubName = vTemp;

SubsetCreate(vDimName1, vSubName);
SubsetCreate(vDimName2, vSubName);

ViewCreate(vCube, vViewName);
ViewSubsetAssign(vCube, vViewName, vDimName1, vSubName);
ViewSubsetAssign(vCube, vViewName, vDimName2, vSubName);
Data:

Code: Select all

SubsetElementInsert(vDimName1, vSubName, CurMth, 1);
SubsetElementInsert(vDimName2, vSubName, CurYr, 1);
Epilog:

Code: Select all

ViewZeroOut(vCube, vViewName);
ViewDestroy(vCube, vViewName);
SubsetDestroy(vDimName1, vSubName);
SubsetDestroy(vDimName2, vSubName);
Ankur Jain
tomok
MVP
Posts: 2832
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: Using datasource as parameter for ZeroOut

Post by tomok »

ajain86 wrote:I would just split out your code into the prolog, data, and the epilog tabs.
You're almost there. The problem is being caused by the following statements being in the Prolog tab:

CurYr=’20’|SUBST(Period_Name,5,2);
CurMth= SUBST(Period_Name,1,3);

because they reference a variable contained in the data and that is not available until the prolog has finished processing. If you modify the suggested split to also put these two statements in the Data tab the error will stop. I don't know the structure of your text file so doing this may not make sense. YMMV.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
ajain86
Community Contributor
Posts: 132
Joined: Thu Oct 15, 2009 7:45 pm
OLAP Product: TM1
Version: 9.4.1 9.5 9.5.1
Excel Version: 2003 2007

Re: Using datasource as parameter for ZeroOut

Post by ajain86 »

tomok, you are correct. thanks for catching my mistake.

I guess the morning coffee's effect have not kicked in yet.
Ankur Jain
telula
Posts: 99
Joined: Tue Nov 18, 2008 5:40 am

Re: Using datasource as parameter for ZeroOut

Post by telula »

Thanks.
So with the split, it means that the zero out will be in 1 TI and the data loading in a separate TI right?
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Using datasource as parameter for ZeroOut

Post by Steve Rowe »

I've only skimmed the thread whilst listening to the end of the first day of the second test match. WooT!

Anyway you can do both the VZO and the dataload in the one TI.

In the prolog put a variable
ixFirstRow=1;

as well as all your view building stuff already listed

In the metadata do the subset element inserts as well as all the metadata stuff you are already doing as part of your data load.

Then in the data tab have at the beginning.
If (ixFirstRow=1);
ViewZeroOut(vCube, vViewName);
ixFirstRow=2;
EndIf;
Your data loading code;

HTH
Cheers,

Steve
Technical Director
www.infocat.co.uk
ajain86
Community Contributor
Posts: 132
Joined: Thu Oct 15, 2009 7:45 pm
OLAP Product: TM1
Version: 9.4.1 9.5 9.5.1
Excel Version: 2003 2007

Re: Using datasource as parameter for ZeroOut

Post by ajain86 »

As a suggestion, I would split the 2. This way you can run either without having to run both.
Ankur Jain
Post Reply