4 Replies Latest reply on Aug 30, 2017 10:09 AM by 3243283

    Dynamic Jython script


      Dear All,

      I have here the following Jython script:


      if (StrCatKey == "3" and StrPerKey[0:3] ==
      "Jun" or StrCatKey == "3" and StrPerKey[0:3] ==

          RESULT = CURVAL


          RESULT =


      however we discovered that the "CATKEY" / "StrCatKey" parameters present different values in the production enviornment ("2") in comparison with the development environment ("3").

      Is there a way to make the script dynamic and independent from the environment? May I create a reference to the "CATNAME" for example?


      Please help!!!

      I wish to thank you all for your support.

        • 1. Re: Dynamic Jython script
          Robert Gideon

          You can try an "if fdmContext["CATNAME"] == x" statement, not sure if that will work in your script. I am assuming this is a Logic Account based on the "RESULT = " statement in your script and I'm not sure if this will work in a Logic Account function or not as I haven't tested it.

          • 2. Re: Dynamic Jython script

            Here is a roundabout way in case the more straightforward one suggested above does not work:


            You can connect to the FDMEE Schema and get the category key from the tpovcategory table.

            SELECT catkey FROM tpovcategory WHERE CATNAME = 'x'


            as long as your category name is the same across environments, it should work fine.

            • 3. Re: Dynamic Jython script

              We are following the same issue.


              Do you have any practical example of how to launch such a query from within the function (Jython script) of a logic account?

              • 4. Re: Dynamic Jython script

                Here is the solution:


                import java.sql as jsql
                import java.lang as lang

                driver, url, user, passwd = ("oracle.jdbc.driver.OracleDriver","jdbc:oracle:thin:@host/servicename","userid","password")
                c = jsql.DriverManager.getConnection(url,user,passwd)
                s = c.createStatement()
                print "executing " , sql_stmt
                rs = s.executeQuery(sql_stmt)
                while (rs.next()):
                        catKey = rs.getString("CATKEY")

                if (strCatKey == catKey and StrPerKey[0:3] == "Jun" or strCatKey== catKey and StrPerKey[0:3] == "Dec"):
                    RESULT = CURVAL
                    RESULT = "Skip"