How to pass dynamic variasbles in CellGetN and CellPutN

Post Reply
BariAbdul
Regular Participant
Posts: 424
Joined: Sat Mar 10, 2012 1:03 pm
OLAP Product: IBM TM1, Planning Analytics, P
Version: PAW 2.0.8
Excel Version: 2019

How to pass dynamic variasbles in CellGetN and CellPutN

Post by BariAbdul »

I have to pass dynamic current year and previous year in CellGetN and CellPutN ,it is giving me an error when the process is run .

Code: Select all

##Defining dynamic current year and previous year##
vCurrYear = TimSt(Now(), '\Y\');

vPrevYear = Timst(Now() - vDaysInAYear,'\Y\', 1)

Code: Select all

Datatab
      NVal= CellGetN('DU_SERVICES_REPORT',SCENERIO,SERVICES, RATE_TA, BUSINESSUNIT, PRODUCTSEQUENCE, PART, ‘CurrYear');

      NVal1= CellGetN('DU_SERVICES_REPORT',SCENERIO,SERVICES, RATE_TA, BUSINESSUNIT, PRODUCTSEQUENCE, PART,'prevYear');

CELLPUTN(NVal,'DU_SERVICES_REPORT_MASTER',SCENERIO,SERVICES, RATE_TA, BUSINESSUNIT, PRODUCTSEQUENCE, PART,'vCurrYear',sDim1CurEl, sDim2CurEl);
CELLPUTN(NVal1,'DU_SERVICES_REPORT_MASTER',SCENERIO,SERVICES, RATE_TA, BUSINESSUNIT, PRODUCTSEQUENCE, PART,'vPrevYear',sDim1CurEl, sDim2CurEl);

Could someone please help me on this one.Thanks
"You Never Fail Until You Stop Trying......"
declanr
MVP
Posts: 1831
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: How to pass dynamic variasbles in CellGetN and CellPutN

Post by declanr »

It would help if you said what the error you get actually is?

Also this returns the year in with a slash after it; is that actually what you want? (e.g. "2014\")
BariAbdul wrote:

Code: Select all

##Defining dynamic current year and previous year##
vCurrYear = TimSt(Now(), '\Y\');

And instead of actually putting your variable into the CellGet/CellPuts you have encased the name in quotes meaning that you are just using the string "vCurrYear" which I doubt is a dimension element.
BariAbdul wrote:

Code: Select all

CELLPUTN(NVal,'DU_SERVICES_REPORT_MASTER',SCENERIO,SERVICES, RATE_TA, BUSINESSUNIT, PRODUCTSEQUENCE, PART,'vCurrYear',sDim1CurEl, sDim2CurEl);
When you get errors with things like this it is usually a good port of call to AsciiOutput everything that is going into your code so you can see what it is actually parsing e.g.

Code: Select all

AsciiOutput(<MyFilePath>,'DU_SERVICES_REPORT_MASTER',SCENERIO,SERVICES, RATE_TA, BUSINESSUNIT, PRODUCTSEQUENCE, PART,'vCurrYear',sDim1CurEl, sDim2CurEl);
Then you will be able to see every thing you are trying to use as an element name and quickly check whether it actually is one.


EDIT - Actually I thought about it and a TimSt format of "\Y\" wouldn't return a year with a slash after it but either way the extra slash isn't needed; you just have to put it there if you are going to follow with another format identifier (e.g. \m)
Declan Rodger
BariAbdul
Regular Participant
Posts: 424
Joined: Sat Mar 10, 2012 1:03 pm
OLAP Product: IBM TM1, Planning Analytics, P
Version: PAW 2.0.8
Excel Version: 2019

Re: How to pass dynamic variasbles in CellGetN and CellPutN

Post by BariAbdul »

Thanks Declan,You were right taking off single quotes around vCurrYear and vPreYear did worked.
"You Never Fail Until You Stop Trying......"
Post Reply