Maximo Open Forum

 View Only
Expand all | Collapse all

setWere looking for a date and string attributes in automation script

  • 1.  setWere looking for a date and string attributes in automation script

    Posted 05-23-2023 06:39

    Hello,
    I have an automation script based on Object lanuch point "ZZAMSVACTRANS" object. While "ZZAMSVACTRANS" has a relationship with "ZZAMSTIMECARD" object through a named relation "VACSHEET". Now I want to get two attributes from current object "ZZAMSVACTRANS" which are a string attribute ( "ZZEMPLOYEENO")  & a date attribute ("VACATION_START") . Next I want to search for those two fields in "VACTIMESHEET" as follow:

    from psdi.server import MXServer
    from psdi.mbo import SqlFormat
    from psdi.mbo import MboValue

    mVac = mbo.getTisMboSet()
    mTS = mbo.getMboSet("VACTIMESHEET")
    mEmpno = mVac.getString("ZZEMPLOYEENO")
    mVacstart = mVac.getDate("VACATION_START")

    ** Next setWhere works fine but to search for only the string attribute
    mTS.setWhere("ZZEMPLOYEENO="+mEpno)

    ** Next setWhere does not work ??? 
    mTS.setWhere("TS_DAY="+mVacstart)

    I got thise error as in the picture


    So, I need one setWhere to find both mEmpno and mVacstart as the following if possible:
    mTS.setWhere("ZZEMPLOYEENO="+mEmpno + " and TS_DAY="+mVacstart)

    any help , thanks in advance

    #Administration
    #Customizations
    #EverythingMaximo
    #Integrations

    ------------------------------
    Mohammad Moula
    eSolution
    ------------------------------


  • 2.  RE: setWere looking for a date and string attributes in automation script

    Posted 05-31-2023 10:19

    You need to use SQLFORMAT class.


    mTS = mbo.getMboSet("VACTIMESHEET")
    sqlf = SqlFormat("ZZEMPLOYEENO = :1 and TS_DAY = :2")
    sqlf.setObject(1,"ASSETMETER", "ZZEMPLOYEENO", mEpno)
    sqlf.setObject(2,"ASSETMETER", "TS_DAY", mEpno)
    mTS.setWhere(sqlf.format())


    ------------------------------
    Prashant Sharma
    Sedin Technologies
    Connect with me @ https://www.linkedin.com/in/psharmamaximo/

    #IBM Champion 2022
    #IBM Champion 2023
    ------------------------------