Page 1 of 1

How to pass dynamic variasbles in CellGetN and CellPutN

Posted: Sun Nov 16, 2014 1:13 pm
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

Re: How to pass dynamic variasbles in CellGetN and CellPutN

Posted: Sun Nov 16, 2014 1:26 pm
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)

Re: How to pass dynamic variasbles in CellGetN and CellPutN

Posted: Wed Nov 19, 2014 6:42 am
by BariAbdul
Thanks Declan,You were right taking off single quotes around vCurrYear and vPreYear did worked.