Tuesday 26 January 2021

SQL to find the Next Working Day and skip the Weekend. | SQL DB2

An example of Db2-SQL to find the next working day and skip the weekend. In this example Friday and Saturday both are weekends.

SELECT
     sysdate AS current_date
    ,DAYNAME (sysdate) current_day
    ,sysdate + 3    AS come_after_3_days
    ,DAYNAME (sysdate+3) oh_after_3_is_friday
    ,decode(DAYNAME (sysdate + 3)
            ,'Friday',(sysdate + 3) + 2
            ,'Saturday',(sysdate + 3) + 1
            ,(sysdate + 3)
           ) so_the_nextworkday_is
    ,dayname(decode(DAYNAME (sysdate + 3)
                    ,'Friday',(sysdate + 3) + 2
                    ,'Saturday',(sysdate + 3) + 1
                    ,(sysdate + 3)
                    ) 
            ) AS so_the_nextworkday_is_sunday
  FROM
    sysibm.sysdummy1

Monday 25 January 2021

Import SSL from the External Secured URL into Websphere Trust Store | WebSphere

To use the External Services in Maximo, or to integrate with an external system like MS Outlook 365, BIM by Autodesk Revit, or GIS, or any web/rest service. 

All famous browser generally trusts almost all known Certificate Authorities (Digicert, Google Trust Services and so on.) 

But when it comes to Websphere, it doesn't work. Only the Administrator specifically instructs WebSphere to trust by importing the certificate into the Trust Store either at the Cell level or Node level.


Let's instruct Websphere to import a Gmail certificate

  1. Webspher > Security > SSL Certificates and Key management > Key stores and certificates> select  CellDefaultTrustStore(if cluster) / NodeDefaultTrustStore
  2. Then Click Signer certificates > Click on Retrieve from port
    • Host: hosturl i.e google.com
    • port :  443
    • Alias: any name, i.e gmail
  3. press Retrieve signer information (retrieved signer information is displayed)
  4. hit Apply and OK. 
  5. restart cell manger service, nodeservice to take effect. 
  6. done. 

----------------
errors we commonly see if a trust store is missing:

  • PKIX path building failed: java.security.certi.CertPathBuilderException:
  • PKIXCertPathBuilderImpl could not build a valid CertPath.
  • Certificate issued is not trusted
  • BMXAA1477E - the connection failed to the HTTP handler for the endpoint. 
  • etc


Elapsed Time in View Status Dialog - Jython | Maximo

Add an additional column in View History Dialog to see the time elapsed for each status. 

This is a modified version of the solution written by Bruno for the same topic. 

We will accomplish this task with an attribute in the status table and an object-level launch point script written in Jython. 


1. Add a column in PRSTATUS table,  Name: ELAPSEDTIME, Type: Duration.

2. Display this column into View History Dialog using the application designer of the PR application.

2. Write an Object Launch Point Script: Object: PRSTATUS , Save, Add, AfterSave. Copy below the body and paste it. 

Tuesday 19 January 2021

Python Function - Find the Next Business Days After n Days | Maximo

You have 15 business days (exclude weekends) to complete the task, what will be the 15thday?


from java.util import Calendar

#Function definition
def getNextBusinessDday(dn ):
    cal = Calendar.getInstance();
    cal.setTime(d)
    loop=1
    while(loop<=n) :
        cal.add(cal.DATE, +1)
        if (cal.get(cal.DAY_OF_WEEK)) not in [cal.FRIDAY,cal.SATURDAY] : 
            loop=loop+1
        vserial = loop
    calculatedetc = cal.getTime()
    return calculatedetc

#variables for input
d = mbo.getDate("changedate")
n = 15

#function call whereever you want in the same script
getNextBusinessDday(d,n)

Reuseable Scripts - Invoke a Script from a Script - Jython | Maximo

 Question:

  1. Can we invoke a script from another script?
  2. Is it possible to reuse the existing Script?
  3. Can we make the Global function and call it in the script when required?

Solution:

My answer is yes to all the above questions, let's start with this example. 

--- " Do this job within 5 business days (excluding weekends (Friday, Saturday))! "

Okay. Today is 19-Jan, what is my, etc after 5 days.


we will handle this with 2 scripts: 

  1. a library script to take the parameter of date + days and gives an output. 
  2. our script from where we will call the library script. 
1. Create a Library Script and name it any like "LS-GETNEXTBUSINESSDAY"
copy the paste the code below into the body of it. 

from java.util import Calendar
cal = Calendar.getInstance();
cal.setTime(d)
loop=1
while(loop<=n) :
    cal.add(cal.DATE, +1)
    if (cal.get(cal.DAY_OF_WEEK)) not in [cal.FRIDAY,cal.SATURDAY] : 
        loop=loop+1
vNextBDay = cal.getTime()

2.  Call this function from another script with 2 parameters d, n ( date, days)

Monday 4 January 2021

Create Purchase Requisition from Inventory Usage using Action Script (Customized Option) | IBM Maximo

Recently we had the requirement to disable the direct MR to PR automation. so instead of

creating direct PR from MR, the users will select a store on material requisition to reserve material

from store. When the MR is approved, the inventory usage is created from MR.

If the material is available in-store, storeroom will issue the material otherwise he clicks the option

to create Purchase Requisition (PR) from inventory usage.

So we developed this new functionality.

Note: This script contains a few custom attributes. I have commented those line, In your case please remove them.

Step 1:

First Add new Status for Inventory Usage Application: PR_CREATED

Step 2: Create Automation Script

Launch Point:        ACTION

Object:                  INVUSE

Variable:                v_mr

Binding Value:      INVUSELINE[MRNUM is null].MRNUM*

Relations:              INVUSE --> INVUSELINE -->MRNUM (child object:MR, mrnum=:mrnum)