The third article of this series showed where a variable lives: on the script, with an optional override on the launch point. This one is about the binding itself, which decides the value that the script sees and the record that receives a value back.
We checked IBM’s pages about variables against the behaviour of Manage in the MAS 9.2 series. Where the two disagree, this page follows Manage.
Four binding types#
Each variable has a binding type, and the type decides where the value comes from.
| Binding type | The binding value names | The script gets | Written back? |
|---|---|---|---|
| Attribute | a field, or a path to a field | the field’s value, in its own type | yes, for OUT and INOUT |
| MAXVAR | a system setting | text | never |
| System property | a system property | text | never |
| Literal | a fixed value | the value, in the literal type | never |
Three details are worth knowing before you choose one:
- A MAXVAR is read for the organization and the site of the record. Without a record, for example in a cron task script, the value is the system-level one.
- A literal is only a default. Manage sets it only when the run has no value of that name yet. When a calling script passes a value under the same name, the caller wins.
- A literal of type YORN arrives as text. The other literal types arrive as numbers or dates.
Only an attribute binding is written back. Declare MAXVAR, system property and literal variables as IN. Declared as OUT, they get no value at all.
The type a field arrives as#
A field binding hands the script a Java value, and its type follows the field type in the data dictionary:
| Field type | Arrives as |
|---|---|
| ALN, UPPER, LOWER, GL, LONGALN, CLOB | text |
| INTEGER, BIGINT | a long whole number |
| SMALLINT | a whole number |
| DECIMAL, AMOUNT, DURATION | a decimal number |
| FLOAT | a floating point number |
| DATE, DATETIME, TIME | a Java date |
| YORN | the number 1 or 0 |
| any field that is empty | None in Jython, null in JavaScript |
YORN is the trap. A yes/no field arrives as the number 1 or 0, so treat it as a number. Write back 1 or 0 as well. Manage has no branch for a true or false value when it writes a variable back, and the write fails.
There is one exception to the rule above. In an array binding, which ends with * (see below), a
YORN field arrives as true or false.
Paths across relationships#
An attribute binding can name a field of a related record. The path starts at the record of the launch point, follows relationships by name, and ends with a field:
POLINE.POCOST.QUANTITYThis reads the first PO line, its first cost line, and that line’s quantity. Two things happen quietly here:
- An empty relationship gives an empty value and no error. When the PO has no lines, the variable is empty, and the script cannot tell “no line” from “no quantity”.
- A write goes to the same related record. An INOUT variable with this path writes its new value to the first cost line of the first PO line.
The path always starts at the launch point record. IBM’s page describes it as starting with an
object name, which Manage does not accept. One prefix is missing from both IBM pages:
&owner&. starts the path at the owner of the record.
Arrays: the asterisk#
An asterisk after the field turns the binding into an array of values:
MATUSETRANS.LINECOST*On a work order, this gives the line cost of every material transaction, as a list of numbers. Arrays come with their own rules:
- An array is read-only. An OUT array variable fails, and nothing is written back from an array.
- No record means no list. With no related record at all, the variable is
Noneand not an empty list. Check for that first. - Records marked for delete are left out.
- Each array brings companion arrays for the flags, such as
matcosts_requiredandmatcosts_readonly, one entry per record.
A short Jython example that sums the material costs of a work order, with matcosts bound to
MATUSETRANS.LINECOST*:
total = 0.0
if matcosts is not None:
for cost in matcosts:
total += costIBM’s own example for this case adds to the total without setting it to 0 first, so it fails at the first addition.
Filters in brackets#
A pair of brackets after a relationship filters its records. There are three kinds of filter:
| Filter | Example | What it does |
|---|---|---|
| Index | POLINE[3] | picks one record, counting from 0, so this is the fourth line |
| Where clause | POLINE[linecost>100] | adds the clause to the relationship’s own where clause, and reads from the database |
| Condition | POCOST[cond:PERCENTCOND] | tests each record against a condition from the Conditional Expression Manager |
Filters combine along a path, and the last step can be an array:
Each filter has its trap:
- An index past the end fails.
POLINE[3]on a PO with two lines raises an error. Index 0 on an empty relationship gives an empty value, like a plain path. - A dot inside a filter breaks the path. Manage splits the path at every dot, so a clause such
as
[linecost>100.50]cannot work. Use whole numbers, or a condition. - No space after
cond:. Manage looks up the condition name with the space and finds none. IBM’s two examples for condition filters both have that space, and both fail as written. - A condition filter reads every record first. The test then runs on each record in memory, so a condition on a large relationship reads all of its records before it filters.
The three access flags#
An OUT or INOUT variable writes its value back with a call that can skip some of the field’s rules. The three check boxes on the Variables tab choose which:
| Check box | What Manage skips when it writes the value |
|---|---|
| Suppress Validation | the field’s validation |
| Suppress Action | the field’s action, the code that runs after a valid change |
| Suppress Access Control | the read-only check, so a read-only field can be changed |
Three rules apply to all three flags:
- They only matter for OUT and INOUT. For an IN variable the check boxes are read-only, and nothing is written.
- They apply only when the value changed. Manage compares the value with the one it read in, and writes only a different value.
- They do nothing after save or after commit, because nothing is written back there.
Suppress Access Control skips only the read-only check. Validation and action still run, unless their own check boxes are set too.
What IBM’s pages get wrong here#
| Topic | IBM’s pages | What Manage does |
|---|---|---|
| Suppress Action | decides whether the validate routine runs | skips the action routine |
| Suppress Access Control | decides whether action and validation run | skips only the read-only check |
| Condition filter example | [cond: PERCENTCOND] | fails because of the space; write [cond:PERCENTCOND] |
| Path format | starts with an object name | starts at the launch point record, or at its owner with &owner&. |
| Array example | adds to a total that was never set | set the total to 0 first |
Article 33 of this series collects the corrections that matter most.
What comes next#
This ends Part 1 of the series, the foundations. Part 2 starts with object launch points: every event, and where it fires.
IBM’s own pages are the reference to keep next to this series:
- Automation scripts in the IBM Maximo Manage documentation.
- All about Maximo scripting, IBM’s scripting guide on GitHub.
The complete list of corrections, with the evidence for each one, is in our member area. Members get access on request, so get in touch if you want it. If you want help with the scripts in your own Manage, our services page shows how we work.
IBM and Maximo are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide.
