We always get requirement from the client to load the Journals to Essbase cubes with Entity Currency Adjs or with Parent Currency Adjs. So as we all do extracting of the journals from the application with a POV and some additional options, the same can be achieved using the HFM API and why do we require it? because using the API we can do the automation of the Journal extracts :-).
I am writing the snippet of the code here because the sample code available as part of the out of box EPM home doesn't have the extract journals sample.
Our requirement in writing the code for Journal Extracts is for automating it using the ODI tool and then to massage the extracted data and then to push it to the Essbase cube or a staging table.
As you already know ODI HFM knowledge modules doesn't work with the 11.1.2.4 version so if there are any native ODI interfaces on the older versions are needed to be rewritten in the API or use the FDMEE component directly for the integration.
We can use Oracle JDeveloper for writing the classes and executing them . Setting up the JDeveloper to use the sample code and API is explained in the Oracle document Oracle_HFMAPI .
Below is the class for extracting the journals using the inbuilt classes "LoadExtractOM" and "JournalExtractOptions"
I am writing the snippet of the code here because the sample code available as part of the out of box EPM home doesn't have the extract journals sample.
Our requirement in writing the code for Journal Extracts is for automating it using the ODI tool and then to massage the extracted data and then to push it to the Essbase cube or a staging table.
As you already know ODI HFM knowledge modules doesn't work with the 11.1.2.4 version so if there are any native ODI interfaces on the older versions are needed to be rewritten in the API or use the FDMEE component directly for the integration.
We can use Oracle JDeveloper for writing the classes and executing them . Setting up the JDeveloper to use the sample code and API is explained in the Oracle document Oracle_HFMAPI .
Below is the class for extracting the journals using the inbuilt classes "LoadExtractOM" and "JournalExtractOptions"
// Extracting Journals using JAVA API
// Written by Naga
// Applicable for HFM version 11.1.2.4
package oracle.epm.fm.hfm;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import oracle.epm.fm.common.datatype.transport.JournalExtractOptions;
import oracle.epm.fm.common.datatype.transport.SessionInfo;
import oracle.epm.fm.common.exception.HFMException;
import oracle.epm.fm.domainobject.loadextract.LoadExtractInfo;
import oracle.epm.fm.domainobject.loadextract.LoadExtractOM;
import oracle.epm.fm.common.datatype.transport.JOURNAL_BALANCE_TYPE;
import oracle.epm.fm.common.datatype.transport.JOURNAL_STATUS;
import oracle.epm.fm.common.datatype.transport.JOURNAL_TYPE;
public class JournalExtract {
public JournalExtract() {
super();
}
public void extract() throws HFMException {
Application application = new Application();
SessionInfo session = application.open();
try {
LoadExtractOM loadOM = new LoadExtractOM(session);
JournalExtractOptions JEO = new JournalExtractOptions();
File nfile = new File("E:\\jnl.txt");
nfile.delete();
List<Integer> L1 = new ArrayList<Integer>();
for (JOURNAL_BALANCE_TYPE F1 : JOURNAL_BALANCE_TYPE.values())
L1.add(F1.getValue());
List<Integer> L2 = new ArrayList<Integer>();
for (JOURNAL_STATUS F1 : JOURNAL_STATUS.values())
L2.add(F1.getValue());
List<Integer> L3 = new ArrayList<Integer>();
for (JOURNAL_TYPE F1 : JOURNAL_TYPE.values())
L3.add(F1.getValue());
JEO.setDelimiter(";");
JEO.setRecurring(true);
JEO.setStandard(true);
JEO.setRegular(true);
JEO.setBalanceType(L1);
JEO.setStatus(L2);
JEO.setType(L3);
JEO.setPov("S#Actual.Y#2016.P#JUL.E#{GRP.[Descendants]}.V#<Entity Curr Adjs>");
LoadExtractInfo info = loadOM.extractJournals(JEO);
System.out.println("Status of the job " + info.getStatus());
File lfile = info.getDataFile();
System.out.println("is the file renamed : " + lfile.renameTo(nfile));
}
finally {
application.close(session);
}
}
The JournalExtractOptions class plays a key role here, the options can be customized as per the requirement on how you would like to have the Journals Extracted with selected Type,Status &Balance_Type. Also the POV can be passed using an argument so we don't need to change it all the time.
Now just class the above class in the Main() class using the below snippet.
Now just class the above class in the Main() class using the below snippet.
public static void main(String[] args) {
try {
String epmOracleInstance = System.getProperty("EPM_ORACLE_INSTANCE");
if (epmOracleInstance == null || epmOracleInstance.isEmpty()) {
throw new Exception("EPM Instance home not set");
}
JournalExtract jext = new JournalExtract();
jext.extract();
} catch (HFMException e) {
e.printStackTrace();
System.out.println(e.getErrorCode());
System.out.println(e.getHResult());
System.out.println(e.getLocalizedMessage(Locale.ENGLISH));
} catch (Exception e) {
e.printStackTrace();
}
Here I am renaming the extracted file to a custom file and location of my choice as the getDataFile() method would download the file into a HFM default working directory.
So how to automate this .....we can simply create a batch script to call the Java class. Below is a sample which i am using
@echo off REM This is HFM Journal Extract script if "%EPM_ORACLE_HOME%" == "" ( echo "ERROR: EPM_ORACLE_HOME not set." exit /B 1 ) cd .. set EPM_ORACLE_INSTANCE=E:\Oracle\Middleware\user_projects\epmsystem1 set EPM_ORACLE_HOME=E:\Oracle\Middleware\EPMSystem11R1 call %EPM_ORACLE_HOME%\common\config\11.1.2.0\setJavaRuntime set JAVA_OPTS=-Djavax.net.ssl.trustStore=E:\Oracle\Middleware\wlserver_10.3\server\lib\DemoTrust.jks -Djava.util.logging.config.class=oracle.core.ojdl.logging.LoggingConfiguration -Doracle.core.ojdl.logging.config.file=logging.xml -DEPM_ORACLE_INSTANCE=E:\Oracle\Middleware\user_projects\epmsystem1 set CLASSPATH="F:\HFMAPI\hfm\.adf;F:\HFMAPI\hfm\hfm\classes;E:\Oracle\Middleware\EPMSystem11R1\common\jlib\11.1.2.0;E:\Oracle\Middleware\EPMSystem11R1\common\jlib\11.1.2.0\epm_hfm_web.jar;E:\Oracle\Middleware\EPMSystem11R1\common\jlib\11.1.2.0\epm_j2se.jar;E:\Oracle\Middleware\EPMSystem11R1\common\jlib\11.1.2.0\epm_thrift.jar" "%JAVA_HOME%\bin\java" %JAVA_OPTS% -cp %CLASSPATH% oracle.epm.fm.hfm.JournalExtract endlocal
Save the batch script and schedule it with either windows scheduler or ODI agent.
Let me know if you have a better way to extract the journals, happy to learn :-).
Let me know if you have a better way to extract the journals, happy to learn :-).