Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Thursday, 30 June 2022

Maximo Attachment File Size

 Below is the script to calculate the Attachment size in Maximo. The File class is used to get the File details and Length() method is used to capture the size details.

from java.io import File 

path = mbo.getString("DOCLINKS.DOCINFO.URLNAME")
print("The Path Value:",path)
if (path):
	file =  File(path)
	print("The Size of the File in Bytes",file.length())
	print("The Size of the File in MB",file.length()/1024)
	print("The Size of the File in GB",file.length()/(1024 * 1024))
Below is the output captured in the system logs.
[6/30/22 8:01:53:951 EDT] 000000e2 SystemOut     O 30 Jun 2022 08:01:53:951 [INFO] [MXServer] [] ('The Path Value:', u'c:\\DOCLINKS\\ATTACHMENTS\\Maximo-access-via-Published-Service-in-your-local-laptop-browser.docx')
('The Size of the File in Bytes', 543667L)
('The Size of the File in MB', 530L)
('The Size of the File in GB', 0L)

Tuesday, 20 April 2021

Maximo Date Format Conversion Using Automation Scripts

We can convert the normal date format to Maximo date format (yyyy-mm-ddThh:mm:ss.ffffff) using Automation Script.

Script Language: javascript

load("nashorn:mozilla_compat.js");
importPackage(Packages.java.text);

erData.breakData();
var actualDate = erData.getCurrentData("ACTUALDATE");
print("INPUT : " +actualDate);

var inputFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
var outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
var dateParse = inputFormat.parse(actualDate);
var maximoDate = (outputFormat.format(dateParse)).replace(" ", "T") +"+05:30";
print("OUTPUT : " +maximoDate);

erData.setCurrentData("ACTUALDATE", maximoDate);

Output:

INPUT : 4/20/2021 03:30:52 PM
OUTPUT : 2021-04-20T15:30:52+08:00

Wednesday, 24 July 2019

Maximo Automation Script setting values while Initializing

There are times where we need to set the value when the object is invoked rather that setting the values during the save method. This can be achieved in Maximo automation scripts.

Step 1: Create an Object Launch Point with JavaScript.
Step 2: Make sure to check the Initialize? check box is checked. And all other check box are unchecked.
Step 3: Below is the sample code for setting the "Inspection Required" and "Adding Spare Parts" check box to always be checked when the item is created.

importPackage(Packages.psdi.mbo);
if(mbo.getString("ITEMSETID")=="ITEMSET1"){
    if(mbo.toBeAdded()==true){
        mbo.setValue("INSPECTIONREQUIRED", 1);
        mbo.setValue("SPAREPARTAUTOADD", 1);
    }
}

Wednesday, 3 April 2019

Integration Flow for Maximo Inbound Using Enterprise Service

Maximo integration framework has always intrigued me. There are different layers at which the MIF works in Maximo. So a college and me had done an experiment in Maximo inbound integration framework using enterprise service. We extended all the base Maximo integration class and added system.out messages to each of the extended methods.

Below is the flow of class that is called when data has been inbound. The experiment was done on Maximo 7.1 version.

Below is the color code for each of the applications.


Below is the flow of diagram from request XML up to Maximo business object validation.

Then response is followed from Maximo to the response XML.


Wednesday, 11 April 2018

Setting Current Date in XSL for Maximo Integration

During Maximo integration there is need to transform XML from Maximo XML format to External System(eg Oracle) XML format. There we can use the XSL mapping in Maximo. Maximo converts the XML to destination XML format using XSL language and vice versa. During that time, if there is need to set the current date in the XSL format see the below code spinet.

<xsl:stylesheet version="1.0"  
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
xmlns:max="http://www.ibm.com/maximo"  
xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java">
 <xsl:template match="/">
  <max:SyncRFQSResponse>
   <max:RFQSet>
    <max:RFQ action="AddChange">
      <xsl:for-each select="max:RFQSyncResponse/max:RFQSet/max:RFQ">
       <max:RFQNUM>
         <xsl:value-of select="max:RFQNUM" />
       </max:RFQNUM>
       <max:SITEID>
         <xsl:value-of select="max:SITEID" />
       </max:SITEID>
       <max:TEST_DATE>
         <xsl:value-of select="java:format(java:java.text.SimpleDateFormat.new('yyyy-MM-dd HH:mm:ss'), java:java.util.Date.new())" />
       </max:TEST_DATE>
      </xsl:for-each>
    </max:RFQ>
   </max:RFQSSet>
  </max:SyncRFQResponse>
 </xsl:template>
</xsl:stylesheet>

Thursday, 15 June 2017

Adding Bulletin Board Message ID field on Maximo Start Center

We can't add Bulletin Board Message ID field through maximo configuration level.

So we need to modify 3 base class files.

\maximo\applications\maximo\maximouiweb\webmodule\WEB-INF\classes\psdi\webclient\controls
BulletinBoard.class

\maximo\applications\maximo\businessobjects\classes\psdi\app\bulletinboard
BulletinBoardCache.class
BBSet.class

Moreover we can't extend these classes since we need to modify some private methods. So we have to do our changes in base class itself.


1) Add below line in BulletinBoard class

columnHeading.put("bulletinboardid", bbset.getMboValueInfoStatic("bulletinboardid").getTitle());