Page 1 of 1

DatasourceCubeView question

Posted: Mon Nov 16, 2009 1:57 pm
by job67
Firstly, let me put things in perspective.

Until 2 weeks ago I had never seen TM1 in any shape or form and I am now working as a TM1 developer. (My new boss did know this so I haven't claimed I knew TM1 to get the job - I just have a development background). I am the only TM1 developer in the office and I am still waiting to go on any form of training course! So I apologise in advance if the question I am about to ask is very simple, but I don't have any other reference points.

I am trying to write a process in TI that will allow me to do the same bit processing on various cubes using a specific view as a datasource. All the cubes have the same dimensions and all the views are set up in the same order.

I am using a simple .csv file (that has 2 columns - one for cube name and one for cube view) as the data source for the process. I read this list in and for each row use the cube name as DataSourceNameForServer and the view name as DatasourceCubeview. (I have checked that the correct values are being set by outputting to a file.)

However, I'm now stuck as I want to use the data in the view - initially to just output it to a file - but I am unsure of how to define and reference the variables in the view so that I can use them.

I have searched as many likely things as I can think of but cannot find the answer, although I'm not sure what I am looking for to be honest so I may well have missed it.

I hope the above makes some sort of sense and any help will be very gratefully received.

Many thanks in advance

Elton

Re: DatasourceCubeView question

Posted: Mon Nov 16, 2009 4:15 pm
by jim wood
Hello and welcome to the world of TM1. I hope in brings you as much fun as the rest of us!! :twisted:

Now if I get the nature of your query right then you may want to look at the TI function asciioutput. This is used within the data / metadata tabs to output data to a cma file. If I remember rightly there is some guideance on how to use the function in TM1 help.

I hope this helps,

Jim.

Re: DatasourceCubeView question

Posted: Mon Nov 16, 2009 4:26 pm
by job67
jim wood wrote:Hello and welcome to the world of TM1. I hope in brings you as much fun as the rest of us!! :twisted:
Jim, not sure if fun is the word, but thanks
jim wood wrote:Now if I get the nature of your query right then you may want to look at the TI function asciioutput. This is used within the data / metadata tabs to output data to a cma file. If I remember rightly there is some guideance on how to use the function in TM1 help.
Sorry, I don't think I've explained myself.

I'm Ok with creating the file itself, it's just how to parameterise the values in the view so that I can send them to the file. (If I actually use one of the views as the data source, then I can ouput the data fine as the variables are already created in the process.)

Re: DatasourceCubeView question

Posted: Mon Nov 16, 2009 4:40 pm
by jim wood
I'm not sure what you mean by parametarise? You can manage your input by changing the input view and you control what goes in to the file by only selecting the the dimension values that you need. (You are setting all variables as "other" in the variables tab? this gives you the ability to use the variables you need only and ignore the ones you don't want also you can then create some scripts based on these variables using other TI functions)

Re: DatasourceCubeView question

Posted: Mon Nov 16, 2009 11:40 pm
by lotsaram
job67 wrote:I am using a simple .csv file (that has 2 columns - one for cube name and one for cube view) as the data source for the process. I read this list in and for each row use the cube name as DataSourceNameForServer and the view name as DatasourceCubeview. (I have checked that the correct values are being set by outputting to a file.)
Hi Elton, welcome to the forum.

You might want to try stating what you are trying to do again and also post some code and screenshots as it really isn't clear what you are trying to do. If I understand the section I have quoted then possibly you are well and truly off track! You cannot use DataSourceNameForServer and DatasourceCubeView on the Metadata or Data tabs as a data source is being read, these commands can only be used on the Prolog tab to assign a data source to the current process not to other processes.

If you are trying to use the CSV source to run an export of those views then what you could do is write a generic process with a cube view source (the cube used as the datasource to set up the process will have to have at least as many dimensions as the maximum expected from the list of cubes) which does an ASCIIOutput on the data tab. This process should have 2 parameters being the cube and view which will be used on the Prolog to assign DataSourceNameForServer and DatasourceCubeView. This process should be called using ExecuteProcess on the Data tab of the process you are trying to write with the CSV source and pass field 1 as the DataSourceNameForServer and field 2 as the DatasourceCubeView parameters.

That might not make sense as I could be barking up the wrong tree alltogether. If so I really think it would help if you tried again to define your problem and what you are trying to do.

Re: DatasourceCubeView question

Posted: Tue Nov 17, 2009 8:31 am
by job67
lotsaram wrote: You might want to try stating what you are trying to do again and also post some code and screenshots as it really isn't clear what you are trying to do. If I understand the section I have quoted then possibly you are well and truly off track! You cannot use DataSourceNameForServer and DatasourceCubeView on the Metadata or Data tabs as a data source is being read, these commands can only be used on the Prolog tab to assign a data source to the current process not to other processes.

If you are trying to use the CSV source to run an export of those views then what you could do is write a generic process with a cube view source (the cube used as the datasource to set up the process will have to have at least as many dimensions as the maximum expected from the list of cubes) which does an ASCIIOutput on the data tab. This process should have 2 parameters being the cube and view which will be used on the Prolog to assign DataSourceNameForServer and DatasourceCubeView. This process should be called using ExecuteProcess on the Data tab of the process you are trying to write with the CSV source and pass field 1 as the DataSourceNameForServer and field 2 as the DatasourceCubeView parameters.

That might not make sense as I could be barking up the wrong tree alltogether. If so I really think it would help if you tried again to define your problem and what you are trying to do.
lotsaram

Many thanks and you did get what I was trying to do. Now I know that what I was trying to do won't work I'll have a go at doing it the way you suggested.

Thanks again

Re: DatasourceCubeView question

Posted: Wed Nov 18, 2009 12:22 pm
by job67
So I now have 2 processes and for the purposes of this I will refer to them (unimaginatively) as P1 and P2.

However, I am having problems in that the asciioutput on the data tab of P2 does not seem to run at all.

I'm hoping I've missed something very obvious but I don't know what so am hoping someone might be able to point me in the right direction (again)!

Thanks again in advance

Abridged details of the processes are:
  • P1 uses a csv file as a source and each row of this contains 3 fields - cube name, view name and a directory path. In the variables tab these are referred to as vCubeName, vCubeView and vDir.

    On the data tab this then calls P2 as follows:
    ExecuteProcess( 'P2', 'pCubeName' , vCubeName , 'pCubeView' , vCubeView , 'pDir' , vDir ) ;


    P2 uses a cube view (with 12 dimensions - the most I will need) as a data source. This then shows 13 entries on the Variables tab (one for the values in each of the 12 dimensions and one for the value for the data referenced by these) which I have left as default V1 - V13.

    The advanced tab then has details as follows:

    Parameters tab
    pCubeName, pCubeView, pDir (all are type String)

    Prolog tab
    #****GENERATED STATEMENTS START****
    #****GENERATED STATEMENTS FINISH****

    vCubeName = pCubeName;
    vCubeView = pCubeView;
    vDir = pDir;

    DataSourceType='VIEW';
    DataSourceNameForServer = pCubeName;
    DataSourceCubeView = pCubeView;

    Metadata tab
    #****GENERATED STATEMENTS START****
    #****GENERATED STATEMENTS FINISH****

    Data tab
    #****GENERATED STATEMENTS START****
    #****GENERATED STATEMENTS FINISH****

    vDateString = subst(Today,7,2) | subst(Today,4,2) | subst(Today,1,2) | subst(Time,1,2) | subst(Time,4,2) | '.csv' ;
    vFile = vDir | vCubeName | ' ' | vCubeView | ' ' | vDateString ;

    AsciiOutput(vFile,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,NumberToString(V13));
For what it's worth, I have checked all the values on the prolog tab in P2 are set correctly by outputting them all to a text file

Re: DatasourceCubeView question

Posted: Wed Nov 18, 2009 2:20 pm
by Steve Rowe
Hi Elton,

99.99% of the time this is because the view is not providing any results so the data tab never gets executed.

Check that your view generates results manually in server explorer and then double check that the settings of the ignore conslidations or ignore rules are what you intended.

A classic error here is to set the view to export what you want, but one of the dimensions references a C level. If you don't uncheck the ignore C levels option (programmatically in the TI) then the view delivers no values. You obviously can find the help file so I'll leave you to track down the commands yourself ;)

(( Next steps as well would be to create the view and subsets in the TI prolog and delete them in the epilog so that no "control" objects are left visible to the user in the server explorer. ))

HTH

Re: DatasourceCubeView question

Posted: Wed Nov 18, 2009 4:33 pm
by job67
Steve Rowe wrote: A classic error here is to set the view to export what you want, but one of the dimensions references a C level. If you don't uncheck the ignore C levels option (programmatically in the TI) then the view delivers no values. You obviously can find the help file so I'll leave you to track down the commands yourself ;)
Well the number of occurrences for the classic error have just gone up by 1!!! That was indeed the problem and is now fixed and I can stop banging my head against the wall - for a minute or two anyway.

Thank you very much
Steve Rowe wrote: (( Next steps as well would be to create the view and subsets in the TI prolog and delete them in the epilog so that no "control" objects are left visible to the user in the server explorer. ))

HTH
Indeed, but I thought I'd take things one step at a time. Should give me something to try tomorrow though.

Re: DatasourceCubeView question

Posted: Thu Sep 16, 2010 8:59 am
by ParisHilton
1 more classic error has just been fixed.
Thanks for the help!