Topic
8 replies Latest Post - ‏2014-04-25T12:20:56Z by bgbaird
CUFSLori
CUFSLori
4 Posts
ACCEPTED ANSWER

Pinned topic Using Relationship in Maximo 7.5 Automation Script

‏2013-07-24T19:24:09Z |

I'm trying to get the glaccount attribute of the workorder to which I'm adding a matusetrans. I've tried mbo.getOwner().workorder.glaccount but I get this error message:

I tried following the instructions in "Scripting with Maximo.pdf" but I'm not sure how to distinguish an attribute from a relationship.

I've also tried mbo.getOwner().workorder[0].glaccount with the same result.

I'm using Jython in Maximo version 7.5.0.4.

Thanks in advance for your help

 

  • SASHULL
    SASHULL
    266 Posts
    ACCEPTED ANSWER

    Re: Using Relationship in Maximo 7.5 Automation Script

    ‏2013-07-25T02:15:16Z  in response to CUFSLori

    mbo.getOwner() returns the MBO that owns the set you're dealing with so it depends a lot on your launch point and which application it's firing. I'm assuming in your case you are dealing with a launch point on MATUSETRANS. Because MATUSETRANS can be added from Inventory application or Work Order application or Receiving Application (if it's Direct Issue), I would instead go through a relationship on your Variable binding as your owner may not be what you think it is.

     

    Out of box there is a relationship called WORKORDER so your variable binding would be WORKORDER.GLACCOUNT. Or you can manually get the MBO using mbo.getMboSet("WORKORDER").getMbo(0) but be sure to verify you only fire on WORKORDER MATUSETRANS records (validate WONUM is set).

    • This reply was deleted by CUFSLori 2013-08-28T14:54:53Z.
    • CUFSLori
      CUFSLori
      4 Posts
      ACCEPTED ANSWER

      Re: Using Relationship in Maximo 7.5 Automation Script

      ‏2013-08-28T15:09:42Z  in response to SASHULL

      Yes! Variable binding made things so much easier.  This was my first script and it was definitely a learning experience.

      Also, if you need to do any database querying, here's a couple of ways to acquire a connection:

      conn = mbo.getMboServer().getDBConnection(mbo.getUserInfo().getConnectionKey()) and to free this connection at the end of the script:

      mbo.getMboServer().freeDBConnection(mbo.getUserInfo().getConnectionKey())

      or

      server = MXServer.getMXServer()

      conn = server.getDBManager().getConnection(mbo.getUserInfo().getConnectionKey()) and to free this connection at the end of the script:

      server.getDBManager().freeConnection(mbo.getUserInfo().getConnectionKey())

      • bgbaird
        bgbaird
        223 Posts
        ACCEPTED ANSWER

        Re: Using Relationship in Maximo 7.5 Automation Script

        ‏2013-08-28T15:47:18Z  in response to CUFSLori

        OK, this is one I haven't done yet...

        Once I get the connection, how do I execute the SQL?

         

        Brian

        • CUFSLori
          CUFSLori
          4 Posts
          ACCEPTED ANSWER

          Re: Using Relationship in Maximo 7.5 Automation Script

          ‏2013-08-28T19:40:08Z  in response to bgbaird

          I continued to use java code, for example:

                      stmt = conn.prepareStatement(sql)
                      stmt.setString(1, woShopIn)
                      rs = stmt.executeQuery()
                      while rs.next():

          there are also jython methods but I don't recall what library they are in.

          • bgbaird
            bgbaird
            223 Posts
            ACCEPTED ANSWER

            Re: Using Relationship in Maximo 7.5 Automation Script

            ‏2013-08-28T19:42:06Z  in response to CUFSLori

            Thanks.  I've got to tell you, I'm having some fun with Automation Scripting.  It hasn't burned me.....yet.

             

            Brian

            • Slvns
              Slvns
              1 Post
              ACCEPTED ANSWER

              Re: Using Relationship in Maximo 7.5 Automation Script

              ‏2014-04-24T21:32:02Z  in response to bgbaird

              Hi Brian, 

              One of my clients is facing the attached issue per BMXAA7837E. Not sure what was done in the system. Thought may be you could shed some light.

              • bgbaird
                bgbaird
                223 Posts
                ACCEPTED ANSWER

                Re: Using Relationship in Maximo 7.5 Automation Script

                ‏2014-04-25T12:18:50Z  in response to Slvns

                Silvanus, when I run into this, if I can't see immediately what is wrong in the script, I start building/validating one piece at a time.  In the old days (FORTRAN 77, or COBOL), when your stack of cards wouldn't compile, that's how you did it.

                http://en.wikipedia.org/wiki/Fortran

                Brian

                 

                • bgbaird
                  bgbaird
                  223 Posts
                  ACCEPTED ANSWER

                  Re: Using Relationship in Maximo 7.5 Automation Script

                  ‏2014-04-25T12:20:56Z  in response to bgbaird

                  And just for the record, I believe that IDEs have consigned elegant code to the Recycle Bin.