0% found this document useful (0 votes)
291 views237 pages

MBO TR270-JNQP-Max6-Customization-Exercises-SE PDF

Uploaded by

Plex Mailx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
291 views237 pages

MBO TR270-JNQP-Max6-Customization-Exercises-SE PDF

Uploaded by

Plex Mailx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 237

Customizing Business Components in IBM Maximo 6

Student Exercises
S150-2638-00

May 2007
Copyright Notice
Copyright © 2007 IBM Corporation, including this documentation and all software. All rights
reserved. May only be used pursuant to a Tivoli Systems Software License Agreement, an IBM Soft-
ware License Agreement, or Addendum for Tivoli Products to IBM Customer or License Agreement.
No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system,
or translated into any computer language, in any form or by any means, electronic, mechanical,
magnetic, optical, chemical, manual, or otherwise, without prior written permission of IBM Corpora-
tion. IBM Corporation grants you limited permission to make hardcopy or other reproductions of any
machine-readable documentation for your own use, provided that each such reproduction shall carry
the IBM Corporation copyright notice. No other rights under copyright are granted without prior writ-
ten permission of IBM Corporation. The document is not intended for production and is furnished “as
is” without warranty of any kind. All warranties on this document are hereby disclaimed, including the
warranties of merchantability and fitness for a particular purpose.
Note to U.S. Government Users—Documentation related to restricted rights—Use, duplication or
disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corporation.

Trademarks
The following are trademarks of IBM Corporation or Tivoli Systems Inc.: IBM, Tivoli, AIX, Cross-Site,
NetView, OS/2, Planet Tivoli, RS/6000, Tivoli Certified, Tivoli Enterprise, Tivoli Ready, TME. In Den-
mark, Tivoli is a trademark licensed from Kjøbenhavns Sommer - Tivoli A/S.
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in
the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other countries.
C-bus is a trademark of Corollary, Inc. in the United States, other countries, or both.
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States,
other countries, or both.
Lotus is a registered trademark of Lotus Development Corporation.
PC Direct is a trademark of Ziff Communications Company in the United States, other countries, or
both and is used by IBM Corporation under license.
ActionMedia, LANDesk, MMX, Pentium, and ProShare are trademarks of Intel Corporation in the
United States, other countries, or both.
SET and the SET Logo are trademarks owned by SET Secure Electronic Transaction LLC. For fur-
ther information, see http://www.setco.org/aboutmark.html.
Other company, product, and service names may be trademarks or service marks of others.

Notices
References in this publication to Tivoli Systems or IBM products, programs, or services do not imply
that they will be available in all countries in which Tivoli Systems or IBM operates. Any reference to
these products, programs, or services is not intended to imply that only Tivoli Systems or IBM prod-
ucts, programs, or services can be used. Subject to valid intellectual property or other legally pro-
tectable right of Tivoli Systems or IBM, any functionally equivalent product, program, or service can
be used instead of the referenced product, program, or service. The evaluation and verification of
operation in conjunction with other products, except those expressly designated by Tivoli Systems or
IBM, are the responsibility of the user. Tivoli Systems or IBM may have patents or pending patent
applications covering subject matter in this document. The furnishing of this document does not give
you any license to these patents. You can send license inquiries, in writing, to the IBM Director of
Licensing, IBM Corporation, North Castle Drive, Armonk, New York 10504-1785, U.S.A.
Printed in Ireland.
Customizing Business Components in IBM Maximo 6 (Exercises)

Customizing Business Components


in IBM Maximo 6
Hands-on Exercises

Objectives
Upon completion of this unit, you will be able to:
• Customize Maximo Business Components.
– Use customizable methods.
• Init()
• Add()
• Delete()
• Save()
• Etc.
– Work with GL Accounts
– Work with change of status.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 1
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

Agenda

MAXIMO Customization Exercises

Development Environment

Remote Access

Access to MAXIMO Components

Error Processing
Component
Component

Customizing Components Component

Shared Directory
Windows Explorer/Tools/Map Network Drive

\\10.10.10.150\IBMTrain

click

IBMTRAIN/maximo6train

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 2
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

Development Environment

Eclipse.exe
www.eclipse.org

Eclipse Set up

Install Eclipse in your PC

Follow document in directory IBMTrain\eclipse3.2\


Installation-for-Eclipse3.2-Platform.doc

Follow document in directory IBMTrain\eclipse3.2\


Initial-eclipse-3.2-setup.doc

Eclipse.exe

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 3
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

Verify the Scrub Option

Window/Preferences

Verify the Scrub Option

2- Expand the
Output folder

1- Click on Java Compiler Building

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 4
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

Verify the Scrub Option

3- Make sure that the Scrub output


folders is OFF (not selected)

If it is not off. Turn it off and


click OK

10
Development Environment Directories

MXES-Cust-Remote Maximo root directory

company
deployment

default
show
Uses *.jar
add businessobjects.jar

Output of compilation Extract this jar


remains in file from the
MXES-Cust-Remote maximo.ear file

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 5
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

11

Eclipse Set up

Created Project in Eclipse

MXES-Remote

The following exercises use the


MXES-Remote project

12

Create Project MXES-Remote

1-Click on New Drop Down

2- Select Project

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 6
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

13

Create Project MXES-Remote (cont)

1-Select Java Project

2- Click on Next

14

Create Project MXES-Remote (cont)

1-Project Name: MXES-Remote

2- Click on Create project from


existing source

3- Browse for directory


C:\MXES-Cust-Remote
4-Click Finish

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 7
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

15

Project MXES-Remote has


been created and it is open
and setup

16

1-Expand Project

2-Project is setup with the


JRE and jar files needed

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 8
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

17

businessobject.jar must be
there.
It was extracted from the
maximo.ear file

Now we are ready to use Eclipse

18

Notice that the project in the classroom has been setup already.

In your environment you need to follow the following steps:

Create directory MXES-Cust-Remote on hard


drive if it does not exist

Follow the steps on the setup documentation


eclipse3.2-setup\MXRemote-Access-setup\
MXRemote-eclipse3.2-setup.doc

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 9
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

19

20

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 10
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

21

Student Exercise 1 – Show Companies

22
Exercise 1 package company.show

For Companies
Display
Displayfields
fieldsCompany
Companyid id(company),
(company),description
description(name)
(name)and
and
Organization Id (orgid) in the following format:
Organization Id (orgid) in the following format:

All
AllCompanies
Companies
Company
Company Description
Description OrgId
OrgId
-------------
------------- -------------------------------
------------------------------- ----------
----------
length(8)
length(8) length(30)
length(30) length(8)
length(8)

The format is optional

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 11
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

23
Exercise 1 package company.show

public
publicclass
classTestCompShow
TestCompShow
{{ Class: TestCompShow
////
////main
mainprogram
programtotoreceive
receive33arguments
arguments
////
//// -- host
host e.g.
e.g.localhost
localhost
//// -- username
username e.g.
e.g.wilson
wilson
//// -- password
password e.g.
e.g.wilson
wilson
////
public
publicstatic
staticvoid
voidmain(String[]
main(String[]args)
args)
{{

}}
////
////method
methodto
toprint
printall
allthe
thecompanies
companiesin
inthe
theMboSet
MboSet
////
public
publicstatic
staticvoid
voidprintCompany(MboSetRemote
printCompany(MboSetRemotecoset,
coset,String
Stringtitle)
title)
{{
}}
}}

24
Exercise 1 package company.show

public static void main(String[] args)

Check if arguments given


If not print error and return

Get Arguments
Get session
Connect to session
Get MboSet for Companies
Call method printCompany

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 12
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

25
Exercise 1 package company.show

public static void printCompany(MboSetRemote coset


String title)

Print title

Loop for all Mbos in MboSet printing for each one:

Company Description OrgId


------------- ------------------------------- ----------
length(8) length(30) length(8)

The format is optional

26

Create TestCompShow Class

1- Click on the drop


down for New

2- Select
Class

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 13
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

27
Create TestCompShow Class (cont)

1- Type package
company.show

2- Type classname
TestCompShow

3- Select create the


main method
Main method is needed
Eclipse will create all the to be able to be executed
necessary directories

4- Click on Finish

28

The file TestCompShow.java


was created
Package
company.show

Class
TestCompShow

Skeleton with main was


created

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 14
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

29

Double click on the tab


to expand and go back
to package view

The main method is the


Write your code method executed when
you run your application

30

Using Eclipse to set imports

1- If we type:
MXSession session …
It does not know where the
MXSession class is.
It is underlined in red

2- Right mouse click


on the red cross and
select Quick Fix

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 15
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

31

Using Eclipse to set imports

1-Eclipse gives several


options to fix the
problem

2-Click on import
MXSession

32

Using Eclipse to set imports

Eclipse inserts the


import statement

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 16
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

33

Building the project

1-Right mouse click on the Project

2-Select Build Project

34

The errors will be


displayed in the
Problems tab

1 error. Method getMXSession()

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 17
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

35

2- Error line

3- Fix error and re-build

1- Double click on error

36
Exercise 1 package company.show

For Companies
Display
Displayfields
fieldsCompany
Companyid id(company),
(company),description
description(name)
(name)and
and
Organization Id (orgid) in the following format:
Organization Id (orgid) in the following format:

All
AllCompanies
Companies
Company
Company Description
Description OrgId
OrgId
-------------
------------- -------------------------------
------------------------------- ----------
----------
length(8)
length(8) length(30)
length(30) length(8)
length(8)

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 18
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

37

Running The Application

3-Select menu option Run/Run…

2-Select file to run. It must have main


e.g. TextCompShow.java

1- Make sure there are no


errors after build

38

2- Click on New

1-Select Java Application

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 19
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

39

1- Eclipse created a
configuration
TestCompShow

3-Click on Arguments tab

2-Eclipse puts the path to class


company.show.TestCompShow

40

1-Type localhost wilson wilson

2- Click on Run

Maximo must have been started

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 20
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

41

1-Output goes to the Console tab

2- Double click on
Console

42

Output

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 21
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

43

system/notboundexception

Maximo has not been started

44

Exercise 1 package company.show

Running

The documentation for running an Application is in:


eclipse3.2\MXRemote-Access-setup\
MXRemote-run-app-eclipse3.2.doc

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 22
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

45

Student Exercise 1a – Utility

46
Exercise 1a package utils

Create
Createaapackage
packageutils
utils

Create
Createaaclass
classExercisesUtils
ExercisesUtils

Create
Createan
anstatic
staticmethod
methodlogonToMax
logonToMaxthat
that
returns MXSession.
returns MXSession.
Create
Createananstatic
staticmethod
methodprintCompany
printCompany
that
that prints the MboSet asin
prints the MboSet as inExercise
Exercise11

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 23
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

47
Exercise 1a package utils
public
publicclass
classExercisesUtils
ExercisesUtils
{{ Classname: ExercisesUtils
////
////method
methodtotoreceive
receive33arguments
arguments
////
//// - - host
Specs
host e.g.
e.g.localhost
localhost
//// - - username
username e.g.
e.g.wilson
wilson
//// - - password
password e.g.
e.g.wilson
wilson
////
public
publicstatic
staticMXSession
MXSessionlogonToMax(String[]
logonToMax(String[]args)
args)
{{
Method: logonToMax
}}
////
////method
methodtotoprint
printall
allthe
thecompanies
companiesininthe
theMboSet
MboSet
////
public
publicstatic
staticvoid
voidprintCompany(MboSetRemote
printCompany(MboSetRemotecoset,
coset,String
Stringtitle)
title)
{{
}} Method: printCompany
}}

48
Exercise 1a package utils

public static MXSession logonToMax(String[] args)

Check if arguments given


If error print message and System.exit(1);

Get Arguments
Get session
Connect to session Take the statements from
Exercise 1
return session

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 24
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

49
Exercise 1a package utils

public static void printCompany(MboSetRemote coset


String title)

Take the method and all


statements in method from
Exercise 1

50
Exercise 1a package company.show

Hints:
Create
Create class
class TestCompShowUtils
TestCompShowUtils
Get
Get session
session using
using the
the new
new utility
utility
ExercisesUtils.logonToMax
ExercisesUtils.logonToMax
Get
Get the
the MboSet
MboSet for
for COMPANIES
COMPANIES
Print
Print the
the MboSet
MboSet using
using the
the printCompany
printCompany
method from utils
method from utils
ExercisesUtils.printCompany
ExercisesUtils.printCompany

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 25
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

51
Exercise 1a (Test) package company.show
public
publicclass
classTestCompShowUtils
TestCompShowUtils
{{
Specs
////
////main
mainprogram
programto toreceive
receive33arguments
arguments
////
//// -- host
host e.g.
e.g.localhost
localhost
//// -- username
username e.g.wilson
e.g. wilson
//// -- password
password e.g.
e.g.wilson
wilson
////
public
publicstatic
staticvoid
voidmain(String[]
main(String[]args)
args)
{{
MXSession
MXSessionsession
session=ExercisesUtils.logonToMax(args);
=ExercisesUtils.logonToMax(args);
}}
}}

52
Debugging

1-Select class to
debug

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 26
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

53
Debugging

2-Click Run

3-Click Debug

1-Select class to
debug

54

2-Click on New

1-Click on Java
Application

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 27
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

55

Click on Arguments tab

56

1-Enter Arguments

Localhost wilson wilson

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 28
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

57

1- Stop in main

2-Click Debug

58

Debug Perspective
Debug Icons

Variables

Stops in first statement in main

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 29
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

59

Debug Icons

Resume
Step Return
Continues to next
break point Performs all the rest of the
statement in method and
Terminate returns to caller

Step Over
Step Into
Executes current statement
Steps into the method and goes to next.
that is called

60

Click on step over icon


to go to next statement

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 30
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

61

2- To step into the method


logonToMax click on step into
icon

1- Invoking method
logonToMax

62

The step return icon means to


perform all the rest of the
statements in method and
return to caller

Method logonToMax

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 31
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

63
Exercise 1 package company.show

Debugging

Follow the documentation in


eclipse3.2\MXRemote-Access-setup\
MXRemote-debug-eclipse3.2.doc

64

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 32
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

65

Student Exercise 2 - Select

66
Exercise 2 package company.select

Create
CreateaaTestCompSelect
TestCompSelectclass
class
Get
Getthe
thecompany
companysetsetwhere
wherethe
thecompany
companyid id
(company) starts with the letter ‘A’ order by
(company) starts with the letter ‘A’ order by
Company
Companyinindescending
descendingorder.
order.
Use
Usethe
theprint
printmethod
methodcreated
createdin
inUtils
Utils

Use your ExercisesUtils.logonToMax

Use your ExercisesUtils.printCompany

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 33
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

67
Exercise 2 package company.select

public
publicclassclassTestCompSelect
TestCompSelect
{{ Specs
////
////main
mainprogram
programto toreceive
receive33arguments
arguments
////
//// -- host
host e.g.
e.g.localhost
localhost
//// -- username
username e.g. e.g.wilson
wilson
//// -- password
password e.g.wilson
e.g. wilson
////
public
publicstatic
staticvoid
voidmain(String[]
main(String[]args)
args)
{{
Hint
}} Where
Whereclause
clausecondition
condition
}} company
companylike
like‘A%’
‘A%’

68

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 34
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

69

Student Exercise 3 - MboValue

70
Exercise 3 package tool.valuedata
Create
Createclass
classTestToolValueData
TestToolValueData
Create
Createmethod
methodprintTool(MboSetRemote
printTool(MboSetRemotemSet)
mSet)
Display
Displayfields
fieldsToolNum
ToolNum(itemnum),
(itemnum),Description,IssueUnit
Description,IssueUnitfor
for
Tools where issueunit is not null.
Tools where issueunit is not null.
Use
Usethe
theMboValueData
MboValueDatato
toget
getdata
datafor
foreach
eachMbo.
Mbo.
Truncate
Truncatethe
thedescription
descriptionto
to30
30ififlarger
largerthan
than30.
30.
Print
PrintIn
Inthe
thefollowing
followingformat:
format:

ToolNum
ToolNum Description
Description IssueUnit
IssueUnit
-------------
------------- -------------------------------
------------------------------- ----------
----------
length(8)
length(8) length(30)
length(30) length(10)
length(10)

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 35
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

71
Exercise 3
Hints:
Hints: Hints:
Object
Objectname
nameis
isTOOLITEM
TOOLITEM
String[]
String[]attrList={“itemnum”,”description”,”issueunit”};
attrList={“itemnum”,”description”,”issueunit”};
Loop
Loopfor
forall
allMbos
Mbosin
inMboSet
MboSet
Get
GetMboValueData
MboValueDatafor
forlist
listof
ofattributes
attributesfor
foreach
eachMbo
Mbo
get
getdata
datafrom
fromMboValueData
MboValueDataand
anddisplay
displaycalling
calling
printToolLine(toolNum,toolDesc,issueUnit);
printToolLine(toolNum,toolDesc,issueUnit);
Create method
printToolLine(String toolNum,
String toolDesc,
String issueUnit)

72
Exercise 3 package tool.valuedata
public
publicclass
classTestToolValueData
TestToolValueData
{{ Class: TestToolValueData
////
////main
mainprogram
programtotoreceive
receive33arguments
arguments
////
//// - - host
host e.g.
e.g.localhost
localhost
//// - - username
username e.g.
e.g.wilson
wilson
//// - - password
password e.g.
e.g.wilson
wilson
////
public
publicstatic
staticvoid
voidmain(String[]
main(String[]args)
args)
{{

}} printTool method
public
publicstatic voidprintTool(MboSetRemote
staticvoid printTool(MboSetRemotemset,
mset,String
Stringtitle)
title)
{ { //Loop
//Loopthru
thruall
allmbos
mbosininMboSet
MboSet Loop for all Mbos in MboSet
}}
Print one line
public
publicstatic voidprintToolLine(String
staticvoid printToolLine(StringtoolNum,
toolNum,String
StringtoolDesc,
toolDesc,
String
StringissueUnit)
issueUnit)

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 36
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

73

Student Exercise 4 - MboInfo

74
Exercise 4 package tool.valuedata

In
Insame
sameclass
classas
asexercise
exercise33 TestToolValueData
TestToolValueData
Create
Createmethod
methodprintFieldInfo
printFieldInfo
Display
Displaythe
theattribute
attributeinformation
informationfor
forMbo
Mbofor
forfields
fields
ToolNum(itemnum),
ToolNum(itemnum),Description,IssueUnit
Description,IssueUnitfor thefirst
forthe first44Mbos.
Mbos.
--length
length
--isNull
isNull
--isRequired
isRequired
Will be the same for all mbos
--isReadOnly
isReadOnly

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 37
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

75
Exercise 4
Hints:
Hints:
Hints:
String[]
String[]
attrList={“itemnum”,”description”,”issueunit”};
attrList={“itemnum”,”description”,”issueunit”};
Loop
Loopfor
forall
allMbos
Mbosin
inMboSet
MboSet
Get
GetMboValueData
MboValueDatafor
forlist
list
Loop
Loopfor
forall
allattributes
attributesin
inlist
list
display
displayfield
fieldinfo
infofor
foreach
eachattribute
attribute

76
Exercise 4
Hints:

Create method
private static void printFieldInfo(
int i, // mbo position
String name, // field name
MboValueData mvd) // field MboValueData

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 38
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

77
Exercise 4 package tool.valuedata
public class TestToolValueData
{
// main program to receive 3 arguments
// - host e.g. localhost
Specs
// - username e.g. wilson
// - password e.g. wilson
public static void main(String[] args)
{
}

public static void printTool(MboSetRemote mset, String title)

{ //Loop thru all mbos in MboSet

public static void printToolLine(String toolNum, String toolDesc,


String issueUnit)

private static void printFieldInfo(int i,


String name,
MboValueData mvd)

78
Exercise 4 package tool.valuedata

Hint
for (int i = 0; toolSet != null && (((tool = toolSet.getMbo(i)) != null) && i < 4); i++)
{ Loop for Mbos in MboSet
//
// get data from Mbo in an array of MboValueData objects
//
valData = tool.getMboValueData(attrList); Get MboValueData
// for list
for (int j = 0; j < attrList.length; j++)
{ Loop for attributes
printFieldInfo(i, attrList[j], valData[j]); in list
}
} Print the information of
one attribute

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 39
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

79

80

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 40
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

81

Student Exercise 5 – Data for Set

82
Exercise 5 package tool.valuedata

In
Insame
sameclass
classas
asexercise
exercise33TestToolValueData
TestToolValueData
Get
GetMboValueData
MboValueDatafor
forthe
theMboSet
MboSet
Create
Createmethod
method
printToolFromSet(MboSetRemote
printToolFromSet(MboSetRemotemSet)
mSet)
Display
Displayfields
fieldsToolNum,
ToolNum,Description,IssueUnit
Description,IssueUnitasasin
in
Exercise 3 but using MboValueData to get data from
Exercise 3 but using MboValueData to get data from
MboSet
MboSetin inaatwo
twodimensional
dimensionalArray
Array

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 41
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

83
Exercise 5
Hints:
Hints:
Hints:
printToolFromSet(MboSetRemote
printToolFromSet(MboSetRemotemSet,
mSet,String
Stringtitle)
title)

Get
Getthe
theMboValueData
MboValueDatafor
forthe
thewhole
wholeset
set
Loop
Loopthe
thetwo
twodimensional
dimensionalarray
arrayof
of
MboValueData
MboValueData
display
displaydata
datausing
usingprintToolLine(…)
printToolLine(…)

84
Exercise 5 package tool.valuedata

public class TestToolValueData


{
public static void main(String[] args)
Specs
{

printToolFromSet(toolSet,”gettting all in set”);

public static void printTool(MboSetRemote mset, String title)

{ //Loop thru all mbos in MboSet

public static void printToolLine(String toolNum, String toolDesc,


String issueUnit)

private static void printFieldInfo(int i,String name, MboValueData mvd)

private static void printToolFromSet(MboSetRemote toolSet, String title)

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 42
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

85

Student Exercise 6 – MboSet Attributes

86

Exercise 6 package tool.attrib

Write class TestToolAttr

Accept one parameter: an object name e.g. TOOLITEM

Display Key Fields

Display information about all Attributes in Object

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 43
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

87

Exercise 6 package tool.attrib

Write class TestToolAttr

If no argument given use the TOOLITEM object

Display the following information about each Attribute


attributename, alias, classname
isldowner,ispositive ,length
maxtype, mustbe, persistent
remarks, required, sameasattribute,sameasobject

88
Exercise 6 package tool.attrib

Hints:

Get
Getthe
theMboset
Mboset for
forMAXATTRIBUTE
MAXATTRIBUTEforforthe
the
objectname
objectname==the
themboset
mbosetname
nameof
ofthe
theobject
objectpassed
passed
as argument
as argument
Loop
Loopfor
forall
allelements
elementsin
inMboSet
MboSet
display
displayall
allthe
thedata
datafor
foreach
eachelement.
element.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 44
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

89
Exercise 6 package tool.attrib

public
publicclass
classTestToolAttr
TestToolAttr
{{ Specs
public
publicstatic
staticvoid
voidmain(String[]
main(String[]args)
args)
{{


String
StringobjName
objName==“TOOLITEM”
“TOOLITEM”
if(args.length
if(args.length>>3)
3)
objName
objName==args[3]
args[3]
showSetAttributes(objName);
showSetAttributes(objName);
}}

private
privatestatic
staticvoid
voidshowKeys(String
showKeys(StringobjName)
objName)
private
privatestatic
staticvoid
voidshowSetAttributes(String
showSetAttributes(StringobjName)
objName)

90

public static void showSetAttributes(String objName) throws Exception, MXException,


RemoteException Hint
{
MXSession session = MXSession.getSession(); MAXATTRIBUTE MboSet
MboSetRemote attribs = session.getMboSet("MAXATTRIBUTE");
attribs.setWhere("objectname = '" + objName + "'");
attribs.setOrderBy("attributename"); Attribute List
String[] attrList = { "attributename", "alias", "classname","isldowner", "length", "maxtype",
"mustbe", "objectname", "persistent", "required",
"sameasattribute", "sameasobject" };
MboValueData[][] valData = attribs.getMboValueData(0, MboConstants.ALLROWS, attrList);
for (int i = 0; i < valData.length; i++)
Get all attributes
{
System.out.println("Attribute[" + i + "]"); Loop the two for Object
for (int j = 0; j < attrList.length; j++) dimensional array
{
System.out.println("\t" + attrList[j] + ": " + valData[i][j].getData());
}
}
Close MboSet to
attribs.close();
}
free cursor

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 45
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

91

92

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 46
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

93

Student Exercise 7 - Add

94
Exercise 7 package company.add

Create
CreateTestCompAdd
TestCompAddclass
class

addComp()
addComp()method
method(to
(toadd
addthree
threecompanies)
companies)

Currency
CurrencyCode
Code(currencycode)
(currencycode)==“USD”
“USD”

Company
Company==“REMCO1”,
“REMCO1”,and
and“REMCO2”,and
“REMCO2”,and“REMCO3”
“REMCO3”

Description
Description(field
(fieldname)
name)==“Inserted
“Insertedfrom
fromRemote”
Remote”

“REMC01”
“REMC01”and
and“REMCO3”
“REMCO3”with
withlong
longdescription:
description:
Concatenate
ConcatenateCompany
Companywith
withtoday’s
today’sdate
date

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 47
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

95

Getting the date

To get the proper date the Java Date cannot be used.

The date that Maximo uses the server date.

session.getDate()

96
Exercise 7 package company.add

Method
printCompanyWithLD(MboSet ms, String title)

to print the company data including Long


Description if it is exist. You can take the
printCompany method from exercise 1 and
modify it.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 48
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

97
Exercise 7 package company.add

Required Setup

Setup up the “Automatically add Companies to


Company Master” option for COMSET1

98

Companies Setup

In Maximo 6 a Company must exist on the


Company Master.

To facilitate the creation of Companies and


automatically add the Company to the Master
the automatic option for Sets can be used.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 49
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

99

GoTo/Administration/Sets

Select COMPSET1

100

2-Save

1-Set Automatically Add


Company flag

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 50
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

101
Exercise 7 Hints:
MboSetRemotecoset
MboSetRemote coset==
s.getMboSet(“COMPANIES”);
s.getMboSet(“COMPANIES”); Noticeyou
Notice youset
setthe
the
valueto
value tothe
theMbo
Mbo
MboRemoteco
MboRemote co==coset.add();
coset.add();
co.setValue(“company”,”REMCO1”);
co.setValue(“company”,”REMCO1”);

Hintsfor
Hints forprintCompanyWithLD
printCompanyWithLD
Getlong
Get longdescription
descriptionfor
forfield
fieldname
name(which
(whichis
is
the company description)
the company description)
Checkififlong
Check longdescription
descriptionexist
existI.e.
I.e.ititis
isnot
not
null and it is not the empty String.
null and it is not the empty String.

102
Exercise 7 package company.add
public class TestCompAdd
{ Specs
// main program to receive 3 arguments:
// host, username, password
public static void main(String[] args)
{
}
public static void addComp()
{}
public static void printCompanyWithLD(MboSetRemote ms,
String title)
{
}

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 51
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

103

104

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 52
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

105

Student Exercise 8 – Delete

106
Exercise 8 package company.add
Add
Addmethod
methodto
toTestCompAdd
TestCompAddclass
class

delComp()
delComp()method
method

Delete
Deletethe
thecompanies
companiescreated
createdfirst
firstso
soyou
youcan
can
re-run
re-runwithout
withoutgetting
gettingduplicate
duplicateerror.
error.

Companies
Companiesadded
addedwhere
wherelike
like‘REM%’
‘REM%’

Display
Displaythe
thefields
fieldscompany,
company,name
nameand
and
currencycode for the deleted companies
currencycode for the deleted companies

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 53
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

107
Exercise 8 package company.add

public
publicclass
classTestCompAdd
TestCompAdd
{{
public
Specs
publicstatic
staticvoid
voidmain(String[]
main(String[]args)
args)
{{

}}

public
publicstatic
staticvoid
voidprintCompanyWithLD(MboSet
printCompanyWithLD(MboSetms,
ms,String
Stringtitle)
title)
{{
}}
public
publicstatic
staticvoid
voidaddComp()
addComp()
{{ }}

public
publicstatic
staticvoid
voiddelComp()
delComp()
{{}}

108

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 54
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

109

Student Exercise 9 – Modify

110
Exercise 9 package company.mod
Write
WriteTestCompMod
TestCompModclass
class

modComp()
modComp()method
method

Modify the companies created.

Prefix Company description with “Mod-”


i.e. attribute “name”

Add date to long description i.e. name_longdescription

Print modified companies


ExercisesUtils.printCompany(mset,"Modified companies");

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 55
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

111
Exercise 9 package company.mod

public
publicclass
classTestCompMod
TestCompMod
{{
////
Specs
////main
mainprogram
programto toreceive
receive33arguments
arguments
////
//// -- host
host e.g.
e.g.localhost
localhost
//// -- username
username e.g. e.g.wilson
wilson
//// -- password
password e.g.
e.g.wilson
wilson
////
public
publicstatic
staticvoid
voidmain(String[]
main(String[]args)
args)
{{
}}
public
publicstatic
staticvoid
voidmodComp()
modComp()
{{…
…}}
}}

112

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 56
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

113

Student Exercise 10 - Relationships

114
Exercise 10 package workorder.relationship
wo
Write
Writeclass
classTestRelationships
TestRelationships asset

company
Use Relationships
Method
MethodshowUsingRelationships
showUsingRelationships
From
Fromthe
thefirst
first44Workorders
Workordersthat
thathave
haveasset
asset
11––Display
Displaythethefollowing:
following:
from
fromworkorder:
workorder:wonum,
wonum,assetnum,
assetnum,location
location
from
from asset: assetnum, vendor,manufacturer
asset: assetnum, vendor, manufacturer
from
fromcompanies:
companies: company,
company,address,
address,phone
phone

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 57
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

115

Exercise 10 package workorder.relationship


wo
asset
Use Dot Notation
Method
MethodshowUsingDotNotation
showUsingDotNotation company
From
Fromthe
thefirst
first44Workorders
Workordersthat
thathave
haveasset
asset
11––Display
Displaythe
thefollowing:
following:
from
fromworkorder:
workorder:wonum,
wonum,assetnum,
assetnum,location
location
from
fromasset:
asset: assetnum,
assetnum,vendor,
vendor,manufacturer
manufacturer
from
fromcompanies:
companies: company,
company,address,
address,phone
phone

116
Exercise 10 package workorder.relationship

public
publicclass
classTestRelationships
TestRelationships
{{ Specs
public
publicstatic
staticvoid
voidmain(String[]
main(String[]args)
args)
{{
////get
getMboSet
MboSetandandcall
callmethods
methods
}}
public
publicstatic
staticvoid
voidshowUsingRelationships()
showUsingRelationships()
{{
}}
public
publicstatic
staticvoid
voidshowUsingDotNotation()
showUsingDotNotation()

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 58
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

117

Student Exercise 10a – All Relationships

118
Exercise 10a package utils

Add the following method


public static void showAllRelationships(MboSetRemote mset)

To the class ExercisesUtils

Display
Displayall
allthe
therelationships
relationshipsfor
forthe
theMboSet
MboSetpassed
passedas
as
parameter.
parameter.
Relationship
RelationshipName
Name Child
Child Sql
Sqlwhere
whereclause
clause
--------------------------
-------------------------- ----------------
---------------- -------------------------
-------------------------

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 59
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

119
Exercise 10a package utils

Hints:

Get
Getthe
theMboSet
MboSetfor
forMAXRELATIONSHIP
MAXRELATIONSHIPfor forthe
the
objectname = the mboset name of the mboset
objectname = the mboset name of the mboset
passed
passedasasargument
argument
Loop
Loopforforall
allthe
theMbos
Mbosin
inMboSet
MboSetdisplaying
displayingthe
the
fields
fields
Name,
Name,child
childand
andwhereclause
whereclause

120

MAXRELATIONSHIP Table Hints:


Name Parent Child WhereClause

Relationship to the Asset table, used to


find the asset for a work order.

ASSET WORKORDER ASSET assetnum = :assetnum


and siteid=:siteid
Relationship name

What we need is to get the Mbos that have the parent = to


the Object we are interested in.
e.g. where clause is: parent = ‘WORKORDER’

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 60
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

121

Getting Object Name

MboSetRemote mSet = session.getMboSet(“COMPANIES”);

Get Object Name from MboSet

String objName = mSet.getName();

122
Exercise 10a package workorder.relationship

Write Hints:
Writeclass
classTestAllRelationships
TestAllRelationships

Use
Usethis
thisclass
classto
totest
testthe
theShowAllRelationships
ShowAllRelationships
MboSetRemote
MboSetRemotewoset
woset==s.getMboSet(“workorder”)
s.getMboSet(“workorder”)
ExercisesUtils.showAllRelationships(woset);
ExercisesUtils.showAllRelationships(woset);

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 61
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

123

124

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 62
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

125

Student Exercise 11 - Hierarchy

126

Company Hierarchies

COMPANY

COMPANY-child
COMPANY-child parentcompany

Only one level


supported in Linking field
MAXIMO

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 63
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

127
Exercise 11 package company.hierarchy
Create
Createthe
thefollowing
followinghierarchy
hierarchyof
ofcompanies
companies

SDKCO1
SDKCO2
SDKCO1-1
SDKCO2-1

SDKCO3 SDKCO2-2

SDKCO3-1 Top Level

SDKCO3-2 Child

SDKCO3-3

128
Exercise 11 package company.hierarchy

Hints: Class name TestCompHierarchy

1 Create the Top Level

2 Create the children

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 64
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

129
Exercise 11 package company.hierarchy

Hints:

MboRemote co = coSet.add(); parent


co.setValue(“company”,”coparent”);
coSet.save();

MboRemote coChild = coSet.add();


coChild.setValue(“company”,”child1”);
coChild.setValue(“parentcompany”,”coparent”);
coSet.save();
child

130
Exercise 11 package company.hierarchy

Hints:
Top Level Name: SDKC0x
Create a method to do the add a
Is there a pattern? Top Level company
Parameters: Company Name

Create a method to do the add of


Hierarchy for one company,
parameters: Company name and
number of children

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 65
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

131
Exercise 11 package company.hierarchy

Hints:

Create method to delete the added


companies to be able to re-run the test

Note:

A company cannot be deleted if it is a


parent.

The children have to be deleted first

132

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 66
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

133

Student Exercise 11a – Show Hierarchy

134
Exercise 11a package company.hierarchy

Create method printCompHierarchy


Display companies with children

Company
Company Children
Children
-----------------------------------------------------------
-----------------------------------------------------------
SDKCO1
SDKCO1
SDKCO1-1
SDKCO1-1
Hint:
SDKCO2
SDKCO2 Relationship?
SDKCO2-1
SDKCO2-1
SDKCO2-2
SDKCO2-2

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 67
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

135
Exercise 11a package company.hierarchy

public
publicclass
classTestCompHierarchy
TestCompHierarchy Specs
{{
public
publicstatic
staticvoid
voidmain(String[]
main(String[]args)
args)
private
privatestatic
staticvoid
voiddeleteChildrenAndTop(MboSetRemote
deleteChildrenAndTop(MboSetRemotemset)
mset)
public
publicstatic
staticvoid
voidaddTopLevel(MboSetRemote
addTopLevel(MboSetRemotemset,
mset,String
String
coName)
coName)
public
publicstatic
staticvoid
voidaddChildren(MboSetRemote
addChildren(MboSetRemotemset,
mset,
String
StringparentName,
parentName,int
intnChildrent)
nChildrent)
public
publicstatic
staticvoid
voidprintCompHierarchy(MboSetRemote
printCompHierarchy(MboSetRemotecoset,
coset,
String
Stringtitle)
title)

136

Verifying it works

GoTo/Purchasing/Companies and type “SDK” you


should see All the companies in the hierarchy

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 68
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

137

Student Exercise 12 - Exceptions

138
Exercise 12 package exception

Create
Createaaclass
classTestException
TestException

Create
Createmethod
methodaddCompException
addCompExceptionwhere
whereyou
youadd
add
twice
twicethe
thesame
samecompany
companywhich
whichproduces
producesand
andException.
Exception.
Use
Use aatry
tryand
andcatch
catchblock
blockand
anddisplay
displayall
allthe
theinformation
informationabout
about
the exception
the exception
--error
errorgroup
group
--error
errorkey
key
--error
errormessage
message
--parameters
parameters

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 69
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

139
Exercise 12a package exception

Create
Createyour
yourown
ownerror
error message
message
duplicateComp=The
duplicateComp=Thecompany
company{0}
{0}is
isaaduplicate
duplicate
company
company
Run
Runaasql
sqlscript
scriptto
toupdate
updateMaximo
Maximo66messages.
messages.
In
Inyour
yourprogram
programthrow
throwthe
theexception
exception
MXApplicationException
MXApplicationException withyour
with yourmessage
message

Put
Putaatry
tryand
andcatch
catchin
inthe
themain
mainand
anddisplay
displaythe
the
exception information.
exception information.

140

SQL Script to update messages

INSERT INTO MAXMESSAGES (MSGGROUP, MSGKEY,


VALUE, TITLE, DISPLAYMETHOD, OPTIONS,
BUTTONTEXT,MAXMESSAGESID )
VALUES (
‘msgGroup', ‘msgKey', 'msgTxt'
, NULL, 'MSGBOX', 2, NULL,
MAXMESSAGESSEQ.nextval);
Commit;

You must re-start Maximo after inserting the message

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 70
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

141

SQL Script to update messages

INSERT INTO MAXMESSAGES (MSGGROUP, MSGKEY,


VALUE, TITLE,
DISPLAYMETHOD, OPTIONS,
BUTTONTEXT,MAXMESSAGESID )
VALUES (
'mycompany', 'duplicateComp',
'The company {0} is a duplicate company', NULL,
'MSGBOX', 2,
NULL, MAXMESSAGESSEQ.nextval);
Commit;

You must re-start Maximo after inserting the message

142
Exercise 12 package exception
public
publicclassclassTestException
TestException
{{
////main
mainprogram
programto toreceive
receive33arguments
//// - - host
arguments
host e.g.
e.g.localhost
localhost
Specs
//// - - username
username e.g.
e.g.wilson
wilson
//// - - password
password e.g.
e.g.wilson
wilson
//// private
privatestatic
staticvoid
voidaddCompException()
addCompException()
public
publicstatic
staticvoid
voidmain(String[]
main(String[]args)
args)
{{
{{
try
try
try
try
{{////add
addaacompany
companytwice
twiceto
to
{{ addCompException();
addCompException();
force exception
force exception
}}
}}
catch(…)
catch(…)
catch(…)
catch(…)////catching
catchingMXException
MXException
{{ ////display
displayall
allthe
thedetails
detailsof
ofexception
exception
{{
}}
throw
throwexception
exceptionwith
withmessage
message
}}

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 71
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

143
Exercise 12 package exception
private static void addCompException()

{ Specs (cont)
try

{ // add a company twice to produce exception

}
catch(…)

// display all the details of exception


// including parameters

throw exception with your own message

}
}

144

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 72
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

145

Student Exercise 13 – IN19

146

Customizing
Customizing
MAXIMO Business
MAXIMO Business
Components
Components

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 73
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

147
Customizing Business Components

Validation Classess

New validation class

Extending existing class

MAXIMO Business Objects

New mbo class

Extending existing mbo

148
Exercise 13- Steps

Set up MAXIMO for development. NO ear file.


Exploded directory mode

Follow the document:


C:\IBMTrain\
webLogic8-setup\8.1.4\
webLogic8-setup-read-first.doc

Notice that in the VM environment Maximo has been setup with no ear file

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 74
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

149

Configuring WebLogic for Development

1- Create a domain
For Maximo setup
webLogic8-create-domain.doc

2- Configure domain
webLogic8-configure-domain.doc
Or
webLogic8-create-domain-with-JMS.doc

3- Set up Maximo for development (No ear file)


webLogic8-MXES as an exploded ear file.doc

Notice that in the VM environment Maximo has been setup with no ear file

150
Development Environment Directories

MAXIMO root
applications

maximo

businessobjects

MXES-Customization classes
Link to

psdi

source
classes

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 75
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

151
MAXIMO root
Development Directories applications
maximo
businessobjects

MXES-Customization classes
Link to

Customization root psdi


custom
app
app
class
e s
company
custom
source
Output of compilation goes to
MAXIMO classes directories app

152

Create Project MXES-Custom

1-Click on New Drop Down

2- Select Project

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 76
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

153

Create Project MXES-Custom (cont)

1-Select Java Project

2- Click on Next

154

Create Project MXES-Custom (cont)

1-Project Name: MXES-Custom

2- Click on Create project from


existing source

3- Browse for directory


C:\MXES-Customization
4-Click Finish

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 77
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

155

Project MXES-Custom has


been created and it is open
and setup

156

1-Expand Project

2-Project is setup with the


JRE and jar files needed

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 78
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

157

MXES-Classes is a link
directory pointing to the MXES
root directory.

Now we are ready to use Eclipse project

158

Eclipse Set up

Create directory MXES-Customization on hard drive

Start Eclipse

Follow the steps on the setup


documentation
MXCustom-eclipse3.2-setup.doc

Create project MXES-Custom

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 79
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

159

Customizing Validation Classes Steps


Selectattribute
Select attributeto
tocustomize
customize

Findclass
Find classin
inMAXATTRIBUTE
MAXATTRIBUTE

Writejava
Write javafile
fileto
toextend
extendclass
class

Putfile
Put filein
incustom/app/…
custom/app/…directory
directory

Compileclass
Compile class

ModifyMAXATTRIBUTE
Modify MAXATTRIBUTEto
topoint
pointto
to
the new class
the new class

ModifyMAXATTRIBUTECFG
Modify MAXATTRIBUTECFGto
topoint
point
to the new class
to the new class

160

Exercise 13 package custom.app.item

Add
Addthe
thefield
fieldIN19
IN19from
fromITEM
ITEMtable
tableto
tothe
theITEM
ITEMscreen.
screen.
Create
Createfield
fieldvalidation
validationfor
forIN19:
IN19:
1-1-Initialize
Initializefield
fieldto
to“IT1”
“IT1”for
fornew
newrecords
records
2-2-Allow
Allowvalues
valuesthat
thatstart
startonly
onlywith
with“I”
“I”
3-3-IfIfvalid
validmake
makeititupper
uppercase
case
4-4-IfIfinvalid
invaliddisplay
displayyour
yourown
ownerror
error

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 80
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

161

Class Customization Directories

MXES-Customization MAXIMO root directory


Link to
psdi
Customization root
custom app

app item
class
e s custom
item
source app
.java

Package custom.app.item item

162
Exercise 13 package custom.app.item

Steps Hints:
Check
CheckMAXIMO
MAXIMOdata
datadictionary
dictionaryto
tosee
seeififthere
thereisisaa
validation
validationclass.
class.

select
selectobjectname,attributename,classname
objectname,attributename,classname
from
frommaxattribute
maxattribute
where
whereobjectname='ITEM'
objectname='ITEM'
and
andattributename
attributename==‘IN19’;
‘IN19’;

No
Novalidation
validationclass
classexist
exist

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 81
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

163
Exercise 13

Hints:

Class
Class name
name for
for field
field IN19
IN19 would
would be
be
FldItemIN19
FldItemIN19
For
For customized
customized classes:
classes:
CustFldItemIN19
CustFldItemIN19

Prefix: Cust

164

Class Hierarchy for Field Validation

MboValueAdapter

MAXTableDomain Fld…

Fld… CrossOverDomain ALNDomain ValueListDomain

Fld… Fld… Fld…

javadoc

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 82
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

165

Exercise 13
Hierarchy

MboValueAdapter
No Validation
class exist we
inherit from
top level
CustFldItemIN19

166
Exercise 13
Hints:

Tool
Tool to
to generate
generate the
the template
template for
for
field Validation Classes
field Validation Classes

Unzip
Unzip the
the Generate-MXES.zip
Generate-MXES.zip file
file from
from
the
the share directory mxgenerate into your
share directory mxgenerate into your
C:\MXESGenerate
C:\MXESGenerate

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 83
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

167
Exercise 13 Hints: Generating the template
for your new validation class

generatefldval
generatefldval p1
p1 p2
p2 p3
p3 p4
p4 p5
p5

where
where
p1
p1--MAXIMO
MAXIMOroot
rootc:\MXES
c:\MXES
P2
P2--table
tablename
name e.g.
e.g.Companies
Companies
P3
P3 - column name e.g.
- column name e.g.currencycode
currencycode
p4
p4--Customization
Customization root
rootdirectory
directory
e.g.
e.g.c:\mxes-customization
c:\mxes-customization
P5
P5 - customobject
- custom object e.g.
e.g.
custom.app.company.CustFldCompanyCurrencyCode
custom.app.company.CustFldCompanyCurrencyCode

ififthere
thereis
isaavalidation
validationclass
classfor
forthe
thefield
fieldititwill
willextend
extend
that validation class otherwise it extends MboValueAdapter
that validation class otherwise it extends MboValueAdapter

168
Exercise 13 Hints: Getting help with
parameters

Typing
Typinggeneratefldval
generatefldvalwith
withno
noparameters
parametersdisplays
displayshelp
help

Parameters:
Parameters:
p1
p1--MAXIMO
MAXIMOroot
rootc:\MXES
c:\MXES
P2
P2--table
tablename
name e.g.
e.g.Companies
Companies
P3
P3 - column name e.g.
- column name e.g.currencycode
currencycode
p4
p4--Customization
Customization root
rootdirectory
directory
e.g.
e.g.c:\mxes-customization
c:\mxes-customization
P5
P5--custom
customobject
object e.g.
e.g.
custom.app.company.CustFldCompanyCurrencyCode
custom.app.company.CustFldCompanyCurrencyCode

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 84
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

169
Exercise 13 Hints: Generating the template
for your new validation class

C:\MXESgenerate>
C:\MXESgenerate>generatefldval
generatefldvalc:\MXES
c:\MXES ITEM
ITEMIN19
IN19
C:\MXES-Customization
C:\MXES-Customization
custom.app.item.CustFldItemIN19
custom.app.item.CustFldItemIN19

C:\MXES
C:\MXES --MAXIMO
MAXIMOroot
rootdirectory
directory
ITEM
ITEM --MAXIMO
MAXIMOtable
tablename
name
IN19
IN19––Field
Fieldname
namein
intable
tableITEM
ITEM
C:\MXES-Customization
C:\MXES-Customization––Customization
Customizationdirectory
directory
custom.app.item.CustFldItemIN19
custom.app.item.CustFldItemIN19––Field
Fieldvalidation
validationclass
class

Package and class

170
Exercise 13 Hints: Generating the template
for your new validation class
C:\MXESgenerate>
C:\MXESgenerate>generatefldval
generatefldvalc:\MXES
c:\MXES ITEM
ITEMIN19
IN19
C:\MXES-Customization
C:\MXES-Customization Type in
custom.app.item.CustFldItemIN19
custom.app.item.CustFldItemIN19 One line
The following files are created after executing:
The directory
C:\MXES-Customization\custom\app\item\ has:
CustFldItemIN19.java
CustFldItemIN19-register.sql
CustFldItemIN19-restore-orig.sql
CustFldItemIN19-message-register.sql
CustFldItemIN19-message-delete.sql

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 85
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

171
Exercise 13 Hints:

Write code for


CustFldItemIN19

field
fieldvalidation
validationclass
classfor
forIN19:
IN19:
1- initValue()
1-Initialize
Initializefield
fieldto
to“IT1”
“IT1”for
fornew
newrecords
records
2-
2-Allow
Allowvalues
valuesthat
thatstart
startwith
withIIonly
only
validate()
3-
3-IfIfinvalid
invaliddisplay
displayyour
yourown
ownerror
error
4-
4-IfIfvalid
validmake
makeititupper
uppercase
case action()

172
Exercise 13
Hints: Creating your
messages

Update
UpdateMAXMESSAGES
MAXMESSAGEStable
table

Create
Createaanew
newmessage
messagefor
forError
ErrorDialog
DialogBox
Box
Group:
Group:myitem
myitem
Id:
Id:InvalidIN19
InvalidIN19
Message:
Message:The
Thevalue
valueof
ofIN19
IN19must
muststart
startwith
withan
anI.I.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 86
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

173

SQL Script to update messages

INSERT INTO MAXMESSAGES (MSGGROUP, MSGKEY,


VALUE, TITLE, DISPLAYMETHOD, OPTIONS,
BUTTONTEXT,MAXMESSAGESID )
VALUES (
‘myitem', ‘invalidIN19',
‘The value of IN19 must start with an I. '
, NULL, 'MSGBOX', 2, NULL,
MAXMESSAGESSEQ.nextval);

Sequence for id

174

Go To/Configuration/Application Designer

Select ITEM Master

Display IN19 on the ITEM App

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 87
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

175

ITEM Tab

176

1-Control
Palette

2-Text Box
3-Drag and Drop

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 88
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

177

New Field is not bound yet

178

2-Textbox Properties

3-Label: IN19

4-Attribute: IN19

1-Select Field

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 89
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

179

Save
changes

180

New field IN19

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 90
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

181

Updating the MXES Data Dictionary

Using Database Configuration

Using Sql Scripts

182

Database Configuration App

Update Class Field

You would need to shut down Maximo and reconfigure

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 91
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

183

Steps

Update Maximo Data Dictionary


Run script: CustFldItemIN19-register.sql

Modify CustFldItemIN19.java

initValue() – Initialize field with “IT1”

validate() – Check that fields starts with “I”

action() – make the field Upper Case

184
Exercise 13- Steps

Generate the Java and SQL scripts


DBMS
Update record in MAXATTRIBUTE
and MAXATTRIBUTECFG using SQL script MAXATTRIBUTE

or the Database Configuration MAXATTRIBUTECFG

Write the Field Validation code and build

Modify Screen for Item using the App


Designer

Update MAXMESSAGES

Re-start MAXIMO and test

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 92
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

185

Restart Maximo

Note:

Every time that you


modify a Java class
you MUST re-start
Maximo

186

Debugging MAXIMO in Eclipse

webLogic
Eclipse
Eclipse webSphere

JVM attaches JVM

App Server must be started in port: 8888


debug Mode

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 93
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

187

Debugging MAXIMO in Eclipse

Start
Start MAXIMO
MAXIMO in
in debug
debug Mode
Mode

WebLogic: startWebLogicDebug.cmd

WebSphere: Follow steps on next slides

188

WebSphere in Debug Mode

1- Servers

2- Application servers

3-Select MAXIMOSERVER

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 94
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

189

WebSphere in Debug Mode

Scroll down

190

WebSphere in Debug Mode

Click on Debugging
Service

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 95
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

191

WebSphere in Debug Mode

1-Enable Debugging Service

2-Change port to 8888

3-Click Apply

192

WebSphere in Debug Mode

Click Save

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 96
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

193

WebSphere in Debug Mode

1- Select Synchronize changes

2- Click Save

194

WebSphere in Debug Mode

Click OK

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 97
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

195

WebSphere in Debug Mode

Click OK

196

WebSphere in Debug Mode

Click Save

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 98
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

197

WebSphere in Debug Mode

Click Save

198

WebSphere in Debug Mode

Click OK

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 99
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

199

WebSphere in Debug Mode

Maximo is not
started yet

200

WebSphere in Debug Mode

2-Click on Start

Maximo is not
1- Select
started
MAXIMOSERVER

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 100
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

201

WebSphere in Debug Mode

Maximo is now
started

202

Setup Eclipse to run in Debug Mode

Eclipse 3.2 setup to run a Remote


Application in Debug Mode

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 101
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

203

2- Select Menu Run

3-Select Debug…

1- Click on Project

204

2-Click on New

1- Select Remote Java Application

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 102
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

205

1-Change port to 8888

2-Click on Debug

206

Error Case: Maximo not started in Debug Mode

Maximo has to be started in debug mode


e.g. startWebLogicDEBUG.cmd

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 103
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

207

If Maximo started in Debug Mode

Now the two JVM are linked and we can debug

208

Debugging MAXIMO in Eclipse

Follow
Follow the
the documentation
documentation
eclipse3.2-setup\
eclipse3.2-setup\
MXMbo-Customization-setup\
MXMbo-Customization-setup\
MXCustom-debug-eclipse3.2.doc
MXCustom-debug-eclipse3.2.doc

Start
Start MAXIMO
MAXIMO in
in debug
debug Mode
Mode

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 104
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

209

Student Exercise 13 A - YesNoCancel

210

Exercise 13a package custom.app.item.yesno

Same
Same as
as Exercise
Exercise 13
13

Display
Display aa Yes, Yes, No,
No, Cancel
Cancel dialog
dialog box
box
and allow to enter a value not starting
and allow to enter a value not starting
with
with “I”
“I” ifif the
the response
response is
is Yes.
Yes.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 105
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

211

Restore Original

Restore the Original Validation


class for IN19 i.e. null BEFORE
generating new validation class

Run the script:

CustFldItemIN19-restore-orig.sql

212
Exercise 13a Hints: Generating template for
package custom.app.item.yesno
generatefldvalyesno
generatefldvalyesno p1
p1p2
p2p3
p3p4
p4p5
p5

C:\MXESgenerate>generatefldvalyesno
C:\MXESgenerate> generatefldvalyesnoc:\mxes
c:\mxes
ITEM IN19 C:\MXES-Customization
ITEM IN19 C:\MXES-Customization
custom.app.item.yesno.CustFldItemIN19
custom.app.item.yesno.CustFldItemIN19
C:\mxes - MAXIMO root directory
ITEM - MAXIMO table name
IN19 – Field name in table ITEM
C:\MXES-Customization – Customization directory
custom.app.item.yesno.CustFldItemIN19 – Field validation
class Package and class name

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 106
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

213

Exercise 13a (cont)


package custom.app.item.yesno

Create the new logger


maximo.custom and use it to
display “Entering …” for each
method in the validation class.

214
Exercise 13a
Hints: Creating your
messages

Update MAXMESSAGES table

Create a new message for YesNoCancel Dialog Box


Group: myitem
Id: InvalidIN19YesNo
Message: The value of IN19 must start with an I. Do
you want to override it?.

Use the message from Exercise 13 (InvalidIN19) for


non-interactive

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 107
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

215

SQL Script to update messages

INSERT INTO MAXMESSAGES (MSGGROUP, MSGKEY,


VALUE, TITLE, DISPLAYMETHOD, OPTIONS,
BUTTONTEXT,MAXMESSAGESID )
VALUES (
‘myitem', ‘invalidIN19YesNo',
‘The value of IN19 must start with an I. Do you want to
override it?'
What Option
, NULL, 'MSGBOX', ???, NULL,
Number???
MAXMESSAGESSEQ.nextval);

Sequence for id

216

Restart Maximo

Note:

Every time that you


modify a Java class
you MUST re-start
Maximo

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 108
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

217

Student Exercise 14 – Child Currency

218
Exercise 14 package custom.app.company

IfIfthe
thecompany
companyis
isaachild
childset
setthe
thefield
field
CURRENCYCODE
CURRENCYCODEas asread
readonly.
only.

Two
Twocases:
cases:

New
NewCompanies
Companies

Existing
ExistingCompanies
Companies

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 109
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

219

Exercise 14 - Company Hierarchies

A company is a
child if it has a
COMPANY parent

COMPANY-child parentcompany

Only one level


supported in Field
MAXIMO parentcompany

220
Exercise 14 Hints:

IfIfthe
thecompany
companyis
isaachild
childset
setthe
thefield
field
CURRENCYCODE as read
CURRENCYCODE as read only.only.
Extend
parentcompany
validation class
Two
Twocases:
cases:

New
NewCompanies
Companies action()

Existing
ExistingCompanies
Companies init()

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 110
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

221

Triggering Event

The triggering event is the modification of the field


parentcompany.

A company is a
child if it has a
COMPANY parent

COMPANY-child parentcompany

222

Becoming a Child

There are two ways of becoming a Child

When creating a new company set up the


parent field

Add branches to an existing


company.
The company added as a branch
becomes the Child of the current
company

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 111
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

223

2- Branches tab to add


a child to this Company

1-Creating a New
Company to be used as
the Top level Company
i.e. NO parent

224

New Row to
add a child

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 112
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

225

Select a Company from


the list of existing
companies that do not
have a parent

226

When we click on
save the Parent of
“ACSN” will be set
to “COPARENT”

Selected
child In this case we made an
existing Company into a
child

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 113
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

227

New Company created as child

Parent can be
associated at this time.

228

Exercise 14 - Steps
Selectattribute
Select attributeto
tocustomize
customize

C:\MXESgenerate>
C:\MXESgenerate>generatefldval
generatefldvalc:\MXES
c:\MXES COMPANIES
COMPANIES
PARENTCOMPANY C:\MXES-Customization
PARENTCOMPANY C:\MXES-Customization
custom.app.company.CustFldCompanyParentCompany
custom.app.company.CustFldCompanyParentCompany

Writebusiness
Write businesslogic
logic

Compileclass
Compile class

RunScripts
Run Scriptsto
toupdate
updateData
Datadictionary
dictionary

RestartMaximo
Restart Maximoand
andtest
test

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 114
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

229

Restart Maximo

Note:

Every time that you


modify a Java class
you MUST re-start
Maximo

230
Exercise 14 package custom.app.company

public class CustFldCompanyParentCompany


extends FldCompanyParentCompany
{ Specs
public void init() …
{ psdi.app.company
// check for existing companies
}

public void action() …


{
// check for new companies
}
}

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 115
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

231

232

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 116
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

233

Student Exercise 14 A – Three Children

Optional

234
Exercise 14a package custom.app.company

Optional Exercise

In the same class of Exercise 14

Do not allow a company to have more


than three children

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 117
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

235
Exercise 14a package custom.app.company
public
publicclass
classCustFldCompanyParentCompany
CustFldCompanyParentCompany
Optional extends
extendsFldCompanyParentCompany
FldCompanyParentCompany
{{ Do not allow a company to have more
than three children

public
publicvoid
voidvalidate()
validate()……
{{
////check
checkthat
thatthe
theparent
parentdoes
doesnot
nothave
havemore
more
////than
than33children
children
}}

}}

236
Exercise 14a package custom.app.company

Testing

Only the case for NEW companies can be tested.

The validation() method is NOT executed for old


companies because the field setValue(…) is done
with NOVALIDATION during the save() for
Company

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 118
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

237

Student Exercise 15 – Child Same Currency

238
Exercise 15 package custom.app.company

The currency
The currency code
code for
for all
all the
the children
children of
of
aa company
company must
must be
be the
the same
same as as the
the
parent’s
parent’s

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 119
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

239
Exercise 15 package custom.app.company

Cases

1-Ifthe
1-If thecurrency
currencycode
codeis ischanged
changedforforaacompany
company
thatis
that isaaparent
parentchange
changethethecurrency
currencycode
codefor
forall
all
the children to be the same as the parent.
the children to be the same as the parent.
2-Ifaanew
2-If newcompany
companyis iscreated
createdas
asaachild
childitit
should have the same currencycode
should have the same currencycode asasits
its
parent
parent

3-Ifan
3-If anold
oldcompany
companybecomes
becomesaachild
childititshould
should
havethe
have thesame
samecurrencycode
currencycodeas
asits
itsparent
parent

240
Exercise 15 package custom.app.company

Hint Case: 1-Changing a parent’s currency

Extend the
Extend the currencycode
currencycode validation
validation class
class

Find the class for validation of currencycode

What method do you need to override?

At what moment we know for sure


that the CURRENCYCODE is going
to be changed for a parent???

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 120
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

241
Exercise 15 package custom.app.company

Hint Case: 1-Changing a parent’s currency

Check ifif there


Check there are
are children
children

What Relatiohship?

Loop through all children changing their


currency to the one in the parent

242
Exercise 15 package custom.app.company

Testing Case: 1-Changing a parent’s currency

Select aa Company
Select Company that
that have
have children
children and
and
modify the
modify the Currency
Currency

Verify that
Verify that all
all the
the children
children have
have the
the parent’s
parent’s
currency
currency

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 121
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

243

1-Select new
Currency

244

3-Go To/Financial/Exchange Rates

2-If error:
“The exchange rate was
not found”

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 122
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

245

Click on New Row

246

3-Click on Save

1-Setup the new 2-Set up Active and


Exchange Rate Expiration Dates

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 123
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

247
Exercise 15 package custom.app.company

Hint Case: 2-Making a Company a child

Extend the
Extend the parentcompany
parentcompany validation
validation class
class

No need to create a new Java file

Use the same class as in Exercise 14

Check if it is a child and set currency


code the same as parent

248
Exercise 15 package custom.app.company

Testing Case: 2-Making a New Company a child

Create aa New
Create New Company
Company and
and assign
assign aa
parent
parent

Verify that
Verify that the
the currency
currency is
is the
the parent’s
parent’s
currency
currency

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 124
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

249
Exercise 15 package custom.app.company

Testing Case: 3-Making an old Company a child

Add aa branch
Add branch to
to aa Company
Company

The branch
The branch Company
Company should
should have
have the
the
currency of
currency of the
the parent.
parent.

250

Case that cannot be tested

Testing Case: 3-Making an old Company a child

Notice
In the current release the action() method
is NOT executed when an existing company
becomes a branch (a child) because the field is
setup with NOACTION during the save() for
Company

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 125
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

251

252

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 126
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

253

Student Exercise 15 A – No List

254
Exercise 15a package custom.app.company

Donot
Do notdisplay
displayaaList
Liston
onthe
theCurrencyCode
CurrencyCode
field if the field is ReadOnly.
field if the field is ReadOnly.
Inthe
In theprevious
previousexercise
exercisethe
thefield
fieldwas
wasmade
made
ReadOnly when the company was a child.
ReadOnly when the company was a child.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 127
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

255

Maximo Default Behavior

When the list icon is clicked


Currency displays the list even though
field is you cannot select from list
read Only since field is read only

256

Maximo Default Behavior

When you select from list


then it gives you error
message

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 128
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

257

Customized Behavior

Company is a child

When the list icon is


clicked displays message

Currency field is read Only

258
Exercise 15a package custom.app.company

Hint

Check ifif field


Check field ReadOnly
ReadOnly

What methods to modify???

A method associated with the


displaying of the list

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 129
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

259

Exercise 15a - Steps


Selectattribute
Select attributeto
tocustomize
customize

GenerateJava
Generate Javaand
andScript
Scriptfiles
filesin
inthe
the
custom/app/… directory
custom/app/… directory

Writebusiness
Write businesslogic
logic

Compileclass
Compile class

RunScripts
Run Scriptsto
toupdate
updateData
Datadictionary
dictionary

RestartMaximo
Restart Maximoand
andtest
test

260

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 130
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

261

Student Exercise 16 – MA Vendors

262
Exercise 16 package custom.app.pr

We
Wedeal
dealonly
onlywith
withvendor
vendorcompanies
companiesin
in
Massachusetts
Massachusetts
We
Wedo
donot
notdeal
dealwith
withmanufacturers.
manufacturers.
Therefore
Thereforethe
thevalid
validlist
listfor
forvendors
vendorsmust
mustbe
be
such
such that the address can only havethe
that the address can only have thestate
state
as
asMA
MAfor
forPRs
PRsand
andPOs
POs

Set up validation class for PRs

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 131
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

263

Related OBJECT is
COMPANIES

List of
Vendors

264

This list should only contain


vendors e.g. Type V
From Massachusetts

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 132
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

265
Exercise 16 Hints:

override
hasList Extend validation
getList on Vendor field
validate
Condition
Company must not be disabled e.g. disabled is ‘N’
The state must be “MA” (field address3)
The type must be vendor “V”
Use SqlFormat for the
Use SqlFormat towhere clause
build the where clause

266

getMboSet(String where)

MAXTableDomain getMboSet(String)

getMboSet(“COMPANIES”); Warning

Uses a where clause:

COMPANIES

ERROR: Invalid where clause

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 133
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

267

Exercise 16 Override getList() Hints:

Returns the MboSetRemote


getList() to be displayed

Build the where clause using SqlFormat class

Get the MboSet using getMboSet(…) method

Return the MboSet

268
Why do we need to implement validate() method?

There are three ways to set the vendor field in the PR

Two ways Interactively

Selecting a Company from the list


Typing the name of the Company
Typing a non existing company
Typing an existing company
that is not in the list
One way remotely
Set the field Vendor in A PR Mbo in
a remote program

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 134
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

269

Exercise 16 Override validate() Hints:

Check that it is vendor from


validate() Massachusetts

Build the where clause using SqlFormat class

Get the MboSet using getMboSet(…) method

Check that there are records in the MboSet

Throw Exception if no records


Create your own message

270

Exercise 16 - Steps
Selectattribute
Select attributeto
tocustomize
customize

GenerateJava
Generate Javaand
andScript
Scriptfiles
filesin
inthe
the
custom/app/… directory
custom/app/… directory

Writebusiness
Write businesslogic
logic

Compileclass
Compile class

RunScripts
Run Scriptsto
toupdate
updateData
Datadictionary
dictionary

RestartMaximo
Restart Maximoand
andtest
test

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 135
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

271

Programming Note

Generate the java file with the generatefval.

The generated constructor needs


the RemoteException to be added.

public CustFldPurVendor(MboValue mbv)


throws MXException, RemoteException

Add
RemoteException

272

Testing the validate() method

Select a Company from the list

Type the name of the Company

It should accept “ATI”

Type a non existing company


Type an existing company that
is not in the list e.g “ACSN”
Was your message displayed in
both cases?
Why not?

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 136
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

273

Type invalid
Company

274

Maximo default
behavior is to take the
value as a search

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 137
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

275

Testing setValue from external

Go To Companies

Find company WES


Return Value
Exception because WES is not a Vendor

276

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 138
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

277

Student Exercise 17 - Item Mod

278

Customizing Mbo
Customizing Mbo
classes
classes

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 139
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

279

Reset ALL the Field Validation Classes

In order to avoid conflicts with the


Customized Field Validation Classes
for Exercises 13, 14, 15, 16

Run ALL the SQL scripts to restore original


validation classes
e.g. CustFldPurVendor-restore-orig.sql

280

Twocases:
Two cases:

Newrecords
New records
New Fields:
Change By, Modifiedrecords
Modified records
Change Date

Weneed
We needto
tokeep
keeptrack
trackof
ofwho
whochanges
changesananItem
Itemand
andthe
thedate
dateof
ofthe
the
change and display them on the screen.
change and display them on the screen.
Fieldsshould
Fields shouldbe
bedisplayed
displayedon
onthe
theItem
Itemscreen
screenand
andbe
beread-only.
read-only.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 140
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

281
Exercise 17 package custom.app.item

Hints:

Addtwo
Add twofields
fieldsto
totable
tableITEM.
ITEM.CUST_CHANGEBY
CUST_CHANGEBY
––same
sameasasPERSON.PERSONID
PERSON.PERSONID
CUST_CHANGEDATE--datetime
CUST_CHANGEDATE datetime

Do this in
Database
Configure App
ExtendITEM
Extend ITEMMbo
Mbo

282

GoTo/Configuration/Database Configuration

Select Object ITEM

Click on Attributes

Click on New

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 141
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

283

CUST_CHANGEBY

Same as
PERSON.PERSONID

Click on New

284

CUST_CHANGEDATE

Type DATETIME

Save Changes

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 142
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

285

Reconfigure Maximo

Shut down Maximo

At DOS prompt:

Run configdb.bat
from:
<Maximo root>\tools\maximo

286

Exercise 17- Screen changes

Using Application Designer

Add fields cust_changeby,


cust_changedate to the Item
screen

Save Changes

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 143
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

287

GoTo/Configuration/Application Designer
ITEM Application

Item tab

288

Control Palette

Select Textbox

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 144
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

289

Drag and drop two Textbox controls

290

Textbox Properties

Label: Changed by

Attribute:
CUST_CHANGEBY
Form object ITEM

Select Field

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 145
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

291

Textbox Properties

Label: Changed Date

Attribute:
CUST_CHANGEDATE
Form object ITEM

Select Field

292

Save Changes

Re-start Maximo to see the changes

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 146
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

293

Class Hierarchy for Exercise 17

e.g.
e.g.Extending
ExtendingItem
ItemMbo
Mbo Hints:

Classes Interfaces

ItemSet implements ItemSetRemote


inherits
CustItemSet implements CustItemSetRemote

Item implements ItemRemote


inherits
CustItem implements CustItemRemote

294
Exercise 17 Steps Hints:Use
generatembo
Generate custom files
CustItemSet.java
CustItemSetRemote.java
Customize
CustItem.java
init()
CustItemRemote.java
add()
CustItem-register.sql modify()
CustItem…sql Scripts

CustItem_rmic file

Run sql scripts to register

build project
test
run rmic (Run Ant. Select names)

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 147
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

295
Exercise 17 Hints: Generating the
template for your Mbo
classes
generatembo
generatembo p1
p1p2
p2p3
p3p4
p4

where
where
p1
p1––MXES
MXESroot
rootdirectory
directory
e.g.
e.g.c:\mxes
c:\mxes
P2
P2--Object
Objectname
name e.g.
e.g.Companies
Companies
p3
p3 - Customization rootdirectory
- Customization root directory
e.g.
e.g.c:\mxes-customization
c:\mxes-customization
P4
P4 - customobject
- custom object e.g.
e.g.
custom.app.company.CustCompany
custom.app.company.CustCompany

It will find the class to extend

296
Hints: Generating the
Exercise 17
template for your new
Item class
generatembo p1 p2 p3 p4
generatembo p1 p2 p3 p4

C:\mxes-generate>
C:\mxes-generate>generatembo
generatemboc:\mxes
c:\mxesITEM
ITEM
C:\mxes-Customization
C:\mxes-Customizationcustom.app.item.CustItem
custom.app.item.CustItem

C:\mxes
C:\mxes --MAXIMO
MAXIMOroot
rootdirectory
directory
ITEM
ITEM --MAXIMO
MAXIMOObject
Objectname
name
C:\MXES-Customization
C:\MXES-Customization––Customization
Customizationdirectory
directory
custom.app.item.CustItem
custom.app.item.CustItem––Customized
Customizedclass
class

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 148
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

297
Exercise 17 Hints: Generating the template
for your new Company class

C:\mxes-generate>
C:\mxes-generate>generatembo
generatemboc:\mxes
c:\mxesITEM
ITEM
C:\mxes-Customization custom.app.item.CustItem
C:\mxes-Customization custom.app.item.CustItem

The following files are created in directory


C:\MXES-Customization\custom\app\item

CustItem-register.sql
CustItem.java CustItem-restore-orig.sql
CustItemRemote.java CustItem-rmic.xml
CustItemSet.java CustItem-message-register.sql
CustItemSetRemote.java CustItem-message-delete.sql

298

Twocases:
Two cases:

Newrecords
New records
New Fields:
Change By, Modifiedrecords
Modified records
Change Date

Weneed
We needto
tokeep
keeptrack
trackof
ofwho
whochanges
changesananItem
Itemand
andthe
thedate
dateof
ofthe
the
change and display them on the screen.
change and display them on the screen.
Fieldsshould
Fields shouldbe
bedisplayed
displayedon
onthe
theItem
Itemscreen
screenand
andbe
beread-only.
read-only.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 149
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

299

Exercise 17 package custom.app.item

Hints:

init()

Set CUST_CHANGEBY as read-only

Set CUST_CHANGEDATE as read-only

add() Set CUST_CHANGEBY to Username

modify() Set CUST_CHANGEDATE to Current date

300

Exercise 17 package custom.app.item

Hints:

To get current date:


MXServer.getMXServer().getDate()

To get User Name:


getUserName()

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 150
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

301

Running rmic in Eclipse


2-Select Run Menu

3-Select External Tools


4-Select External Tools…

1- Select the generated rmic XML.


CustItem-rmic.xml

302

Running rmic in Eclipse

2-Click on New button

1-Select Ant Build

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 151
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

303

Running rmic in Eclipse

1-Nane should point


to CustItem-rmic.xml

2-Click on Browse Workspace

304

Running rmic in Eclipse

1-Expand Current
Project MXES-Custom

2-Select the linked


directory MXES-Classes
The output of the rmic compilation
3- Click on OK goes to this directory

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 152
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

305

Running rmic in Eclipse

2-Click on Build tab

1-Type –debug in Arguments

306

Running rmic in Eclipse

3-Click on JRE

1-Select The project containing…

2-Click on Apply

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 153
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

307

Running rmic in Eclipse

1-Select Run in the same JRE as the


workspace

2-Click on Apply

3-Click on Run

308

Running rmic in Eclipse

2-Double click on
Console tab

1-Output goes to the


Console

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 154
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

309

1-rmic compiled 2 classes

2-rmic compile list:


CustItem and CustItemSet

310

Running rmic

Follow documentation

eclipse3.2-setup\
MXMbo-Customization-setup\
MXCustom-rmic-eclipse3.2.doc

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 155
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

311

Reset ALL the Field Validation Classes

In order to avoid conflicts with the


Customized Field Validation Classes
for Exercises 13, 14, 15, 16

Run ALL the SQL scripts to restore original


validation classes
e.g. CustFldPurVendor-restore-orig.sql

312

Exercise 17 Steps
Add fields using Database Configuration

Add fields to screen with Application Designer

Generate the custom class for Item

Implement Customization

Build Project

Run rmic

Test

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 156
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

313

Student Exercise 17 A - Item Lottype

314

Exercise 17 a

After save,
After save, do
do not
not allow
allow to
to change
change the
the
field:
field:
LotType
LotType

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 157
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

315

Exercise 17a ITEM Object

Customize the
Customize the same
same Object
Object as
as in
in
Exercise 17.
Exercise 17. (ITEM)
(ITEM)

316

Exercise 17 a package custom.app.item

Hints:

What method?

After save,
After save, do
do not
not allow
allow to
to change
change the
the
field:
field:
LotType
LotType
Check if record is new
and it is going to be
saved in database.

toBeAdded()

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 158
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

317

Student Exercise 18 - Workorder Status

318
Exercise 18 package custom.app.wo

For Workorder
For Workorder

Do not
Do not allow
allow aa Workorder
Workorder to to be be approved
approved
ifif the
the GLAccount
GLAccount is is null
null or
or itit is
is not
not fully
fully
specified i.e.
specified i.e. itit is
is incomplete.
incomplete.

Display message:
Display message:
Invalid GL
Invalid GL Account
Account for
for wo:
wo: xxxx.
xxxx.
Please enter
Please enter aa full
full GL
GL Account.
Account.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 159
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

319

6500-300-???
GL is
incomplete Cannot
Approve

320

Exercise 18

Error message when


trying to Approve

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 160
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

321

Exercise 18 Fixing the GLAccount

2-Incomplete
segment
has ???

1-Click on
the
GLAccount
Icon
3-Click on a
value for
segment e.g. 4-Click OK
200

322

Exercise 18

Now the GLAccount is


complete and the WO can be
Approved

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 161
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

323

Exercise 18

The triggering event is the approval of a workorder

Method to override

canChangeStatus(…)

OR

changeStatus(…)

324

Exercise 18

Method to override The super in


canCangeStatus
throws Exception with
canChangeStatus(…) a generic error and not
with your error
message
OR

To show a custom
changeStatus(…) error message you
must override
changeStatus(…)

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 162
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

325
Exercise 18 package custom.app.wo

Hints:
For Workorder
For Workorder
Extend WO Mbo
Override:
changeStatus(…) method

Donot
Do notallow
allowaaWorkorder
Workorderto tobe
beapproved
approvedififthe
the
GLAccountis
GLAccount isnull
nullor
orititis
isnot
notfully
fullyspecified
specifiedi.e.
i.e.
it is incomplete.
it is incomplete.
Get Internal status,
Check if changing to APPR
Check if glAccount is complete.

326

Programming Note

If there are several overloaded


methods you should override the
one with the most number of
parameters

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 163
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

327

Extending WO

Using Eclipse to override a


method in a superclass

328

1- Click on Source

2- Override/Implement

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 164
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

329

All the methods that


can be overridden

330

Several
overloaded
changeStatus
methods

We want to override
the one with the most
parameters

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 165
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

331

1-Select the one with


most parameters

2-Click OK

332

Generated code

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 166
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

333

The only argument we


are interested in is
changeStatus signature newStatus

changeStatus(String newStatus,
Date date,
String memo,
long accessModifier,
boolean comingFromReceive)
See Javadocs for arguments

334

We need to rename the argument to have a meaningful name

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 167
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

335

2-Menu Refactor/rename

1-Select arg0

Rename first argument arg0 to newStatus

336

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 168
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

337

1-Type newStatus

2- Click OK

338

Changed arg0 to
newStatus
everywhere
Now the customization can be implemented

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 169
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

339

Implementation Decision

Should the call to super


super.changeStatus(…)
be done before or after your custom code?

340

Exercise 18 Steps package custom.app.wo


Generate the custom class for WO
Object Name: WORKORDER classname: CustWO

Implement changeStatus(..)

Build Project

Run rmic

Register Custom class and message

Test

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 170
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

341

Student Exercise 19 - Company Contacts

342

Exercise 19

Add the following fields and reconfigure

Addfield
Add field“NUMCONTACT”
“NUMCONTACT”type
typeINTEGER
INTEGER
toCOMPANIES
to COMPANIES

Addfield
Add field“PARENTCO”
“PARENTCO”to tothe
theCompContact
CompContact
Object with sameas COMPANY
Object with sameas COMPANY in inthe
the
COMPANIESobject
COMPANIES object

Reconfigure.Run
Reconfigure. Runconfigdb
configdbfrom
fromDOS
DOS

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 171
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

343

Exercise 19
Add NUMCONTACT field to Company Contacts tab

Contacts

344

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 172
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

345
Exercise 19
package custom.app.contacts

For Company
For Company

Keep the
Keep the counter
counter ofof how
how many
many contacts
contacts
in aa company
in company inin field
field NUMCONTACT.
NUMCONTACT.
Make the
Make the field
field Read-only
Read-only init()

346

Exercise 19 package custom.app.contacts


Hints:
Company tables Counter number of
ID contacts

COMPANIES COMPANY NUMCONTACT

COMPANY

COMPCONTACT COMPANY

COMPANY

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 173
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

347

Exercise 19 Objects

COMPANIES Owner of CompContact Set

Relationship

COMPCONTACT
COMPCONTACT
COMPCONTACT

348
Exercise 19 package custom.app.contacts

companyfield
company fieldNUMCONTACT
NUMCONTACThas
hascounter
counterof
ofContacts
Contacts
Hints:
FindMbo
Find Mbofor
forCOMPCONTACT
COMPCONTACTtable
table

Twocases:
Two cases: Triggeringevents
Triggering events

AAnew
newcompany
companycontact
contactisiscreated
created add()

delete(…)
AAcompany
companycontact
contactisisdeleted
deleted
undelete(…)

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 174
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

349

Tab Contacts

Click on
new row
Adding contacts to Companies

350

Click on delete

Deleting contacts from Company

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 175
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

351

Click on un-delete

UnDeleting contacts from Company

352
Class Hierarchy for Mbos

Each
EachMboSet
MboSethas
hasaareference
referencename
namee.g
e.gWORKORDER.
WORKORDER.

Table name
Classes Interfaces

MboSet implements MboSetRemote


Set
inherits
implements
WOSet WOSetRemote

Mbo implements MboRemote


Mbo
inherits
implements
WO WORemote

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 176
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

353
Class Hierarchy for Customized Workorder

e.g. Extending Workorder Mbos

Classes Interfaces

WOSet implements WOSetRemote


Set
inherits
implements
CustWOSet CustWOSetRemote

WO implements WORemote
Mbo
inherits
implements
CustWO CustWORemote

354
Short Class Hierarchy for Customized Workorder

e.g. Extending Workorder Mbos


Classes Interfaces

WOSet implements WOSetRemote


Set
inherits

CustWOSet If we are not adding new remote methods


No need to have a CustWOSetRemote

WO implements WORemote
Mbo
inherits

CustWO No Custom Remote Classes. No rmic

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 177
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

355
Exercise 19 Hints: Generating the SHORT
template for your Mbo classes

generatemboshort
generatemboshort p1
p1p2
p2p3
p3p4
p4

where
where
p1
p1––MXES
MXESroot
rootdirectory
directory
e.g.
e.g.c:\mxes
c:\mxes
P2
P2--Object
Objectname
name e.g.
e.g.Companies
Companies
p3
p3 - Customization rootdirectory
- Customization root directory
e.g.
e.g.c:\mxes-customization
c:\mxes-customization
P4
P4 - customobject
- custom object e.g.
e.g.
custom.app.company.CustCompany
custom.app.company.CustCompany

It will find the class to extend

356
Exercise 19 Hints: Generating the template
for your new CompContact class
generatemboshort
generatemboshort p1
p1p2
p2p3
p3p4
p4

C:\mxes-generate>
C:\mxes-generate>generatemboshort
generatemboshortc:\mxes
c:\mxes
COMPCONTACT
COMPCONTACT
C:\mxes-Customization
C:\mxes-Customization
custom.app.contacts.CustCompContact
custom.app.contacts.CustCompContact
C:\mxes
C:\mxes --MAXIMO
MAXIMOroot
rootdirectory
directory
ITEM
ITEM --MAXIMO
MAXIMOObject
Objectname
name
C:\MXES-Customization
C:\MXES-Customization––Customization
Customizationdirectory
directory
custom.app.contacts.CustCompContact
custom.app.contacts.CustCompContact––
Customized
Customizedclass
class

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 178
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

357
Exercise 19 Hints: Generating the template for
your new CompContact class
C:\mxes-generate>
C:\mxes-generate>generatemboshort
generatemboshortc:\mxes
c:\mxes
COMPCONTACT C:\mxes-Customization
COMPCONTACT C:\mxes-Customization
custom.app.contacts.CustCompContact
custom.app.contacts.CustCompContact

The following files are created in directory


C:\MXES-Customization\custom\app\contacts

CustCompContact-register.sql
CustCompContact.java CustCompContact-restore-orig.sql

CustCompContactSet.java CustCompContact-message-register.sql
CustCompContact-message-delete.sql

358

Exercise 19 Steps

Generate the short version custom class for


COMPCONTACT

Implement add(), delete(…)

Build Project

Run rmic No need to do rmic

Test

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 179
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

359

360

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 180
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

361

Student Exercise 20 - Parent Company

362
Exercise 20
package custom.app.company

For Contacts
For Contacts

Set up
Set up the
the field
field PARENTCO
PARENTCO in in
CompContact in
CompContact in all
all contacts
contacts for
for aa
company equals
company equals to to the
the parentcompany
parentcompany
field in
field in the
the Company
Company

Create a Hierarchy of companies


to test.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 181
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

363
Exercise 20 package custom.app.company

For Contacts
For Contacts

Add the
Add the PARENTCO
PARENTCO fieldfield to
to the
the screen
screen
Contacts tab
Contacts tab to
to be
be able
able to
to easily
easily see
see
your customization
your customization isis working.
working.

Create a Hierarchy of companies


to test.

364

Exercise 20 package custom.app.company


Company tables Hints:

COMPANIES COMPANY

Child COMPANY parentcompany

COMPANY PARENTCO

COMPCONTACT COMPANY PARENTCO

COMPANY PARENTCO

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 182
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

365

Exercise 20

The Mbo to Customize could be

Companies Mbo save()

OR

CompContact Mbo add()

366

Exercise 20 Extending CompContact

COMPANIES COMPANY parentcompany

A1-1 A1

COMPCONTACT COMPANY CONTACT PARENTCO

A1-1 N1 A1
New
A1-1 N2 A1

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 183
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

367

Exercise 20 Extending CompContact


COMPANIES COMPANY parentcompany

A1-1 A1

COMPCONTACT COMPANY CONTACT PARENTCO

A1-1 C1 null
Existing
A1-1 C2 null

New A1-1 N3 A1
Only New records are set with parentcompany value

368

Exercise 20 Extending Company


COMPANIES COMPANY parentcompany

A1-1 A1

COMPCONTACT COMPANY CONTACT CNT1

A1-1 C1 A1
Existing
A1-1 C2 A1

New A1-1 N3 A1
ALL records are updated at save()

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 184
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

369

Note on override Company save()

The save() method in the Companies Mbo is only


executed if the Company Mbo has changed

i.e. In the standard Company if Only a contact is


added and then save is executed the Company
save() is not executed because the Company Mbo
was not changed.

370

Transaction

Company
Save
CompContact

New Row

Only a contact is added. When save is executed the


Company save() is not executed because the Company
Mbo was not changed.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 185
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

371

Why override Company save() in this exercise

In Exercise 19 the CompContact Mbo was


customized to update Companies with the
counter of Contacts

Therefore, when a contact is added/deleted the


Company Mbo is modified and when the save is
executed it will also save the Company Mbo.

Notice that this works only because there is a


modification in a field in Companies

372
Exercise 20 package custom.app.company

Hints:
For Contacts
For Contacts

Extend Company Mbo


Override:
Set up
Set up the
the field
field PARENTCO
PARENTCO
save() in
in
CompContact in
CompContact in all
all contacts
contacts for
for aa
company equals
company equals toto the
the parentcompany
parentcompany
field in
field in the
the Company
Company
Loop for all contacts and
update PARENTCO field with
parentcompany from
Company

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 186
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

373

Exercise 20 Steps

Generate the short version custom class for COMPANIES

Implement save()

Build Project

Run rmic No need to do rmic

Test

374

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 187
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

375

376

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 188
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

377

Student Exercise 20 A - Old Records

378

Exercise 20 A

What about the


old existing
records?

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 189
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

379

Wrong Approach to fixing data

Update the database


using SQL scripts

No More SQL scripts

380
Exercise 20A package company.oldrecs

Create aa remote
Create remote program
program
UpdateCompOldRecs that
UpdateCompOldRecs that updates
updates
Companies and
Companies and CompContact
CompContact
Updates Companies
Updates Companies field
field
NUMCONTACT
NUMCONTACT
Updates CompContact
Updates CompContact field
field PARENTCO
PARENTCO

Use the Eclipse project MX-Remote

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 190
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

381
Exercise 20A package company.oldrecs

Hints:

Write Remote Program


Createaaremote
Create remoteprogram
programthat
thatupdates
updates
companies get
companieswith session
withcounter and
counterof connect
ofcontacts
contacts
Company
Company getfield
MboSet
field for COMPANIES
NUMCONTACT
NUMCONTACT
loop for all companies
Usethe
Use theEclipse updateMAX-Cust-Remote
Eclipseproject
project NUMCONTACT
MAX-Cust-Remote
loop for all contacts
update PARENTCO

382
Exercise 20A – Output when trying to run
java.rmi.UnmarshalException: error unmarshalling return;
nested exception is:
java.lang.ClassNotFoundException:
custom.app.company.solution20.CustCompanySet_Stub
(no security manager: RMI class loader disabled)

Reason
We have Customized the Company Mbo
The Eclipse project uses businessobjects.jar which has
the old Company object

We need to rebuild the ear file to include the custom


classes, and then extract the businessobjects.jar file

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 191
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

383
Exercise 20A Rebuilding ear file

Rebuild the
Rebuild the ear
ear file
file at
at
<Maximo>\deployment>buildmaximoear
<Maximo>\deployment>buildmaximoear

Extract businessobjects.jar
Extract businessobjects.jar file
file from
from
maximo.ear in
maximo.ear in <…>\deployment\defaults
<…>\deployment\defaults
Use WinZip

Refresh the
Refresh the project
project in
in Eclipse
Eclipse

Run the
Run the TestCompOldResc
TestCompOldResc program
program again
again

384

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 192
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

385

Student Exercise 21 - At least 2 Contacts

386
Exercise 21 package custom.app.company

AA company
company must
must have
have at
at least
least two
two
contacts with
contacts with different
different telephone
telephone
numbers which
numbers which are
are not
not null.
null.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 193
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

387
Exercise 21 package custom.app.company

AA company
company must
must have
have at
at least
least two
two
contacts with
contacts with different
different telephone
telephone
numbers
numbers which
Wewhich are not
must are notwhen
check null. the Company
null.
is being saved i.e.
appValidate()
or
save()

388
Exercise 21 package custom.app.company

Hints:

In the previously Extended Company Mbo


Override
appValidate()
AA company
company must have
must have at
at least
get Contacts
least two
two
contacts with
contacts with different
different telephone
Loop thru telephone
all numbers
contacts numbers
Check that at least two
with different NOT NULL
phone numbers
throw Exception if not

Create error message

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 194
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

389

Keeping track of phone numbers


Phone number is in field “voicephone”

Can use a String array to


keep track of phones

Can use a Java Container to


keep track of phones

Do not count phone numbers that are null

Must have two different NOT NULL phones

390

Testing
Contact Phone
C1 123
C2 123
Save Exception
Contact Phone
C1 123
C2 123
C3 null Save Exception
Contact Phone
C1 123
C2 123
C3 null
C4 456 Save OK

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 195
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

391

392

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 196
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

393

Student Exercise 22 - No Delete

394

Exercise 22 package custom.app.contacts

Do not
Do not allow
allow the
the deletion
deletion of
of aa contact
contact ifif
there will
there will be
be less
less that
that two
two left
left with
with
different NOT
different NOT NULL
NULL phone
phone numbers.
numbers.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 197
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

395
Exercise 22 package custom.app.contacts

Hints:

The triggering event is the deletion of a contact


Do not
Do not allow
allow the
the deletion
deletion of
of aa contact
contact ifif
there will
there will be
be less
less that
that two
two left.
left.
In the previously Extended
CompContact Mbo
Override
canDelete()

396
Exercise 22 package custom.app.contacts

Hints:

The record has not been deleted yet when canDelete()


is called.

Review the different options in count(…) method

Explained in first half of course

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 198
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Customizing Business Components in IBM Maximo 6 (Exercises)

397

Summary
You should now be able to:
• Customize Maximo Business Components.
– Use customizable methods.
• Init()
• Add()
• Delete()
• Save()
• Etc.
– Work with GL Accounts
– Work with change of status.

©Copyright IBM Corp. 2007 Customizing Business Components in IBM Maximo 6 (Exercises) 199
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

Student VMware Setup


Appendix A

Objectives
Upon completion of this unit, you will be able to:
• Use the Virtual Machine used in the training computers.

©Copyright IBM Corp. 2007 Student VMware Setup A-1


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

Real Machine

Login to Real Machine

student

EDSERVICES2005

©Copyright IBM Corp. 2007 Student VMware Setup A-2


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

Real Machine

Virtual
Machine

Real Machine

Double click
on the
Maximo6
Image

©Copyright IBM Corp. 2007 Student VMware Setup A-3


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

Click on Cancel

©Copyright IBM Corp. 2007 Student VMware Setup A-4


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

10

Must be
MXES Patch 3

©Copyright IBM Corp. 2007 Student VMware Setup A-5


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

11

If you do not see


the Start button
resize window

12

©Copyright IBM Corp. 2007 Student VMware Setup A-6


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

13

Directing the input

Ctrl G Directs input to Virtual Machine

Ctrl Alt Directs input to Real Machine

14

Shutting down

Start Menu: Shut Down…

OR

Ctrl – Alt - Insert Displays shut down dialog

©Copyright IBM Corp. 2007 Student VMware Setup A-7


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

15

Shutting Down

Start Menu:
Shut Down…

Click OK

16

Shutting Down – Ctrl Alt Insert

Ctrl – Alt - Insert Displays shut down dialog

Click on
Shut Down

©Copyright IBM Corp. 2007 Student VMware Setup A-8


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

17

Shutting down

Never click on the


Never do a Ctrl Alt Delete x to shut down
window

You could lose all the work


done in the Virtual Machine

18

Recovery if by Accident VM was closed

Start Virtual Machine

Do NOT do anything but just Shut VM properly.

Shut down the real Machine.

Start everything.

©Copyright IBM Corp. 2007 Student VMware Setup A-9


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

19

Start Eclipse

Start Maximo 6

Start Maximo 6 DEBUG

Command window

20

Copying between Real machine and VM

Only Drag and Drop is


supported

©Copyright IBM Corp. 2007 Student VMware Setup A-10


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Student VMware Setup

21

Summary
You should now be able to:
• Use the Virtual Machine used in the training computers.

©Copyright IBM Corp. 2007 Student VMware Setup A-11


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

Eclipse 3.2 Basics


Appendix B

Agenda

Eclipse 3.2

Creating class

Editing class

Copying files

Renaming files

Moving files

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-1


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

1-Drop down New list

2-Create Project

Creating a Simple Java Project.

Notice that creating a Maximo 6 Customization project


requires more steps.
See Documentation for Eclipse 3.2

1-Java Project

2-Click Next

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-2


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

1-Project Name

2-Create Project in
existing directory

3-Browse for
directory

4- Click Next

Output of compilation goes


to this directory

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-3


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

Libraries used.
In this case JDK 1.4.2

Project Created

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-4


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

Drop down New list

Create Class

10

2-When creating a class


the package can be
created at the same time

1-Class Name

3-Can create a
main to be able
to execute the
class

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-5


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

11

Package test was created

Package statement

Main method

File TestJava.java was created

12

Double-clicking on the tab


makes it full screen

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-6


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

13

Code Completion

Typing System. The dot causes the


display

Code completion help

Select the option you


need by double clicking

14

2-Double-clicking on tab to goes


back to the package explorer view

1-Write statement with error

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-7


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

15

Building the Project

1-Right mouse click on Project name

2-Click on Build Project

Build compiles ALL the classes


that have been modified

16

A red mark indicates an


statement with error

Problems tab displays the


errors/warnings from
compilation

Error description

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-8


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

17

Passing the mouse on the


red mark displays error

18

1-Correct error

2-Re-build project

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-9


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

19

0 errors

20

type if(i == 5)

“i” variable has not


been defined yet

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-10


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

21

Error
i cannot be resolrved

22

1-Right-mouse click on red mark

2-Select Quick Fix

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-11


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

23

Eclipse gives options


to fix the problem

Create local variable i

Shows the effect of


selecting this option

24

Eclipse added the


definition of variable i

The red mark indicates there


is another problem

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-12


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

25

Error: The variable I may not


have been initialized

26

1-Right-mouse click on red mark


And select Quick Fix

2-click on option to
initialize variable to 0

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-13


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

27

Eclipse added
initialization of “i”

28

Formatting

Code is not indented


properly

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-14


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

29

1- Right-mouse click
anywhere

3-Select Format

2-Select Source

30

Eclipse formatted the


code

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-15


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

31

Create New Class

1-Click on New Icon

Select Class

32

2-When creating a class


the package can be
created at the same time
Show.basic.one

1-Class Name

3-Can create a
main to be able
to execute the
class

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-16


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

33

1-Package show.basic.one was created

3-Package statement

4-Main method

2-File OneBasic.java created

34

Copying a file

1-Right-click on file

2-Select Copy

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-17


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

35

1-Select Package to copy to

2-Right-click

3-Select Paste

36

File OneBasic.java was copied


to package test

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-18


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

37

Renaming a file

1-Right-click on file

2-Select Refactor

3-Select Rename

38

Old name

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-19


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

39

1-New name

2-Finish

40

Warning from Eclipse

1-We are renaming a file with a main method and


therefore if this class is being executed from another
application the other application needs to be changed

2-Click on Finish

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-20


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

41

2-Class name was


changed to TwoBasic

1-File OneBasic.java was


remamed TwoBasic.java

42

Closing windows
1-Right-click on
the tab

Close closes the


active window
Close Others closes
all open windows
except the current
active one
Close All closes all
open windows

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-21


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

43

Close Others closed


all open windows
except this one

44

Coding help

1-Type File test = null;

“File” data type is not


recognized

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-22


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

45

“File” cannot be resolved

46

1-Right-click on red cross

2-Select Quick Fix

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-23


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

47

1-Options to fix
problem

3-Double-click 2-Eclipse found


on import the class File in
option the package
java.io

48

Eclipse inserted
the import
statement

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-24


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Eclipse 3.2 Basics

49

Re-build Project

1-Right-click on
project name

2-Select Build
Project

50

Yellow means Warning.


variable defined but not
used yet.

One warning

©Copyright IBM Corp. 2007 Eclipse 3.2 Basics B-25


Course materials may not be reproduced in whole or in part without the prior written permission of IBM.

You might also like