Page 1 of 1

Load data from dynamic CubeView

Posted: Thu Jan 08, 2015 2:29 pm
by Bianca
Hello together,

I try to copy data from a dynamic CubeView.

Prolog:

##################
# definition of source
##################

DatasourceNameForServer = p_Cube;
DataSourceType = 'View';
DatasourceCubeview = V_Name;

- variables p_Cube, p_View, v_Name are parameters
- The source cube is equal to the target cube.
- Only one element within one special dimension (called 'PV') is different for the copy part
- Within the source cube (=target cube) it is unknown how much dimensions are included
- Within the source cube (=target cube) it is unknown at which position/index I can find the special dimension named 'PV' (it is sure that this dimension is within the cube).

Those information should be known for the CellPutN(); that is used within the data tab of the Turbo Integrator.
Lets imagine p_Cube has 4 dimensions and on index number 2 is the special dimension 'PV' and the element ist called 'PV1'... then it should be like:

CellPutN(Value,p_Cube,V1,'PV1',V3,V4);

I tried to get the answer with something like this:

v_counter = 1;

While ( TABDIM(Cube, v_counter) @<> '' );
sDim = TabDim(Cube, v_counter);

IF(v_counter = 1);
v_Dim_at_DimIndex1 = sDim;
ElseIF(v_counter = 2);
v_Dim_at_DimIndex2 = sDim;
ElseIF(v_counter = 3);
v_Dim_at_DimIndex3 = sDim;
.
.
.

But it didn't work!

Now the question:
Is there a way to solve this problem?

Thank you for your help!!!!!

Re: Load data from dynamic CubeView

Posted: Thu Jan 08, 2015 3:32 pm
by lotsaram
I can't really understand exactly what you are asking but if you want a detailed worked example of how to manage dynamically assigning views and filters to copy data look up the process bedrock.cube.data.copy

Re: Load data from dynamic CubeView

Posted: Thu Jan 08, 2015 3:44 pm
by Bianca
thank you for the fast answer.What do you mean with this "bedrock.cube.data.copy" ?
do I have to search this within a special guide?

The process that I want to creat has to be intelligent and should work for many different cubes.
For example:

Cube1
Dim1 = Currency
Dim2 = Week
Dim3 = PV -> source element is 'PV1'

Cube1 should be copied to

Cube1
Dim1 = Currency
Dim2 = Week
Dim3 = PV -> target element is 'PV6'


The next time, the same process will be called to copy another cube:

Cube2
Dim1 = PV -> source element is 'PV3'
Dim2
= Team
Dim3 = Measure
Dim4 = Region

Cube2 should be copied to

Cube2
Dim1 = PV -> target element is 'PV4'
Dim2 = Team
Dim3 = Measure
Dim4 = Region


I need to use a CellPutN() within the data tab to copy the source into the target.
The Syntax for this formula is CellPutN(x, Cube, e1, e2 [,...en]);
what is missing is the number of e1,...en and the information if the dimension 'PV' is like e1 or e3 ......

Re: Load data from dynamic CubeView

Posted: Thu Jan 08, 2015 4:35 pm
by tomok
As far as the PV1 thing is concerned, can't you just do this:

Code: Select all

IF(pVariable_to_Assign_PV1 = 1);
  V1 = 'PV1';
ElSEIF(pVariable_to_Assign_PV1 = 2):
  V2 = 'PV1';
ElSEIF(pVariable_to_Assign_PV1 = 3):
  V3 = 'PV1';
........
ElSEIF(pVariable_to_Assign_PV1 = x):
  Vx = 'PV1';

Re: Load data from dynamic CubeView

Posted: Thu Jan 08, 2015 5:00 pm
by Bianca
what I tried till now is the following:
I know that there is no cube with more then 20 dimensions included.

PROLOG

Code: Select all

##################
# Definition der Quelle    
##################

DatasourceNameForServer = p_Cube;
DataSourceType = 'View';
DatasourceCubeview = V_Name;

DATA

Code: Select all

# find index of dimension PV in actual cube
#####################################

v_counter = 1;

While ( TABDIM(p_Cube, v_counter) @<> '' );
   sDim = TabDim(p_Cube, v_counter);

   IF(v_counter = 1);
      v_Dim_at_DimIndex1 = sDim;
   ElseIF(v_counter = 2);
      v_Dim_at_DimIndex2 = sDim;
   ElseIF(v_counter = 3);
      v_Dim_at_DimIndex3 = sDim;
   ElseIF(v_counter = 4);
      v_Dim_at_DimIndex4 = sDim;
   ElseIF(v_counter = 5);
      v_Dim_at_DimIndex5 = sDim;
   ElseIF(v_counter = 6);
      v_Dim_at_DimIndex6 = sDim;
   ElseIF(v_counter = 7);
      v_Dim_at_DimIndex7 = sDim;
   ElseIF(v_counter = 8);
      v_Dim_at_DimIndex8 = sDim;
   ElseIF(v_counter = 9);
      v_Dim_at_DimIndex9 = sDim;
   ElseIF(v_counter = 10);
      v_Dim_at_DimIndex10 = sDim;
   ElseIF(v_counter = 11);
      v_Dim_at_DimIndex11 = sDim;
   ElseIF(v_counter = 12);
      v_Dim_at_DimIndex12 = sDim;
   ElseIF(v_counter = 13);
      v_Dim_at_DimIndex13 = sDim;
   ElseIF(v_counter = 14);
      v_Dim_at_DimIndex14 = sDim;
   ElseIF(v_counter = 15);
      v_Dim_at_DimIndex15 = sDim;
   ElseIF(v_counter = 16);
      v_Dim_at_DimIndex16 = sDim;
   ElseIF(v_counter = 17);
      v_Dim_at_DimIndex17 = sDim;
   ElseIF(v_counter = 18);
      v_Dim_at_DimIndex18 = sDim;
   ElseIF(v_counter = 19);
      v_Dim_at_DimIndex19 = sDim;
   ElseIF(v_counter = 20);
      v_Dim_at_DimIndex20 = sDim;
   EndIf;

   v_counter = v_counter + 1;

End;

v_number_of_Dimensions = v_counter -1;
The v_number_of_Dimensions can tell me how many e1,...en I need to use.

Code: Select all

If (v_number_of_Dimensions = 2);
  CellPutN(x, Cube, e1, e2); 
ElseIF(v_number_of_Dimensions = 3);
  CellPutN(x, Cube, e1, e2, e3);
.
.
.
.


But how can I check in a clever way which [,...en] is the PV Dimension. Do I need again an if statement with 19 ElseIf parts?

Code: Select all

If (v_Dim_at_DimIndex1 = 'PV');
  e1 = 'PV'; 
  CellPutN(x, Cube, e1, e2);
If (v_Dim_at_DimIndex2 = 'PV');
  e2 = 'PV'; 
  CellPutN(x, Cube, e1, e2);
.
.
.
.
and how can I combine those information without getting really long code?
I'm lost.... :shock:

Re: Load data from dynamic CubeView

Posted: Thu Jan 08, 2015 5:43 pm
by lotsaram
Look up www.bedrocktm1.org I think it has all your requirements pretty much covered.

You will be making more effective use of your time starting from a library and understanding the code there and then maybe adapting some of it than trying to do it yourself from scratch.

Re: Load data from dynamic CubeView

Posted: Fri Jan 09, 2015 6:51 am
by BariAbdul
You can also look at the below link:
http://www.tm1forum.com/viewtopic.php?f ... 659#p18659 Thanks

Re: Load data from dynamic CubeView

Posted: Fri Jan 09, 2015 12:32 pm
by Bianca
the last 2 answers helped me to finish my work.
Thanks for the fast and good help!

In case I need to close this request please tell me how to do it -> I don't want to waste the time of others :D

Re: Load data from dynamic CubeView

Posted: Sat Jan 10, 2015 4:08 am
by BariAbdul
Hi Bianca ,Your reply is as good as closing the issue,That will do.Thanks :)