Page 1 of 1

copying children from 1 parent to another

Posted: Thu Oct 15, 2009 10:44 am
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

Re: copying children from 1 parent to another

Posted: Thu Oct 15, 2009 7:59 pm
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;

Re: copying children from 1 parent to another

Posted: Fri Oct 16, 2009 11:29 am
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