Page 1 of 1

Restoring from .rej files

Posted: Wed Mar 21, 2012 6:23 pm
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.

Re: Restoring from .rej files

Posted: Thu Aug 02, 2012 3:23 pm
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.

Re: Restoring from .rej files

Posted: Thu Aug 02, 2012 4:02 pm
by jim wood
It works as long as the software has generated the rej files after the crash,

Jim.

Re: Restoring from .rej files

Posted: Thu Aug 02, 2012 10:21 pm
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