Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
Expand all | Collapse all

Exclude rows from object structures via WHERE clause

  • 1.  Exclude rows from object structures via WHERE clause

    Posted Thu September 16, 2021 07:21 AM
    Edited by System Admin Wed March 22, 2023 11:45 AM


    MAM 7.6.1.2:


    Is it possible to configure object structures so that they exclude rows? (via a WHERE clause)

    Reason:

    Staff use object structures like REP_WOPLANACT to create ad-hoc reports…and a CUSTOM_WO object structure to export to Excel (via application export).

    But unfortunately, they keep misinterpreting the data when it comes to tasks:

    1. They forget that tasks are WOs. It would be best to exclude tasks from both object structures.
    2. On a side note: I plan to remove the ACT… fields from the object structures, since they don't include task actuals. I'll likely add custom ACT… fields to the object structures that do include task actuals.

    If I could apply a WHERE clause to object structures, then that would help avoid the situation in #1.



    RFE / Idea:
    Exclude records from Report Object Structure
    https://ibm-ai-apps.ideas.ibm.com/ideas/MASM-I-564

    ​​
    #Maximo
    #AssetandFacilitiesManagement


  • 2.  RE: Exclude rows from object structures via WHERE clause

    Posted Thu September 16, 2021 03:47 PM
    Have you tried using the using the "Data restriction condition" on the Object Structure main tab? I see a condition there, apparently out-of-the-box, which restricts data to non-task work orders (BMXTKTNOTASK). This condition has an expression "istask=0". You can create your own if you need a different expression.

    ------------------------------
    Joel Ramos
    ------------------------------



  • 3.  RE: Exclude rows from object structures via WHERE clause

    Posted Thu September 16, 2021 04:25 PM
    Edited by System Admin Wed March 22, 2023 11:54 AM

    Thanks!
    It's strange, I don't see a field called "Data restriction condition" in the Object Structure main tab (I don't see it in any of my Maximo environments):





    But I googled maximo "object strcuture" "Data restriction condition"  and found this image (I added the green markup):

    (The source is More Maximo, but I don't know what the underlying post/webpage is.)

    [Edit: And I see it in the Maximo Preview Site environment too.]


    So as you said, that field obviously exists, at least for some people.


    Question:

    Is there any chance you could provide some info about what you're seeing?

      - Screenshot?
      - Database field name via Alt+F1 (i.e. MAXINTOBJECT.xyz)
      - Version of Maximo that you're using

    Sorry to ask so much, but I'm not sure how else to determine why I can't see that field.

    Thanks!


    #AssetandFacilitiesManagement
    #Maximo


  • 4.  RE: Exclude rows from object structures via WHERE clause

    Posted Fri September 17, 2021 07:58 AM
    Edited by System Admin Wed March 22, 2023 11:53 AM
    The attribute on MAXINTOBJECT is RESTRICTWHERE. I've seen these before as well at my last job but in my local environment I was given it's not there even though I'm on the latest IFIX. I'm assuming there's an issue with one of the MXS files not getting executed to make the screen change based on your starting and ending version.

    Also, for clarity, I don't think this would apply to QBRs (since you mentioned a report structure). I think this is purely for retrieval of data using the REST API since conditions can not always be converted to SQL.

    ------------------------------
    Steven Shull
    ------------------------------



  • 5.  RE: Exclude rows from object structures via WHERE clause

    Posted Fri September 17, 2021 08:25 AM
    Edited by System Admin Wed March 22, 2023 11:47 AM
    Thanks. Looking at that screenshot I found online, it looks like the field had a lookup window/picklist.

    And @Joel Ramos mentioned:
    I see a condition there, apparently out-of-the-box, which restricts data to non-task work orders (BMXTKTNOTASK). This condition has an expression "istask=0". ​

    I could manually add that field to Application Designer -> Object Structures. But it wouldn't have the picklist. I wonder how we can find out what the field properties are supposed to be…so that the picklist shows up. 


    I suppose I can submit a case to support…

    Edit: Case # TS006879227
    #AssetandFacilitiesManagement
    #Maximo


  • 6.  RE: Exclude rows from object structures via WHERE clause

    Posted Mon September 20, 2021 04:21 PM
    Here's what I see for that field in Application Designer in one of my sytems:


    ------------------------------
    Tim Ferrill
    Solutions Consultant
    Intelligent Technology Solutions
    tferrill@webuildits.com
    www.webuildits.com
    @tferrill/@webuildits
    ------------------------------



  • 7.  RE: Exclude rows from object structures via WHERE clause

    Posted Sat September 18, 2021 03:36 PM
    Edited by System Admin Wed March 22, 2023 11:47 AM
    Regarding query-based reporting / ad-hoc reporting using the REP_WOPLANACT object structure:

    I wonder if I could change that object structure so that it uses a view instead of the WORKORDER table. I could give the view a WHERE clause to exclude tasks: ISTASK=0.



    #Maximo
    #AssetandFacilitiesManagement


  • 8.  RE: Exclude rows from object structures via WHERE clause

    Posted Mon September 20, 2021 08:24 AM

    I always recommend creating a new object structure instead of trying to change the existing. Most people don't realize this but changes to an object structure will prevent users from modifying any QBR based on it and existing reports would keep the logic you don't want (so it'd only help with new QBRs). 

    Modifying existing object structures can also cause issues. There's a parent child hierarchy that gets built and a lot of time they look for the reference they expect (such as WORKORDER in this case) and if it's no longer part of the object structure the updatedb will fail. There are other issues too like their updatedb could add something back or remove something you added. It's typically easier and more reliable just to create your own (duplicating existing when possible).  



    ------------------------------
    Steven Shull
    ------------------------------



  • 9.  RE: Exclude rows from object structures via WHERE clause

    Posted Wed September 22, 2021 02:04 AM

    Thanks Steven. That's good to know.

    Question:
    In a previous comment about the RESTRICTWHERE field, you mentioned:
    "…conditions can not always be converted to SQL."

    Would you be able to expand on that point? Are conditions not written in real SQL?


    Thanks.




  • 10.  RE: Exclude rows from object structures via WHERE clause

    Posted Wed September 22, 2021 09:08 AM
    Most conditions that users write get executed against dummy_table or the corresponding database table as actual SQL. There are substitution variables, so there is some overhead that the framework has to do to parse out the logged in user for example or the value in a particular field. That's when the conditional expression type is "Expression".

    But conditions can be java classes (and automation scripts, which use a java class to launch your script). For example, BMXCREWID is a condition that uses a java class to determine if it should evaluate to true/false.

    Because of the substitution variables and java classes, it didn't seem likely that it would evaluate the condition in report object structure scenarios. But when you're retrieving data from the REST API you're interacting with MBOs so it can easily evaluate the condition logic.

    ------------------------------
    Steven Shull
    ------------------------------



  • 11.  RE: Exclude rows from object structures via WHERE clause

    Posted Tue September 28, 2021 09:30 AM
    Edited by System Admin Wed March 22, 2023 11:49 AM

    Hi Steven,

    It looks like you were right. The "Data restriction condition" field (MAXINTOBJECT.RESTRICTWHERE) didn't work for ad-hoc reports (QBRs).

    I added the BMXTKTNOTASK condition (:istask=0) to a custom report object structure . I used the report object structure in an ad-hoc report, but the report didn't exclude task records. So I think that tells us that "Data restriction condition" doesn't apply to ad-hoc reports.
     

    "I don't think this would apply to QBRs (since you mentioned a report structure). I think this is purely for retrieval of data using the REST API since conditions can not always be converted to SQL."

    "...conditions can be java classes (and automation scripts, which use a java class to launch your script). For example, BMXCREWID is a condition that uses a java class to determine if it should evaluate to true/false.

    Because of the substitution variables and java classes, it doesn't seem likely that it would evaluate the condition in report object structure scenarios. But when you're retrieving data from the REST API you're interacting with MBOs so it can easily evaluate the condition logic."

    Do we have any other options for filtering object structures for the purpose of ad-hoc reports?

    Thanks.



    #Maximo
    #AssetandFacilitiesManagement


  • 12.  RE: Exclude rows from object structures via WHERE clause

    Posted Tue September 28, 2021 09:53 AM
    On child objects it's easy as you can adjust the relationship. For the main object I'm not aware of a reliable way to enforce this other than ensuring your report developers create the report with their where clause saved and their where clause including the filter.

    ------------------------------
    Steven Shull
    ------------------------------



  • 13.  RE: Exclude rows from object structures via WHERE clause

    Posted Tue September 28, 2021 09:58 AM
    I wonder if I could make the main object be a view, instead of using the WORKORDER table directly. And then in the view, exclude records via its WHERE clause. Maybe that would work?


  • 14.  RE: Exclude rows from object structures via WHERE clause

    Posted Tue September 28, 2021 10:14 AM
    On an object structure you can use a view as the main object but report object structures need the main object to match the main object of the app. This is required so that data restrictions, where clauses, etc. work inside of the report as they'll be referenced as workorder.siteid for example. You'd have to create a custom app based on the custom view which I wouldn't recommend. 

    The out of the box woprint.rptdesign handles the view differences of Changes, Work Order Tracking, etc. by joining workorder to those views. But from a QBR that wouldn't be possible.

    ------------------------------
    Steven Shull
    ------------------------------



  • 15.  RE: Exclude rows from object structures via WHERE clause

    Posted Wed September 29, 2021 04:39 PM
    Edited by System Admin Wed March 22, 2023 11:53 AM
    For what it's worth, Object Structure Query Definitions didn't work either. I was able to create a query definition, but it didn't filter the ad-hoc report (based on the report object structure).


    I suppose query definitions are only meant to be used with OSLC, not report object structures.



    #AssetandFacilitiesManagement
    #Maximo


  • 16.  RE: Exclude rows from object structures via WHERE clause

    Posted Wed October 06, 2021 10:20 PM
    Edited by System Admin Wed March 22, 2023 11:51 AM
    Regarding this blurb from Steven Shull:
    "On an object structure you can use a view as the main object but report object structures need the main object to match the main object of the app. This is required so that data restrictions, where clauses, etc. work inside of the report as they'll be referenced as workorder.siteid for example."


    I did some experimenting and confirmed that is correct. While I was technically able to use a view as the main object in the ROS, it didn't work properly when I tried to create an ad-hoc report from the ROS. I got an error.


    Details:

    I was able to save the ROS with the view as the main object:


    But I couldn't use the view's fields in an ad-hoc report:
    BMXAA4214E - An unknown error has occurred. Please contact your system administrator for assistance. Gather the logs from the <HOME> directory and determine where and why the error occurred.

    (Unfortunately, I don't have access to the logs --  so I don't know what the underlying issue was.)


    To further prove the point, I replaced the view in the ROS with the WORKORDER object...and that worked just fine. I was able to use it's fields in the ad-hoc report without getting an error.

    Similarly, if I added the view as a child object in the ROS, I was able to use it's fields in the ad-hoc report. So that proves that the problem is when the view is the main object in the ROS.


    #Maximo
    #AssetandFacilitiesManagement


  • 17.  RE: Exclude rows from object structures via WHERE clause

    Posted Thu October 07, 2021 08:17 AM
    Edited by System Admin Wed March 22, 2023 11:51 AM

    I'd just like to point out, for my own records, that this blurb from Steven Shull is important (in general when it comes to ROS):


    "Most people don't realize this but changes to an object structure will prevent users from modifying any QBR based on it and existing reports would keep the logic you don't want (so it'd only help with new QBRs)."


     


    #Maximo
    #AssetandFacilitiesManagement


  • 18.  RE: Exclude rows from object structures via WHERE clause

    Posted Fri October 08, 2021 10:38 AM
    Edited by System Admin Wed March 22, 2023 11:52 AM
    I wonder if the Database Join Required field could be used to exclude rows in ROS / ad-hoc reports:

    Database Join Required
    QBR (Ad Hoc) Reporting and Report Object Structures - Revision 3 (page 76)

    "If the join is defined as required, or an inner join, a '1' will be used in the MAXRELATIONSHIP.DBJOINREQUIRED field. This type of join will only return results that have corresponding data in both tables. These inner joins limit the data that is returned.

    Looking further at the relationship between the PR to PR Line table - If the MAXRELATIONSHIP.DBJOINREQUIRED = '1', only PRs with entries in the PRLINE table will be returned in the report."


    If I were to have a view as child object that excluded tasks, and enable the Database Join Required field, would that exclude tasks from the parent WORKORDER object?

    #Maximo
    #AssetandFacilitiesManagement


  • 19.  RE: Exclude rows from object structures via WHERE clause

    Posted Fri October 08, 2021 10:59 AM
    Edited by System Admin Wed March 22, 2023 11:53 AM
    @Steven Shull
     It looks like Database Join Required worked:


    (Database Join Required is enabled on the child object, which is a view with a WHERE clause that excludes tasks)

    Before:


    After:
    ​​
    #Maximo
    #AssetandFacilitiesManagement


  • 20.  RE: Exclude rows from object structures via WHERE clause

    Posted Fri October 08, 2021 11:31 AM
    Interesting... I assumed it would only force a join if records from both were referenced. You're saying the join is enforced even if the child object is not part of the report object structure? If so that would be an interesting approach.

    ------------------------------
    Steven Shull
    ------------------------------



  • 21.  RE: Exclude rows from object structures via WHERE clause

    Posted Fri October 08, 2021 01:06 PM
    Edited by System Admin Wed March 22, 2023 11:44 AM

    Ah crap. You're right, it only works if a field from the child object (Database Join Required = Y) is actually added to the report. If none of the child object fields are included in the report, then records aren't excluded from the main WORKORDER object.



    #AssetandFacilitiesManagement
    #Maximo