Page 1 of 1

CubeExists returns 0 even the cube exists

Posted: Fri Jul 15, 2016 2:23 pm
by vladino
Hi all,
I found a strange behavior of CubeExists function.

I have several cubes on a TM1 server. For some of them CubeExists returns 1 but for some others it returns 0.

Does anyone know why is that? I haven't found any difference between these cubes...

BR
Vladino

Re: CubeExists returns 0 even the cube exists

Posted: Fri Jul 15, 2016 2:34 pm
by qml
vladino wrote:I found a strange behavior of CubeExists function.

I have several cubes on a TM1 server. For some of them CubeExists returns 1 but for some others it returns 0.

Does anyone know why is that? I haven't found any difference between these cubes...
Are you absolutely sure you've eliminated any human error like typos?

What are the contents (if any) of the weird_cubes.txt file when you run the bellow code snippet in a TI process?

Code: Select all

nDimSize = DIMSIZ( '}Cubes' );

i = 1;
WHILE( i <= nDimSize );

	sCube = DIMNM( '}Cubes', i );

	IF( CubeExists( sCube ) = 0 );

		ASCIIOUTPUT( 'weird_cubes.txt', sCube );
	ENDIF;

	i = i + 1;
END;

Re: CubeExists returns 0 even the cube exists

Posted: Fri Jul 15, 2016 3:01 pm
by vladino
qml wrote: Are you absolutely sure you've eliminated any human error like typos?

What are the contents (if any) of the weird_cubes.txt file when you run the bellow code snippet in a TI process?

Code: Select all

nDimSize = DIMSIZ( '}Cubes' );

i = 1;
WHILE( i <= nDimSize );

	sCube = DIMNM( '}Cubes', i );

	IF( CubeExists( sCube ) = 0 );

		ASCIIOUTPUT( 'weird_cubes.txt', sCube );
	ENDIF;

	i = i + 1;
END;
I was absolutely sure before I ran your code... This is really strange.

I'm running Bedrock's ExportViewToFile using exactly the same approach as you have in your code (i.e. looping over }Cubes dim). That's where I found this problem - when the code passes sCube into Bedrock's process it checks whether the cube exists or not. And it returns error for one specific cube.
So I prepared a small TI code with the name of the affected cube in local string variable. And it throws an error. But when I run your code it gives 1 for all cubes...

Could you explain this behavior? Because I don't understand...

BR
Vladislav

EDIT: Before I'm calling ViewExportToFile I'm calling View.Create with the same sCube parameter. The view is created but the data is not exported as ViewExportToFile returns error. But View.Create also checks whether the cube exists and it goes on and creates the view... This is really strange.

Re: CubeExists returns 0 even the cube exists

Posted: Fri Jul 15, 2016 3:20 pm
by vladino
Now I'm totally lost...

I have 3 cubes:
ObchodniPlan
ObchodniPlanReport
ObchodniPlanVystup

I have this code:

Code: Select all

nDimSize = DIMSIZ( '}Cubes' );

i = 1;
WHILE( i <= nDimSize );

   sCube = DIMNM( '}Cubes', i );

   IF( CubeExists( sCube ) = 1 );
      IF( SUBST(sCube, 1, 8) @= 'Obchodni');
         TextOutput('Cubes.txt', sCube, '1');
      ELSE;
         TextOutput('Cubes.txt', sCube, '0');
      ENDIF;
   ENDIF;

   i = i + 1;
END;
All above mentioned three cubes returns 0... WHY???

Re: CubeExists returns 0 even the cube exists

Posted: Fri Jul 15, 2016 3:28 pm
by qml
vladino wrote:All above mentioned three cubes returns 0... WHY???
What do you mean exactly? Are they printed out to cubes.txt by your code or not? If they are, even if with a "0" flag next to them, then CubeExists surely returns 1 for them, exactly as expected. The problem would then be in the cube name comparison i.e. the first 8 characters of these cubes' names are not 'Obchodni' at all. There might be an unprintable character in these cubes' names or some typo somewhere, but I really don't think CubeExists is your problem here.

Re: CubeExists returns 0 even the cube exists

Posted: Fri Jul 15, 2016 3:38 pm
by vladino
qml wrote: What do you mean exactly? Are they printed out to cubes.txt by your code or not? If they are, even if with a "0" flag next to them, then CubeExists surely returns 1 for them, exactly as expected. The problem would then be in the cube name comparison i.e. the first 8 characters of these cubes' names are not 'Obchodni' at all. There might be an unprintable character in these cubes' names or some typo somewhere, but I really don't think CubeExists is your problem here.
This was just a test but my problem is the first question - I'm looping over all cubes and passing sCube parameter to View.Create and View.ExportToFile. And these two functions returns 0 for CubeExists but I don't know why. If I would be passing the string variable into it I would understand there might be a typo but I'm passing the sCube parameter which I get from DIMNM function.

Code: Select all

nDimSize = DIMSIZ( '}Cubes' );
i = 1;
WHILE( i <= nDimSize );

   sCube = DIMNM( '}Cubes', i );

   ExecuteProcess('Bedrock.Cube.View.Create',
     'pCube',sCube,
     'pView','ExportView',
     'pFilter','Year: 2016',
     'pSuppressZero',1,
     'pSuppressConsol',1,
     'pSuppressRules',0,
     'pDimensionDelim','&',
     'pElementStartDelim',':',
     'pElementDelim','+',
     'pDebug',1
     );
      
   ExecuteProcess('Bedrock.Cube.Data.ViewExportToFile',
     'pCube',sCube,
     'pExportPath','export',
     'pExportFile','ExportView.txt',
     'pView','ExportView',
     'pSkipRuleValues',0,
     'pSkipCalcValues',1,
     'pSkipNullValues',1,
     'pTitleRecord',0,
     'pDebug',1
     );

   i = i + 1;
End;

Re: CubeExists returns 0 even the cube exists

Posted: Fri Jul 15, 2016 3:51 pm
by qml
Sorry, I'm out of ideas then. Do you have another copy of the model and/or another version of TM1 to test it in?

Re: CubeExists returns 0 even the cube exists

Posted: Fri Jul 15, 2016 6:14 pm
by Wim Gielis
Hello,

Do you see the same behaviour after stopping and starting the TM1 model ?

Re: CubeExists returns 0 even the cube exists

Posted: Sat Jul 16, 2016 7:54 am
by lotsaram
The }Cubes dimension is compiled at server startup from a listing of all .cub files in the data directories. If however one of the dimensions in the cube ISN'T present in the directory then the cube won't load and be available on the server. (But it will still be in the }Cubes dimension). Such "cubes" would return 0 to CubeExists.

I think this might explain your situation. So
- do you have any cube load errors on startup?
- have you trapped the names of the cubes causing the error and are they actually present in the server?

Re: CubeExists returns 0 even the cube exists

Posted: Thu Jul 21, 2016 8:15 am
by vladino
Hello guys,
thank you all for your valuable posts.

I have restarted the TM1 service and voila - now it works!

It's weird because there were no changes in the model so I don't understand it. There were no cube load errors, all cubes and dimensions are on the server...
Anyway, the problem is solved for now.

Thanks again!

Vladino