copying children from 1 parent to another

Post Reply
Joffes
Posts: 8
Joined: Thu Aug 28, 2008 6:56 am
OLAP Product: Tm1
Version: 9.4.1
Excel Version: 2003 2007
Location: Johannesburg, South Africa
Contact:

copying children from 1 parent to another

Post by Joffes »

Hi guys,

I am trying to write a process to copy children from 1 parent to another.
I am using a subset of the n level elements as a a start and parameters for the from and to parents.
I have 2 attributes project no and task no. My dimension looks like:

All projects project no task no
1 1
1.1 1 1
1.2 1 2
1.3 1 3
2
2.1 2 1
2.2 2 2
3
4
5

So I would like to copy the children of 1 to 5 and end up with
All projects
1
1.1
1.2
1.3
2
2.1
2.2
3
4
5
5.1
5.2
5.3


My current code looks as such:
DimName='Project_Tasks';
Project=ATTRS(DimName,Project_Tasks,'Project');
TaskNo=ATTRS(DimName,Project_Tasks,'Task No');

IF (ATTRS(DimName,Project_Tasks,'Project') @= CopyFrom);
DimensionElementInsert(Project_Tasks,'',CopyTo|'.'|TaskNo,'N');
ELSE;
Itemskip;
ENDIF;

Any suggestions?

Thanks
Steve
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: copying children from 1 parent to another

Post by ajain86 »

I assume you have defined the variable CopyForm, CopyTo, Project_Tasks.
If Project_Tasks was actually supposed to be the dimension name and not a variable, then it must be in single quotes.

Can you show how they are defined.

I personally would the part of CopyTo|'.'|TaskNo in a variable as I think that is easier to maintain.

Also, assuming CopyTo and TaskNo are defined properly, then they would be referenced like this:

Assumptions:
CopyFrom = '1';
CopyTo = '5';
Project_Tasks = ?

DimName='Project_Tasks';
Project=ATTRS(DimName,Project_Tasks,'Project');
TaskNo=ATTRS(DimName,Project_Tasks,'Task No');

IF (Project @= CopyFrom);
sNew = ''| CopyTo |'.'| TaskNo |'';
DimensionElementInsert(DimName,'',sNew,'N');
ELSE;
Itemskip;
ENDIF;
Ankur Jain
Joffes
Posts: 8
Joined: Thu Aug 28, 2008 6:56 am
OLAP Product: Tm1
Version: 9.4.1
Excel Version: 2003 2007
Location: Johannesburg, South Africa
Contact:

Re: copying children from 1 parent to another

Post by Joffes »

CopyFrom and CopyTo are Parameters which should be variable.
Project_Tasks is defined as a variable and is a subset of all the n level elements in my dimension.

I'll look into defining the CopyTo|'.'|TaskNo into a variable
Post Reply