Page 1 of 1

TI process hangs on

Posted: Mon Sep 01, 2014 10:54 am
by BariAbdul
I am trying to find the subsetcount with below process,it saves fine but just hangs on,infact the server has to be restarted:

Code: Select all

#****Begin: Generated Statements***
#****End: Generated Statements****


# If the Allsubsets dimension exits then we delete it and again create it.#
IF(DimensionExists('AllSubsets')=1);
    DimensionDestroy('AllSubsets');
ENDIF;

DimensionCreate('AllSubsets');
IF(DimensionExists('Dimension_names')=1);
    DimensionDestroy('Dimension_names');
endif;

no_dimensions = DIMSIZ('}Dimensions');

DimensionCreate('Dimension_names');
DimensionElementDelete('}Dimensions','Dimension_names');
dim_counter = 1;

WHILE(dim_counter <= no_dimensions);

    dim_name=DIMNM('}Dimensions',dim_counter);
    # Skip the control dimensions
    var1=scan('}',dim_name);

    if(var1<>1);
        DimensionElementInsert('Dimension_names','',dim_name,'N');
        i=0;vFilenew='';
        compare='a';
        # Search for corresponding folder and .sub file for a dimension
        while(compare@<>'');
            vFile = WildCardFileSearch( vDataDirectory|'\'| dim_name | '}subs\'| '*.sub',vFilenew) ;
            result=fileExists( vDataDirectory | '\'| dim_name | '}subs\'| vFile);
            if(vFile@<>'');
                if(vFIle@<>'Default.sub');
                    strlength=LONG(vFile);
                    vSubsetfinal=DELET(vFile,strlength-3,4);
                    DimensionElementInsert('AllSubsets','',vSubsetfinal,'N');
                endif;
                vFilenew=vFile;
            endif;
            if(vFile@='');compare='';
            endif;
        END;
    endif;

    dim_counter = dim_counter +1;
END;

dim_counter=1;
subset_counter=1;
no_dim = DIMSIZ('Dimension_names');
no_subsets = DIMSIZ('AllSubsets');ASCIIOutput(vOutputFile |'\'| 'SubsetCount.csv','Dimension_names','Subset_names');
WHILE(subset_counter<=no_subsets);
    subset_name=DIMNM('AllSubsets',subset_counter);
    dim_counter_new=1;
    WHILE(dim_counter_new<=no_dim);
        dim_name1=DIMNM('Dimension_names',dim_counter_new);
        var_dim_name = scan('}',dim_name1);
        if(var_dim_name<>1);
            if(dim_name1@<>'AllSubsets');
                #If the subset exists for the dimension then write its name# in front of the dimension name in csv file
                if(SubsetExists(dim_name1,subset_name)=1);
                    ASCIIOutput(vOutputFile |'\'| 'SubsetCount.csv',dim_name1,subset_name);
                endif;
            endif;
        endif;
        dim_counter_new=dim_counter_new+1;
    END;
subset_counter=subset_counter+1;
END;
Could anybody help me on this one ,Please.

Re: TI process hangs on

Posted: Mon Sep 01, 2014 11:19 am
by BariAbdul
Sorry I forgot to mention most important bit,this particular model consists lots(about 70,000)subsets,could that be the reason?Thanks

Re: TI process hangs on

Posted: Mon Sep 01, 2014 5:08 pm
by Wim Gielis
Hello

This is a big number of subsets...

Does it work on a much smaller number of subsets?
Do you have all of your loops and counters correct? (it's not easy to tell immediately if you do not indent your code and you do not use the code tags correctly).

What is this line for?

Code: Select all

DimensionElementDelete('}Dimensions','Dimension_names');
and you set a counter BEFORE that line? Did you use AsciiOutput to follow what is going on in the loops?

Re: TI process hangs on

Posted: Mon Sep 01, 2014 8:58 pm
by Alan Kirk
Wim Gielis wrote: This is a big number of subsets...

Does it work on a much smaller number of subsets?
Do you have all of your loops and counters correct? (it's not easy to tell immediately if you do not indent your code and you do not use the code tags correctly).
It's indented and tagged properly now. Not sure how, maybe a guardian demon did it. :twisted:

There was also (originally) an If() test right at the end of another line after a semi-colon. While it's syntactically permissible, it does make it a bear to try to match the If/EndIf statements.
Wim Gielis wrote:What is this line for?

Code: Select all

DimensionElementDelete('}Dimensions','Dimension_names');
and you set a counter BEFORE that line?
I get what he's doing there; he creates the dimension 'Dimension_Names' but doesn't want to iterate that dimension in his loop since it's not a "real" dimension. Nonetheless I'd regard that as being bad juju. I absolutely would NOT monkey with the contents of any of the system dimensions. It would be far safer to just include a test in the loop setting the value of var1 to 1 if the dimension in question is named 'Dimension_Names' and thus skipping it in the same way as the system dimensions are.

I'm not saying that that's the cause of the problem (I don't have time right now to analyse the whole thing; I skimmed it but nothing stands out), but I definitely wouldn't do it.
Wim Gielis wrote:Did you use AsciiOutput to follow what is going on in the loops?
Seconded; that's essential. The AsciiOutput should be written with a timestamp, a code line, and the value of all variables up to that point. It won't be possible to read it while the process is still running but if the thing really is hanging then it'll at least show where it's hanging which will in turn reveal why.

Re: TI process hangs on

Posted: Mon Sep 01, 2014 9:18 pm
by Duncan P
Easier than putting in loads of AsciiOutput statements, but quite a lot more verbose, is setting DEBUG logging for process functions.

I described how to do it here.

[Edit] and you can read the log while the process is running.

Re: TI process hangs on

Posted: Tue Sep 02, 2014 3:30 pm
by BariAbdul
Wim Gielis wrote:Hello

This is a big number of subsets...

Does it work on a much smaller number of subsets?
Yes,Indeed it is a big number,When I tried on smaller set of subsets it seems to work.
It's indented and tagged properly now. Not sure how, maybe a guardian demon did it. :twisted:
Surprising I did posted it by using 'Code' which somehow worked later on! ;)

Thank you gurus for your help.You all been really kind.

Re: TI process hangs on

Posted: Wed Sep 03, 2014 10:18 am
by Wim Gielis
Duncan P wrote:Easier than putting in loads of AsciiOutput statements, but quite a lot more verbose, is setting DEBUG logging for process functions.

I described how to do it here.
Hello Duncan,

That is interesting, I never used that debugging function on TI commands. Thanks.

I did a small test with this TI process code:

Code: Select all

i = 1;

WHILE( i <= 2 );

     AsciiOutput( 'test.txt', NumberToString( i ) );

      i = i + 1;

END;
The output in the text file is (as it should be):

"1"
"2"


However, the output in the TM1 Message Log is as follows:

12560 [2] INFO 2014-09-03 07:29:30.783 TM1.Process Process "test" executed by user "Wim"
12560 [2] DEBUG 2014-09-03 07:29:30.783 TM1.Process.Functions Process = test, Function = numbertostring
12560 [2] DEBUG 2014-09-03 07:29:30.783 TM1.Process.Functions.Parameters Process = test, Function = numbertostring, Parameter 1 =
12560 [2] DEBUG 2014-09-03 07:29:30.783 TM1.Process.Functions Process = test, Function = AsciiOutput
12560 [2] DEBUG 2014-09-03 07:29:30.783 TM1.Process.Functions.Parameters Process = test, Function = AsciiOutput, Parameter 1 = test.txt
12560 [2] DEBUG 2014-09-03 07:29:30.783 TM1.Process.Functions.Parameters Process = test, Function = AsciiOutput, Parameter 2 = 1
12560 [2] DEBUG 2014-09-03 07:29:30.783 TM1.Process.Functions Process = test, Function = numbertostring
12560 [2] DEBUG 2014-09-03 07:29:30.783 TM1.Process.Functions.Parameters Process = test, Function = numbertostring, Parameter 1 =
12560 [2] DEBUG 2014-09-03 07:29:30.783 TM1.Process.Functions Process = test, Function = AsciiOutput
12560 [2] DEBUG 2014-09-03 07:29:30.783 TM1.Process.Functions.Parameters Process = test, Function = AsciiOutput, Parameter 1 = test.txt
12560 [2] DEBUG 2014-09-03 07:29:30.783 TM1.Process.Functions.Parameters Process = test, Function = AsciiOutput, Parameter 2 = 2
12560 [2] INFO 2014-09-03 07:29:30.783 TM1.Process Process "test": finished executing normally, elapsed time 0.00 seconds


Why does the variable i is not filled in ? For example, the numbertostring does not have a parameter value for i, but AsciiOutput has the value for i ... ?
That's typically the kind of information one needs... when looping, we need to debug the loop and check the value of i.

Why is numbertostring all lower case, and AsciiOutput is mixed case? Strange :-) I typed both in mixed case in the TI code, so there should be some kind of modification by TM1.

Thanks,

Wim

Re: TI process hangs on

Posted: Wed Sep 03, 2014 1:47 pm
by dr.nybble
Hi Wim, the function names you see are how the developer typed it into the TM1 source code.

Over the years they have accrued but there is no consistency in the case.

As for the debugging, it is a bug -- I just checked. I'll let the developer responsible for that area know.

Re: TI process hangs on

Posted: Wed Sep 03, 2014 1:54 pm
by Wim Gielis
Hi,

Great, thanks!

I would love to have the value of i, if it's a bug then I am sure it can be corrected :-)
The lowercase is not critical. Consistency would be good but the other problem is far more important.

Thanks.