Tuesday, September 27, 2016

HFM Java API Part 1: Getting Started

Ok, Kscope16 went by and the conference was awesome. My summer holiday is also far gone and it was nice even though the weather could have been better (but hey, I live in Finland, not in Spain or Florida so some fluctuations are expected). After getting back to work in August I have been very busy helping a couple of customers who have gone live with their new HFM environments or are in the process of doing so. But now it's time to update the blog again!

I did a presentation about the new HFM Java API in Kscope16 and was glad to hear that many developers are already using it to achieve some cool things - like Ricardo and Rodrigo of with their ODI KM (how's the paper doing guys? ;). I decided to release my short "Getting Started" document to public to make it slightly easier for to people to pick up JDeveloper and get their first project built using the Java API.

Link: Set Up New HFM API Project In JDeveloper (PDF document)

After getting the IDE ready you can start developing code for your Java program. In the next post I will concentrate on the coding part and show you examples of common tasks in HFM such as extracting data and running consolidations.


  1. Hey, the article is underway! Its on OTN for review! Please expect "Integrating ODI with HFM – Metadata Knowledge Modules" very soon :)

  2. In the manageDataOM class you can clear data using the clearData method; i am confused by the arguments required for sSliceToClear - I can't figure out if in the format of A#{IncomeStatement.[Base]) or something else...

  3. I have used the following slice definitions to consolidate data using the API. I assume that the syntax should be the same for other functions using "slices" too. I think you should test if the Clear function requires all dimensions to be defined or not.

    "Slices" for consolidation:
    S#Actual.Y#2007.P{[Third Generation]}.E#Geographical

    Another slice for extracting data:

    1. I ended up doing this in the sdk-demo and it worked

      public class DataClear {
      public DataClear() {
      }//end Super

      public void clearDataSlice() throws HFMException {
      Application application = new Application();
      SessionInfo session =;

      try {
      ManageDataOM managedataOM = new ManageDataOM(session);
      ClearDataOptions cleardataOptions = new ClearDataOptions();



      } finally {
      } //end try finally

      }//end clearDataSlice
      }//end DataClear

  4. Hi Henri,
    Thank for putting this up, really appreciate it. Just a quick question...would it be possible to connect to the HFM server using the HFM API from our local systems...say my computer is on the same network as the HFM box on the Exalytics Environment....can I connect to it using the HFM API libraries from my computer or would I need to go to the HFM box to setup my code....if yes, how.

  5. Hi Henri,
    Can you please tell me how can I get all active or running session id in HFM using JAVA API?

  6. Hi Henri,

    A great post indeed. I was using your inputs, to create a jython script to pull HFM numbers across a POV, via HFM JAPI, but am having following issues, if you could please help

    I am trying to retrieve data across a certain POV from HFM, using HFM JAPI. I am using the following code, but the same isn't working. The dataOM.getCellInfo(pov1), returns the following HFMException

    CellInfo1 = dataOM.getCellInfo(pov1)

    HFMException: EPMHFM-3037: Invalid Item ID.

    while, listCelltext = dataOM.getCellTextAndAttachmentsUsingPov(pov1), returns empty string.

    Kindly, help with, where I might be going wrong. I guess, something wrong with the POV, but am not able to figure out what. Is there a format that I need to adhere to ??


    import sys
    from java.util import Locale
    from java.lang import System

    # Import the HFM API objects we need in this script
    from import HSSUtilManager
    from import SessionOM
    from import DataOM
    from import HFMException

    # Set the required EPM environment variables
    System.setProperty("EPM_ORACLE_HOME", r'D:\Oracle\Middleware\EPMSystem11R1')
    System.setProperty("EPM_ORACLE_INSTANCE", r'D:\Oracle\Middleware\user_projects\epmsystem1')

    # Target HFM connection properties
    clusterName = "HFMD"
    userName = "user"
    password = "password"
    #password = "xyz"
    application = "HFM_APP"

    pov1 = "S#Actual.Y#2018.P#May.W#YTD.E#Entity_Top.V#.I#[ICP Top].O#Custom1.P#Custom2.C#Custom3.D#All_DataTypes.F#Custom4.S#Custom5.A#Top_Account";

    ssoToken = HSSUtilManager.getSecurityManager().authenticateUser(userName,password)
    sessionOM = SessionOM()
    hfmsession = sessionOM.createSession(ssoToken, Locale.ENGLISH,clusterName,application)

    dataOM = DataOM(hfmsession)

    povs = []

    fdmAPI.logDebug("POV is : %s" % povs)

    #listCelltext = dataOM.getCellTextAndAttachmentsUsingPov(povs)
    listCelltext = dataOM.getCellTextAndAttachmentsUsingPov(pov1)
    CellInfo1 = dataOM.getCellInfo(pov1)

    fdmAPI.logDebug("Cell texts extracted: %s" % listCelltext)
    fdmAPI.logDebug("Cell texts extracted: %s" % CellInfo1)

    for listCellTextInfo in listCelltext:
    for cellTextInfo in listCellTextInfo:
    cellTextlabel = cellTextInfo.getlabel()
    cellTextValue = cellTextInfo.getText()

    fdmAPI.logInfo("Label: %s -> %s" (cellTextLabel, cellTextValue))





  7. Hi Henri,

    Happy Christmas, I have a question that you maybe able to help with. I have coded a Web Service (using JAX-RS) that returns the HFM metadata, what I don't seem to be able to handle is the HFMException, this is being caught by the Tomcat Server. I would like to capture it within the JAX-RS framework. Any help would be much appreciated.
    Kind regards
    Graham Day