Page 1 of 1

Can't assign variable

Posted: Wed May 19, 2010 6:35 am
by monishapm
Hi,

Prolog:

NumericSessionVariable('a');
NumericSessionVariable('b');
NumericSessionVariable('c');

StringSessionVariable('d');

Epilog:

b=ELCOMPN('dim','Consolidation');

Metadata:

While(b<1);
d=ELCOMP('dim,'Consloidation,b);
a=if(dayno(today)-Dayno
(ATTRS('dim',d,'StartDate'))>366,
1,0);
If(a=0);
DimensionElementcomponentDelete('dim','Consolidation',d);
DimensionElementcomponentAdd('dim,'Consolidation',d,+1);
EndIf;
b=b-1;
End;


actually i have to get the element in a consolidation as string variable in 'd'. but i am not getting it. Pls correct me whereever I am wrong.

Thanks,

Monisha

Re: Can't assign variable

Posted: Thu May 20, 2010 8:33 pm
by Martin Ryan
Hi Monisha,

First up, please start new topics by creating a new topic, rather than tacking them onto other topics at random. This makes things very confusing for both the original topic and the new topic.

Your problem is that you are inconsistently using the single quote. If you start something with a single quote, you must close it

Code: Select all

d=ELCOMP('dim,'Consloidation,b);
should be

Code: Select all

d=ELCOMP('dim','Consloidation',b);
Martin

Re: Can't assign variable

Posted: Fri May 21, 2010 2:39 am
by VRGultom
http://publib.boulder.ibm.com/infocente ... 30AF9.html

The ELCOMP function returns a child of a consolidated element. This function accepts three arguments: a dimension name, an element name, and an index number for the child.

b=ELCOMPN('dim','Consolidation');

ELCOMPN returns the number of components in a specified element. If the element argument is not a consolidated element, the function returns 0.
Syntax :ELCOMPN(dimension, element)

---------------------------
While(b<1);
d=ELCOMP('dim,'Consloidation,b);
a=if(dayno(today)-Dayno
(ATTRS('dim',d,'StartDate'))>366,
1,0);
If(a=0);
DimensionElementcomponentDelete('dim','Consolidation',d);
DimensionElementcomponentAdd('dim,'Consolidation',d,+1);
EndIf;
b=b-1;
End;
---------------------------
from your code, b must be always 0 because your code : while (b<1). So the loop will be process only if b<1 which is 0

so from this code : b=ELCOMPN('dim','Consolidation');
you have to make sure that your element is not consolidated element to have b =0 to process the loop

Regards
VRG