Topic
  • 10 replies
  • Latest Post - ‏2015-02-25T18:00:15Z by HeidiA
expert
expert
190 Posts

Pinned topic Document on Automation Script

‏2011-12-27T03:20:00Z |
Hi all,

Could anyone help me with automation script documents. We need to use automation scripts for our project but I couldn't find any documents on automation scripts. Thanks in advance,
Updated on 2012-10-24T16:21:35Z at 2012-10-24T16:21:35Z by mahato01
  • tivoli-i lov it
    tivoli-i lov it
    89 Posts

    Re: Document on Automation Script

    ‏2011-12-27T04:58:14Z  
    I'm looking for the same. Please help
  • vseries
    vseries
    106 Posts

    Re: Document on Automation Script

    ‏2011-12-27T05:08:00Z  
    I'm looking for the same. Please help
    Hi,

    Following documents might be helpful for you :-

    Jython Scripts
    http://www.ibm.com/developerworks/wikis/display/tivolisrm/Jython+Scripts

    Service Catalog Jython Validation
    http://www.ibm.com/developerworks/wikis/download/attachments/139592598/Service+Catalog+Jython+Validation.pdf?version=1
  • SASHULL
    SASHULL
    398 Posts

    Re: Document on Automation Script

    ‏2011-12-27T18:07:13Z  
    Attached is a guide provided by IBM that has been invaluable in understanding Automation scripts. This was given in response to one of their webinars (though is also available online).

    This is based on Maximo 75 (which I'm assuming is the version you were interested in). There were some slight differences (such as instead of mbo using scriptHome) in TSRM 7.2.
  • MichaelSmithson
    MichaelSmithson
    9 Posts

    Re: Document on Automation Script

    ‏2012-02-19T06:38:15Z  
    Hi all,
    I am trying to develop an automated script (using python) in IBM Maximo 7.5 which adds a period of time (no. of days) to an existing date. I have 3 attribute fields (existing date, period of time and resultant date), am using an attribute launch point with the period of time as the implicit attribute, and existing date (type IN) and resultant date (type OUT) set as explicit variables. I only need help with how to develop the script itself to unravel and rebuild the dates which I have in the following format: 31/01/2012 16:00 (i.e. 31-Januray, 2012 4pm).
    Please can anyone help
  • MichaelSmithson
    MichaelSmithson
    9 Posts

    Re: Document on Automation Script

    ‏2012-03-26T09:57:42Z  
    Hi all,
    I am trying to develop an automated script (using python) in IBM Maximo 7.5 which adds a period of time (no. of days) to an existing date. I have 3 attribute fields (existing date, period of time and resultant date), am using an attribute launch point with the period of time as the implicit attribute, and existing date (type IN) and resultant date (type OUT) set as explicit variables. I only need help with how to develop the script itself to unravel and rebuild the dates which I have in the following format: 31/01/2012 16:00 (i.e. 31-Januray, 2012 4pm).
    Please can anyone help
    I have managed to create the script required.

    import time
    import java.util.Date
    p = java.util.Date.getTime(purchasedate)
    import java.math.BigInteger
    s = java.math.BigInteger.floatValue(p)
    s = s / 1000
    a = assetdesignlife * 86400
    s = s + a
    t = time.localtime(s)
    designendoflifedate = time.strftime("%d/%m/%Y %H:%M", t)

    If only we had had automated scripting in earlier versions of IBM Maximo.
  • Bowser
    Bowser
    97 Posts

    Re: Document on Automation Script

    ‏2012-03-27T04:46:12Z  
    I have managed to create the script required.

    import time
    import java.util.Date
    p = java.util.Date.getTime(purchasedate)
    import java.math.BigInteger
    s = java.math.BigInteger.floatValue(p)
    s = s / 1000
    a = assetdesignlife * 86400
    s = s + a
    t = time.localtime(s)
    designendoflifedate = time.strftime("%d/%m/%Y %H:%M", t)

    If only we had had automated scripting in earlier versions of IBM Maximo.
    Something useful I found was ignoring documentation on Python / Jython modules and instead referring to the Java and Maximo APIs. This is because the Python / Jython modules are not included in your execution environment, but the Java and Maximo APIs are. You just have to watch for nuances in creating new instances and variable coercion.

    That said, I think you should explore using Calendar classes in the Java API. It would make a much cleaner approach to doing the same thing.

    You can find the Java APIs here: http://docs.oracle.com/javase/6/docs/api/

    Bowser.
  • scottsd
    scottsd
    121 Posts

    Re: Document on Automation Script

    ‏2012-04-26T14:01:44Z  
    • Bowser
    • ‏2012-03-27T04:46:12Z
    Something useful I found was ignoring documentation on Python / Jython modules and instead referring to the Java and Maximo APIs. This is because the Python / Jython modules are not included in your execution environment, but the Java and Maximo APIs are. You just have to watch for nuances in creating new instances and variable coercion.

    That said, I think you should explore using Calendar classes in the Java API. It would make a much cleaner approach to doing the same thing.

    You can find the Java APIs here: http://docs.oracle.com/javase/6/docs/api/

    Bowser.
    It is actually possible to access the Jython/Python modules from these automation scripts with a simple addition to your system's path from an automation sciprt.

    Here's an example script. This script assuming my Jython/lib directory on the AppServer is the one shipped within WebSphere, caution is suggested when using this embedded Jython in WebSphere, I've found that it's kinda messed up for some modules, and would recommend instead pointing to a full Jython installation lib directory. In the 7.5.0.3 version of Tpae and going forward, it appears that this directory is automatically included, though, unfortunately in 7.5.0.2 Tpae (and SCCD 7.5) this workaround is still required.

    import sys
    print sys.path
    foundJython = False
    for path in sys.path:
    if (path.find("jython\Lib") != -1) :
    foundJython=True
    print "already found jython in path"

    if (foundJython==False):
    sys.path.append(r'C:\Progra~1\IBM\WebSphere\AppServer\optionalLibraries\jython\Lib')
    print sys.path
    import httplib
    Thanks,
    Scott
  • mahato01
    mahato01
    6 Posts

    Automation script loops around and update all open records

    ‏2012-10-24T16:21:35Z  
    Hi,
    I am trying to develop a script that will fire on SR and update workorder with set of data. It works but instead of updating the workorder created from SR, it goes on and updates all the workorders. I am not able to get around this on how to limit or control this to update only the workorder that was created from SR. I applied some conditions but that did not work completely.
    scriptHome does not work on 7.5? Is there way to get around this problem? Here is a sample of this code.

    woQuesAnsSet = mbo.getMboSet("G_ENVQUESANS");
    woQuesSet = mbo.getMboSet("G_ENVQUEST");

    for i in range(0,woQuesSet .count()):
    woQAS = woQuesSet .getMbo(i)
    myAns=woQuesAnsSet.addAtEnd()
    myAns.setValue("G_APP", woQAS.getString("G_APP"), 2L)
    myAns.setValue("G_CATEGORY", woQAS.getString("G_CATEGORY"), 2L)

    Let me know if you have any suggestion or recommendation on what changes this needs to make it work.

    Thanks in advance,

    Kumar
  • 7FF5_David_Brawner
    7FF5_David_Brawner
    1 Post

    Re: Automation script loops around and update all open records

    ‏2013-05-13T15:34:17Z  
    • mahato01
    • ‏2012-10-24T16:21:35Z
    Hi,
    I am trying to develop a script that will fire on SR and update workorder with set of data. It works but instead of updating the workorder created from SR, it goes on and updates all the workorders. I am not able to get around this on how to limit or control this to update only the workorder that was created from SR. I applied some conditions but that did not work completely.
    scriptHome does not work on 7.5? Is there way to get around this problem? Here is a sample of this code.

    woQuesAnsSet = mbo.getMboSet("G_ENVQUESANS");
    woQuesSet = mbo.getMboSet("G_ENVQUEST");

    for i in range(0,woQuesSet .count()):
    woQAS = woQuesSet .getMbo(i)
    myAns=woQuesAnsSet.addAtEnd()
    myAns.setValue("G_APP", woQAS.getString("G_APP"), 2L)
    myAns.setValue("G_CATEGORY", woQAS.getString("G_CATEGORY"), 2L)

    Let me know if you have any suggestion or recommendation on what changes this needs to make it work.

    Thanks in advance,

    Kumar

    mahato01,

     

    It doesn't appear from your example that you qualified the WOset, ie. you have not identified the WO you wish to update so the for statement loops through all returned WO's.

    Maybe I missed domething in your example code

  • HeidiA
    HeidiA
    1 Post

    Re: Document on Automation Script

    ‏2015-02-25T18:00:15Z  
    • scottsd
    • ‏2012-04-26T14:01:44Z
    It is actually possible to access the Jython/Python modules from these automation scripts with a simple addition to your system's path from an automation sciprt.

    Here's an example script. This script assuming my Jython/lib directory on the AppServer is the one shipped within WebSphere, caution is suggested when using this embedded Jython in WebSphere, I've found that it's kinda messed up for some modules, and would recommend instead pointing to a full Jython installation lib directory. In the 7.5.0.3 version of Tpae and going forward, it appears that this directory is automatically included, though, unfortunately in 7.5.0.2 Tpae (and SCCD 7.5) this workaround is still required.

    import sys
    print sys.path
    foundJython = False
    for path in sys.path:
    if (path.find("jython\Lib") != -1) :
    foundJython=True
    print "already found jython in path"

    if (foundJython==False):
    sys.path.append(r'C:\Progra~1\IBM\WebSphere\AppServer\optionalLibraries\jython\Lib')
    print sys.path
    import httplib
    Thanks,
    Scott

    We have both Windows and Linux servers, and we were able to use the above code with some modifications. It works fine for Windows.  However, we are not able to get it working on the Linux servers.  We get an import error that the module was not found.  Following is the code we used:

     

    import sys
    foundJythonW = False
    foundJythonL = False
    for path in sys.path:
        if(path.find("C:\Program Files\IBM\WebSphere\AppServer\optionalLibraries\jython\Lib") != -1):
            foundJythonW = True
            print "Already found in jython path for Windows"

        if(path.find("/opt/IBM/WebSpere/AppServer/optionalLibraries/jython/Lib") != -1):
            foundJythonL = True
            print "Already found in jython path for Linux"

    if(foundJythonW==False):
        sys.path.append(r"C:\Program Files\IBM\WebSphere\AppServer\optionalLibraries\jython\Lib")
         
    if(foundJythonL==False):
        sys.path.append(r"/opt/IBM/WebSpere/AppServer/optionalLibraries/jython/Lib")

    print "sys.path after: " + str(sys.path)

    import ups_testLib

     

    Hoping you can help so we can build libraries using jython.  Thank you.

    Heidi