Showing posts with label MaxL. Show all posts
Showing posts with label MaxL. Show all posts

11/25/09

Java Customized Calc Function

The essbase already have many functions for calculation. We can create customized calculation functions by Java. Steps:
1. Create a Java function,CalcFunc.java
public class CalcFunc {
public static double sum (double[] data) {
int i, n = data.length;
double sum = 0.0d;
for (i=0; i< n ; i++)
{
double d = data [i];
sum = sum + d;
}
return sum;
}
}
2. compile,run with javac CalcFunc.java, and generate CalcFunc.class
javac CalcFunc.java
C:\app\bob\product\11.1.0\db_1\jdk\bin\javac.exe C:\Hyperion\CustJava\CalcFunc.java
3. Put the class file in the jar file
jar cf jar_filename class_filename
jar cf CalcFunc.jar CalcFunc.class
4.On the computer running Essbase Server, copy the .jar file to one of the following directories (if the directory does not exist, create it):
For .jar files containing global custom-defined functions:
ARBORPATH/java/udf/
C:\Hyperion\products\Essbase\EssbaseServer\java\udf
For .jar files to be used only with specific applications:
ARBORPATH/app/AppName/udf/
5. Register
create function Sample.'@JSUM'
as 'CalcFunc.sum'
spec '@JSUM(memberRange)'
comment 'adds list of input members';

MaxL Perl Functions

1. connect (user, password, host), Sample:
my $dbh = Essbase->connect("user","password", "host");
2. do (statement); a MaxL statement to be passed to the Essbase Server
$dbh->do("display user");
Where "display user" is a valid MaxL statement
3. pop_msg(); Navigates through MaxL status messages one at a time.
Arguments: none.Returns: a list of the form (, , )
4. fetch_desc(); Returns a reference to a row of query results and a reference to a corresponding row of datatypes for the query results.
($column_name, $datatypes) = $dbh->fetch_desc();
5. fetch_row();Returns a reference to a row of query results in a MaxL output table, as a list
6. disconnect();

MaxL Perl Module

Windows: Download Perl source from http://www.cpan.org/ and build it yourself. You may use ActivePerl, available from http://www.activestate.com/. Before you install the Essbase.pm extension to Perl, ensure that:
You have Perl 5.6 (or higher) installed on your system.You have Microsoft Visual C++ version 6 or higher installed on your system.The Essbase Server is either installed locally, or you have at least the Runtime Client installed and your system's environment is set up to access a remote Essbase Server. Your system should have an environment variable $ESSBASEPATH pointing to the root directory of the Essbase Server installation. In addition, %ESSBASEPATH%\Bin should be included in your path variable. Note:MaxL Perl Module can only be used with the same version Essbase Server.

MaxL Shell Commands

Spool on/off
Set Display Column Width
Set Message Level
Set Timestamp
Echo
Shell Escape
Nesting
Error Checking and Branching
Version
Logout
Exit

11/24/09

MaxL Automation Backup/Recovery

This paper is for the auto backup and recovery process for LDAP Shared Service and Essbase database.
1. In the essbase.cfg file, add:
    SPLITARCHIVEFILE TRUE
    TRANSACTIONLOGDATALOADARCHIVE SERVER_CLIENT

The 1st command will split big archive file into smaller one automatically. The 2nd command will enable the transaction logging.

2.  backupLDAP.bat
The code inside:
@echo off
REM Backup LDAP with HOTBackup
c:\Hyperion\products\Foundation\server\scripts\backup.bat C:\Hyperion\backup\HSS_backup

3. RecoveryLDAP.bat, the code inside:
@echo off

REM Backup LDAP with HOTBackup
c:\Hyperion\products\Foundation\server\scripts\recover.bat C:\Hyperion\backup\HSS_backup

4. BackupEssbaseMaxL.msh
spool on to 'c:\Hyperion\Logs\EssbaseArchive.log';

login $1 $2 on $3;
alter database Sample.Basic force archive to file 'C:\Hyperion\backup\SampleBasic';
alter database Demo.Basic force archive to file 'c:\Hyperion\backup\DemoBasic';
spool off;

5. backupEssbaseBSO.bat
echo off
REM Backup BSO Essbase
set uid=admin
set pwd=password
set svr=bobpc
essmsh "C:\Hyperion\auto\BackupEssbaseMaxL.msh" %uid% %pwd% %svr% %dt% %tm%
ren C:\Hyperion\backup\SampleBasic SampleBasic%date:~4,2%-%date:~7,2%-%date:~10%.arc
ren C:\Hyperion\backup\DemoBasic DemoBasic%date:~4,2%-%date:~7,2%-%date:~10%.arc
The idea is backup with general name, and use bat script rename the backup file with time stamp.

6. RecoveryEssbaseMaxL.msh
spool on to 'c:\Hyperion\Logs\EssbaseArchive.log';

alter database Sample.Basic force restore from file 'C:\Hyperion\backup\SampleBasic.arc';
alter database Demo.Basic force restore from file 'c:\Hyperion\backup\DemoBasic.arc';
alter database Sample.Basic replay transactions using sequence_id_range 2 to 2;
alter database Demo.Basic replay transactions using sequence_id_range 2 to 2;
spool off;

Please select the sequence id range by query
query database Sample.Basic list transactions;



7. RecoveryEssbaseBSO.bat
@echo off
REM Recovery BSO Essbase
essmsh "C:\Hyperion\auto\RecoveryEssbaseMaxL.msh"

The bat file for backup can be scheduled to run daily using Windows Scheduler.