0

I am using Jython to write a code(Hyperion FDMEE/Essbase) wherein external libraries are getting imported explicitly in a function

#FN_RETRIEVE
import os
import sys
sys.path.append("D:\\EssbaseJavaAPI\\11.1.2.0\\lib\\ess_japi.jar")
def RETRIEVE(fdmAPI, fdmContext, grid_typ):
        ## Import libraries
        from com.essbase.api.session import *
        from com.essbase.api.domain import *
        from java.lang.Object import *
        from com.essbase.api.base import *
        from com.essbase.api.datasource import *
        from com.essbase.api.dataquery import *
        from com.essbase.api.metadata import *
        from com.essbase.api.domain import *
        from com.essbase.api.session.IEssbase import *
        from com.essbase.api.domain.IEssDomain import *
        from array import *


        config = ConfigParser.ConfigParser()
        config.read("D:/somepath/config.ini")


        # Create JAPI instance.
        ess = IEssbase.Home.create(IEssbase.JAPI_VERSION) …….

Now, I am trying to call this function in a different script as follows

import FN_RETRIEVE
reload(FN_RETRIEVE)

retr1 = FN_RETRIEVE.RETRIEVE(fdmAPI, fdmContext, "another param")

But I am getting the following error,

ess = IEssbase.Home.create(IEssbase.JAPI_VERSION) NameError: global name 'IEssbase' is not defined

It probably has to do something with the scope, but need help here what I may be missing.

Thanks, Dev

dev k
  • 3
  • 2
  • Why are you using `reload`? Also, why are you putting all your import statements in the function, where (hint, hint) the modules are bound to *local* variables, not global variables? – chepner Mar 20 '19 at 13:30
  • kept all the imports outside the function and that resolved the issue .. a silly miss from my side ..Thanks Chepner :) – dev k Mar 20 '19 at 13:41

0 Answers0