Maximo Open Forum

 View Only
  • 1.  Script to Zero YTD hours for Laborers

    Posted 04-13-2021 13:29
    Inspired by an article I came across authored by Chris Winston, I want to create a script that will do the Zero Year-to-Date hours function automatically.

    I created an Escalation to run once a year in the wee hours of the first day of our fiscal year, on the LABOR object, with no SQL condition.

    Created one Escalation Point, with no restrictions on it.  That Point has an Action, which is to run the script I created.

    This is the Jython code:
    from psdi.mbo import MboConstants
    from psdi.mbo import MboSet
    from com.ibm.tivoli.maximo.util.mbo import IterableMboSet
    
    laborSql = " reportedHrs > '0' or ytdOTHrs > '0' or ytdHrsRefused > '0'"
    
    laborSet = mbo.getMboSet("CUSTOMLABORLIST", "LABOR", laborSql)
    
    if (laborSet.count() > 0):
        labor = laborSet.moveFirst()
        while (labor is not None):
            labor.zeroYTD()
            labor = laborSet.moveNext()
    
        laborSet.setFlag(MboConstants.DISCARDABLE, True)
        laborSet.close()
    
    else:
        laborSet.setFlag(MboConstants.DISCARDABLE, True)
        laborSet.close()
    ​


    Here are my questions:
    1) Is the script "right"?  Is that labor.zeroYTD() call done right?  Do I need to put any parameters there (the Javadocs says this method has three parameters)?
    2) Is it better to put the SQL here in the script and run it through a whole mboset, or would it have been better to put the SQL in the Escalation's condition and have the script simply call that zeroYTD() method -- so, like the Escalation is responsible for finding the records instead of the Script?


    Once I get this working, I want to do the same for zeroing Asset costs, Inventory quantities, etc. . .
    #Administration
    #EverythingMaximo

    ------------------------------
    Travis Herron
    Pensacola Christian College
    ------------------------------


  • 2.  RE: Script to Zero YTD hours for Laborers

    Posted 04-14-2021 09:20
    We've automated it a few different ways over the years for customers in our cloud, but our most common design was an escalation on ORGANIZATION that had actions for each (running the asset rollup reports, zeroing inventory YTD, zeroing labor, and zeroing asset costs). If you build the actions appropriately, you can use this to determine which organizations to run it on if you have it. Also make sure you set it to repeat (you don't want it to just work once).

    We typically avoid counts as it's easy enough to iterate and you don't need to know the count. It causes an additional query to execute that might not be needed. We do something like this to loop:

    laborMbo = laborSet.moveFirst()
    while laborMbo:
        laborMbo.zeroYTD(True,True,True)
        laborMbo = laborSet.moveNext() 
    laborSet.save()
    laborSet.close()

    As for your questions
    1) We used laborMbo.zeroYTD(True,True,True). Those 3 parameters are Reported, Overtime, and Refused and we assumed all customers would want all 3 to be zeroed out.
    2) We like the escalation determining which organizations this should run on and then executing for all labor in that organization at once. In our design, we set laborSet.setLogLargFetchResultDisabled(True) because if you have more than 5000 records (or whatever your stop limit is) that would prevent it from retrieving the set. For most organizations, they won't have 5000 labor records so it won't be a big deal but because we wrote it generically I thought I'd call it out.


    As for your future plans, inventory and asset zeroing of asset costs is even more straight forward. The biggest challenge is getting the asset cost rollup report executed and ensuring all costs are rolled up prior to zeroing asset costs.

    Once you're sure asset costs are rolled up (checking the SERVRECTRANS, TOOLTRANS, MATUSETRANS, LABTRANS tables), zeroing the asset costs is easy because it's done at a set level (IE assetSet.zeroCosts(True,False)). First argument is YTD, second argument is TOTALCOST. Obviously for year end activities you don't want to zero the second.

    For inventory, it's also at a set level but there are no arguments. You simply need to call inventorySet.zeroYTDQuantities().

    In all of our automation, we put in additional checks as we had bugs on certain versions that caused escalations to run on the wrong date/time or run more than once. As long as you're on newer versions you probably don't need to worry about this, but it may be something worth tracking somewhere (potentially on the organization record) so you can avoid processing twice.

    ------------------------------
    Steven Shull
    Projetech Inc.
    ------------------------------