Restoring from .rej files

Ideas and tips for enhancing your TM1 application
Post Reply
User avatar
jim wood
Site Admin
Posts: 3951
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Restoring from .rej files

Post by jim wood »

Guys,

I'm not sure this has been covered. So far I have seen the method mentioned but no code. Well here is the code I used to restore from .rej files via TI. This code assumes that the largest cube has 9 dimensions. This can be changed very easily to accomondate more:

Code: Select all

IF(CubeExists(CubeName)=1);
    J=0;
    While(J<10);
      J=J+1;
      DimName=TabDim(CubeName,J);
      IF(DimName@<>'');
          Dims=J;
      EndIF;
    End;
    IF(Dims=2);
        IF(DataValueType@='N');
            CellPutN(NewValue,CubeName,Dim1,Dim2);
        ElseIF(DataValueType@='S');
            CellPutS(STR(NewValue,14,0),CubeName,Dim1,Dim2);
        EndIF;
    ElseIF(Dims=3);
        IF(DataValueType@='N');
            CellPutN(NewValue,CubeName,Dim1,Dim2,Dim3);
        ElseIF(DataValueType@='S');
            CellPutS(STR(NewValue,14,0),CubeName,Dim1,Dim2,Dim3);
        EndIF;
    ElseIF(Dims=4);
        IF(DataValueType@='N');
            CellPutN(NewValue,CubeName,Dim1,Dim2,Dim3,Dim4);
        ElseIF(DataValueType@='S');
            CellPutS(STR(NewValue,14,0),CubeName,Dim1,Dim2,Dim3,Dim4);
        EndIF;
    ElseIF(Dims=5);
        IF(DataValueType@='N');
            CellPutN(NewValue,CubeName,Dim1,Dim2,Dim3,Dim4,Dim5);
        ElseIF(DataValueType@='S');
            CellPutS(STR(NewValue,14,0),CubeName,Dim1,Dim2,Dim3,Dim4,Dim5);
        EndIF;
    ElseIF(Dims=6);
        IF(DataValueType@='N');
            CellPutN(NewValue,CubeName,Dim1,Dim2,Dim3,Dim4,Dim5,Dim6);
        ElseIF(DataValueType@='S');
            CellPutS(STR(NewValue,14,0),CubeName,Dim1,Dim2,Dim3,Dim4,Dim5,Dim6);
        EndIF;
    ElseIF(Dims=7);
        IF(DataValueType@='N');
            CellPutN(NewValue,CubeName,Dim1,Dim2,Dim3,Dim4,Dim5,Dim6,Dim7);
        ElseIF(DataValueType@='S');
            CellPutS(STR(NewValue,14,0),CubeName,Dim1,Dim2,Dim3,Dim4,Dim5,Dim6,Dim7);
        EndIF;
    ElseIF(Dims=8);
        IF(DataValueType@='N');
            CellPutN(NewValue,CubeName,Dim1,Dim2,Dim3,Dim4,Dim5,Dim6,Dim7,Dim8);
        ElseIF(DataValueType@='S');
            CellPutS(STR(NewValue,14,0),CubeName,Dim1,Dim2,Dim3,Dim4,Dim5,Dim6,Dim7,Dim8);
        EndIF;
    ElseIF(Dims=9);
        IF(DataValueType@='N');
            CellPutN(NewValue,CubeName,Dim1,Dim2,Dim3,Dim4,Dim5,Dim6,Dim7,Dim8,Dim9);
        ElseIF(DataValueType@='S');
            CellPutS(STR(NewValue,14,0),CubeName,Dim1,Dim2,Dim3,Dim4,Dim5,Dim6,Dim7,Dim8,Dim9);
        EndIF;
    EndIF;
EndIF;
Hope this proves useful,

Jim.
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
User avatar
ioscat
Regular Participant
Posts: 209
Joined: Tue Jul 10, 2012 8:26 am
OLAP Product: Contributor
Version: 9.5.2 10.1.1 10.2
Excel Version: 07+10+13
Contact:

Re: Restoring from .rej files

Post by ioscat »

Hello, Jim.

We got a problem: I crashed some data and users set some data. BackUp is made every day. I thought that transaction log allows to apply to last backup all changes made by users, but backing up is not allowed by tm1. Is your method able to solve our problem?

Sorry for my English.
User avatar
jim wood
Site Admin
Posts: 3951
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: Restoring from .rej files

Post by jim wood »

It works as long as the software has generated the rej files after the crash,

Jim.
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
User avatar
Martin Ryan
Site Admin
Posts: 1988
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: Restoring from .rej files

Post by Martin Ryan »

Hi ioscat,

I think your problem is different from that addressed by Jim's post. .rej files are generated when a server that is running as an application (not a service) is shut down and the user chooses not to save changes, or when a server restarts after a crash and the user decides not to load all the data that is sitting in the log file.

I could read your comments two ways, and I'll try to address both.

One is that the server crashed and you need to restore the data entered between the last time the cubes were saved and the crash. This should happen automatically if you're running TM1 as a service - TM1 will just pick up the information from the tm1s.log file. If you're running as an application you'll get a dialog that says "TM1 server log exists, do you want to load changes?" or something similar. Just click yes and it will load up all the data from tm1s.log.

If you're talking about backing the cubes up in general then TM1 doesn't do this automatically, you're right. You can use third party backup software, which your IT dept should have handy, or a batch file to copy data from the Data directory to a backup drive. Note you cannot copy tm1s.log as that is locked by the server.

Hope that helps. If you've got more questions then it'd be a good idea to start them as a new thread in the main forum. This Useful Code, Tips and Tricks forum is not aimed at problem resolution, it's aimed at sharing useful ideas.

Martin
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
Post Reply