Page 2 of 3

Re: Numeric values not copying from source to target elaments

Posted: Wed Oct 05, 2016 3:10 pm
by Steve Rowe
Hi Abdul,

Suggest you apply a liberal sprinkling of asciioutput commands to your code so that you can debug it and understand where it is going wrong.
With the complexity of the code in your TI and no knowledge of all the structures that are being tested against it is pretty difficult for anyone else to debug.
Cheers,

Re: Numeric values not copying from source to target elaments

Posted: Wed Oct 05, 2016 3:11 pm
by Wim Gielis
aravind.cgns wrote:Abdul,
Priceless :-)

@Aravind.cgns: do you have the habit to use AsciiOutput to debug your TI processes ?

Re: Numeric values not copying from source to target elaments

Posted: Wed Oct 05, 2016 3:16 pm
by Mark RMBC
Just for my benefit why weren't the numeric values being populated?

regards, Mark (not Abdul)

Re: Numeric values not copying from source to target elaments

Posted: Wed Oct 05, 2016 3:21 pm
by qml
Steve Rowe wrote:Suggest you apply a liberal sprinkling of asciioutput commands to your code so that you can debug it and understand where it is going wrong.
Hi Abdul,

That is what I suggested some 15 posts ago, but it doesn't seem to have struck a chord.

Re: Numeric values not copying from source to target elaments

Posted: Wed Oct 05, 2016 3:40 pm
by BrianL
I prefer using LogOutput over AsciiOuput. I can then leave the debug statements in the code all the time and only enable the logging as needed via the tm1s-log.properties file.

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 6:19 am
by aravind.cgns
Thanks for the replies,

Guys i am using AsciiOuput in my code, when i am trying to execute the subsetelementinsert() with loop variable passing into it , it displays the below error:

Error: Prolog procedure line (380): Unable to insert element "-1" in dimension:subset "Hier Customer:Target View". Position of element exceeds the number of elements in subset + 1.

i am including part of the code where i am encountering the error:

### Determine Cube Substitution ###
m = 1;
while(m<=20);
pDim2 = 'p_Parameters_Cube';
Param3 = Dimnm(pDim2,m);

pCube = CellGetS('Test Control Finance Cube',Param3,'Cube Name');

If( pCube @= '' );
Break;
EndIf;


### Determine Customer dimension Substitution ###

i= 1;
while (i <=50);

pDim = 'p_Parameters';

Param1 = Dimnm(pDim, i);


pSourceCustomer = CellGetS('Test Customer Control Cube',Param1,'Source Customer');
pTargetCustomer = CellGetS('Test Customer Control Cube',Param1,'Target Customer');

### Break the loop if any of the source or target customer not found ###

If( pSourceCustomer @= '' % pTargetCustomer @= '');
Break;
EndIf;

### Determine version dimension Substitution ###

k =1;
while(k<=10);
pDim1 = 'p_Parameters_Version';
Param2 = Dimnm(pDim1,k);

pSourceVersion = CellGetS('Test Version Control Cube',Param2,'Source Version');
pTargetVersion = CellGetS('Test Version Control Cube',Param2,'Target Version');

### Break the loop if any of the source or target version not found ###

If( pSourceVersion @= '' % pTargetVersion @='' );
Break;
EndIf;
.
.
.
.
.
.
.
After the debug checks and paramer validation error occurs in below part of the code:

cTempViewFrom = cViewSource;
cTempSubFrom = cTempViewFrom;

If( ViewExists( pCube, cTempViewFrom ) = 1 );
ViewDestroy( pCube, cTempViewFrom );
EndIf;
ViewCreate( pCube, cTempViewFrom );
If( SubsetExists( pDimension, cTempSubFrom ) = 1 );
SubsetDeleteAllElements( pDimension, cTempSubFrom );
Else;
SubsetCreate( pDimension, cTempSubFrom );
EndIf;
SubsetElementInsert( pDimension, cTempSubFrom, pSourceCustomer, i );-----(Error occurs here)
ViewSubsetAssign( pCube, cTempViewFrom, pDimension, cTempSubFrom );

please suggest me like how to overcome this error

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 6:28 am
by declanr
Change

Code: Select all

  
 SubsetElementInsert( pDimension, cTempSubFrom, pSourceCustomer, i );
To

Code: Select all

  
 SubsetElementInsert( pDimension, cTempSubFrom, pSourceCustomer, SubsetGetSize ( pDimension, cTempSubFrom) + 1 );
[/code

The issue is that "i" inrements every time but the subset size doesnt; so if the first element you tried to add is the 10th tested it was trying to add it into the 10th position in an empty subset... you could also just always use position 1 in the subset assume you don't care about the order.

Edit - just noticed that it looks from your code as if you are destroying the subset for every increment anyway - so you would only ever have 1 element in the subset at a time? If so just use 1.

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 7:08 am
by aravind.cgns
Thanks for the reply declanr, i have changed the code as u suggested.


Below are my two control cubes which has two control cubes one for customer other for version:


Source Customer Target Customer Source Version Target Version
CSCHEST0000 CSCHEST0000 Version 1 Version 2
GIANTCAR000 GIANTCAR000 Current Version 3

after changing the code still i have only one element included in my subsets :
from source view customer subset it is inserting last element 'GIANTCAR000'
from Target view customer subset it is inserting last element 'GIANTCAR000'
from source view version subset it is inserting last element 'Current'
from source view version subset it is inserting last element 'Version 3'

it is doing one to one mapping where i need many to many mapping.It is unable to insert all the elements selected from the control cubes.

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 7:15 am
by Wim Gielis
declanr wrote:Change

Code: Select all

  
 SubsetElementInsert( pDimension, cTempSubFrom, pSourceCustomer, i );
To

Code: Select all

  
 SubsetElementInsert( pDimension, cTempSubFrom, pSourceCustomer, SubsetGetSize ( pDimension, cTempSubFrom) + 1 );
The issue is that "i" inrements every time but the subset size doesnt; so if the first element you tried to add is the 10th tested it was trying to add it into the 10th position in an empty subset... you could also just always use position 1 in the subset assume you don't care about the order.

Edit - just noticed that it looks from your code as if you are destroying the subset for every increment anyway - so you would only ever have 1 element in the subset at a time? If so just use 1.
I prefer a 0:

Code: Select all

  
 SubsetElementInsert( pDimension, cTempSubFrom, pSourceCustomer, 0 );
which has the same result, works always and cannot be easier.

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 7:28 am
by aravind.cgns
wim, I have used the logic u have suggested but still it is unable to create subset with all the elements selected from control cubes.

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 7:51 am
by declanr
aravind.cgns wrote:wim, I have used the logic u have suggested but still it is unable to create subset with all the elements selected from control cubes.
This section:

Code: Select all

If( SubsetExists( pDimension, cTempSubFrom ) = 1 );
SubsetDeleteAllElements( pDimension, cTempSubFrom );
Else;
SubsetCreate( pDimension, cTempSubFrom );
EndIf;
Means before you add a new element you delete all the ones that already exist in the subset... so with it inside your loop you will only ever get one element... you need it before your loop. Same for the viewcreate.

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 8:34 am
by Wim Gielis
... That's why you should use AsciiOutput, like e.g. in:

Code: Select all

AsciiOutput( 'test.txt', 'BEFORE', NumberToString( SubsetGetSize( pDimension, cTempSubFrom )));
SubsetElementInsert( pDimension, cTempSubFrom, pSourceCustomer, 0 );
AsciiOutput( 'test.txt', 'AFTER', NumberToString( SubsetGetSize( pDimension, cTempSubFrom )));
and so on. Thát is debugging. Put the statement before and after and compare both results.
AFTER should be 1 higher than BEFORE.

Also, BEFORE should probably not be 0 (only in the first instance of the loop). Afterwards it should increment like 0, 1, 2, 3, ..., you get the picture (hopefully).

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 10:37 am
by aravind.cgns
thanks declar, it worked well when i have created subset and view before the loop and inserted the elements inside the loop, but it is creating a duplicate value for each element

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 12:34 pm
by Wim Gielis
aravind.cgns wrote:thanks declar, it worked well when i have created subset and view before the loop and inserted the elements inside the loop, but it is creating a duplicate value for each element
That's logical, since you are allowed to add the same element multiple times in the same subset. Just as you could do that manually.

Possible solutions include:
- populate a temporary dimension first, dimensions can only hold unique elements, after which you transfer the dimension elements to a subset in your main dimension
- when inserting an element in a subset, loop over the current subset elements to see if the element already exists in the subset, or not
- just before using your subset after it is filled, loop over it and delete the duplicate elements from the subset
- other

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 1:08 pm
by aravind.cgns
i am not sure like due to the above duplicate elements in subset data is not correctly populating into target cells!!!

Source Customer Target Customer
CSCHEST0000 CSCHEST0000

Source Version Target Version
CURRENT VERSION 1
VERSION 2 VERSION 4

it is copying data from version 2 to both the target versions version 1 and version 4 instead it should copy data from current to version 1 and version 2 to version 4. please look into my attachment and suggest me like my data procedure is writing data correctly into target cells.

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 1:27 pm
by Wim Gielis
aravind.cgns wrote:i am not sure like due to the above duplicate elements in subset data is not correctly populating into target cells!!!

Source Customer Target Customer
CSCHEST0000 CSCHEST0000

Source Version Target Version
CURRENT VERSION 1
VERSION 2 VERSION 4

it is copying data from version 2 to both the target versions version 1 and version 4 instead it should copy data from current to version 1 and version 2 to version 4. please look into my attachment and suggest me like my data procedure is writing data correctly into target cells.
Aravind.cgns,

Please FIRST think about a solution and your cubes, THEN implement it in TI. Not the other way round.
Trial and error is also not the best approach.

Your solution SHOULD look like this:

1. Create a cube with 2 dimensions:
- a linenumber dimension, elements 1 to 20, say
- a measures dimension containing elements Year_Source, Year_Target, Scenario_Source, Scenario_Target, Version_Source, Version_Target, ...
All String elements, it could be picklists. The way you populate the cube is irrelevant, be it rules, TI, someone typing in the element names, it's unimportant as long as the cells contain valid element names in the dimensions

2. Create a TI process that loops over the linenumber dimension. As simple as that !
Check in the relevant dimensions that the input of the user exists.
Within the loop, do ExecuteProcess to the next process

3. Create the process that copies data, again very simple and straightforward.
It's part of what you already have.
Create parameters for Year_Source, Year_Target, Scenario_Source, and so on.

This is the way in which probably every decent TM1 developer would approach this problem.

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 2:01 pm
by aravind.cgns
Thanks wim for the faster response , could you please explain in detail like how the TI process works with execute process, currently i am using 3 different control cubes for cube names , customers and versions.

If i understood correctly you have suggested like to create a single cube to hold all these inputs from control cubes in a single measure dimension ???

help me out to write the TI process i am new to TM1!!! suggest me a sample process i will build my own.

Thanks,
Aravind

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 3:00 pm
by aravind.cgns
wim,

i am able to get all the parameters from the control cubes using loops, the problem is with my data copy logic it has work with combination of customer and version input parameters, i have 20 different cubes where i have to copy the data with the same input parameters, so challenge here is each cube has different number of dimensions. so my cellputs or cellputn should work in such a way that it correctly pick the input parameters.

suggest me like anything to be altered in my data procedure in the attached document.

Re: Numeric values not copying from source to target elaments

Posted: Thu Oct 06, 2016 9:21 pm
by Wim Gielis
aravind.cgns wrote:wim,

i am able to get all the parameters from the control cubes using loops, the problem is with my data copy logic it has work with combination of customer and version input parameters, i have 20 different cubes where i have to copy the data with the same input parameters, so challenge here is each cube has different number of dimensions. so my cellputs or cellputn should work in such a way that it correctly pick the input parameters.
In the OP you mention that you have Bedrock processes, so why not use such generic processes to copy data ?
IIRC Bedrock has processes to copy data when the number of dimensions in the cube is variable.
Such process will then be executed with ExecuteProcess and the correct parameters, within loops over a single control cube (with measures where the user enters his choices).
If you're new to TM1 this will certainly not be easy and I would advise to hire someone with TM1 knowledge for a short period of time to set this up.

Re: Numeric values not copying from source to target elaments

Posted: Wed Oct 19, 2016 9:05 am
by aravind.cgns
Hi Guys,

Is there any workout to identify the index number of an element which is present in measure dimension. I have a measure dimension 'p_Process' which has two elements 'Source Version' and 'Target Version'. The values to these elements are populated by creating dimension picklist from 'Version' dimension.

My cube looks as below:

p_Process
Source Version Target Version
p_Parameters Current Version 1
Parameter1 Version 2 Version 4
Parameter2
Parameter3
Parameter4
Parameter5

I have to identify the index number of 'current' , 'version 1' values in the measure elements which is passed by creating dimension picklist.