Maximo Open Forum

 View Only
  • 1.  Using variables in setWhere n the automation script

    Posted 05-24-2023 06:21

    Hello,

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

    I need to have setWere statement to search for a record in mTS object using the following conditions:
    - TS_DATE = mVacstart
    - ZZEMPLOYEENO = mEmpno

    any help will be much appreciated


    #Administration
    #Customizations
    #EverythingMaximo
    #Integrations

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


  • 2.  RE: Using variables in setWhere n the automation script

    Posted 05-24-2023 09:26

    You could build a where clause using SqlFormat, call setWhere & reset on the MboSet, etc. but it doesn't make sense to do. Let's assume your child object name is VACTIMESHEET (since that's the name of the relationship and most customers make the relationship match the object name).

    I would write this like:

    mTS=mbo.getMboSet("$CURTIMESHEET","VACTIMESHEET","ts_date=:VACATION_START and zzemployeeno=:VACTIMESHEET")

    The first parameter is a unique name that you want to give to reference the set while it's in memory. The second parameter is the object name that you are going to. If the relationship name doesn't match the object name then you should change this. The third parameter is the relationship of how to get from the current record to the child set. Because you are retrieving the values from the current MBO, we can build a dynamic relationship using bind variables. This properly handles parameterization of the data. 



    ------------------------------
    Steven Shull
    IBM
    ------------------------------



  • 3.  RE: Using variables in setWhere n the automation script

    Posted 05-25-2023 00:42
    Edited by Mohammad Moula 05-25-2023 02:20
    Yes, when I changed the relationship name to be as the object name it works fine.
    Thanks a lot






  • 4.  RE: Using variables in setWhere n the automation script

    Posted 05-25-2023 00:46
    Edited by Mohammad Moula 05-25-2023 02:19

    mTS=mbo.getMboSet("$CURTIMESHEET","VACTIMESHEET","ts_date=:VACATION_START and zzemployeeno=:VACTIMESHEET")

    How do I make VACATION_START or TS_DATE is formatted in this statement ?
    Can I use the SimpleDateFormat ? using     ( from java.text import SimpleDateFormat ) ?

    so I want both formatted "dd/MM/yyyy" 

    Thanks



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



  • 5.  RE: Using variables in setWhere n the automation script

    Posted 06-05-2023 07:59

    You can try something like 

    from java.text import SimpleDateFormat

    ...

    SimpleDateFormat("dd/MM/yyyy").format(mbo.getDate("VACATION_START"))

    ...



    ------------------------------
    Dragos Chitu
    EL
    ------------------------------



  • 6.  RE: Using variables in setWhere n the automation script

    Posted 06-14-2023 01:43

    Well, Your statement dealing with an attributes and it works with me. But, what I want is to use a  Literal variables in SetWhere ??

    Thanks Steven for help 



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



  • 7.  RE: Using variables in setWhere n the automation script

    Posted 06-14-2023 02:40

    Hi,

    You need to pass the literal values within the quotes. Suppose you want to compare the ITEMNUM attribute with a string literal in setWhere. You have to use the below code...

    itemSet.setWhere("ITEMNUM = '"+itemnum+"'")

    where itemnum is a string literal



    ------------------------------
    Subhransu Sekhar Sahoo
    Tata Consultancy Services
    ------------------------------



  • 8.  RE: Using variables in setWhere n the automation script

    Posted 06-14-2023 02:59
    Thanks for help,
    Can you rewrite the statement to be more clear for me. Can make space between the sigle quote & double quote?





  • 9.  RE: Using variables in setWhere n the automation script

    Posted 07-18-2023 11:05

    Hi,

    It's (" ITEMNUM=' " + itemnum + " ' ")

    Thanks!



    ------------------------------
    Tanishk Rathi
    ------------------------------