Maximo scripting with Python built-in data structure.
A comprehensive way to use the Python list data structure to get and set values for multiple attributes.
Hi folks, I am Vivek, an IBM Maximo developer. I just started to share Maximo's knowledge. Whatever I learn and whatever I have, I will encourage your support.
In this post, I would like to share how we can use the Python built-in list data type to get the values from the mbo/mboset and set them in attributes when we were dealing with multiple values, so to avoid calling mbo.getSrting() and mbo.setValue() multiple times, which is increasing the line of code as well and gives trouble while debugging when we see the length of code.
Python List:
Python list data type is one of the most commonly used data structures in Python programming. A list in Python is an ordered collection of items. in sorted or in ordered manner.
Key Features of Python Lists
Ordered: Elements in a list have a defined order, and that order will not change unless explicitly modified.
Mutable: You can change the content of a list after it has been created. This includes adding, removing, or modifying elements.
Heterogeneous: A list can contain elements of different types, including other lists, creating nested lists.
Problems Statement: get the value of multiple value and store it in single variable insted of creating multiple variable and then set that value to other attribute of mbo by calling mbo.setValue() function in a single time.
To achieve the above problem statement, we can use the python data structure like List since it is mutable, so we will be able to add or append n numbers of values to the list data structure, which dynamically increases its size using dynamic memory allocation in the backend. and will use the iterative statement like the for loop, which will traverse through the list using the indexing feature, so that it will fetch the value from the list and set it in the mbo attributes in an orderly manner.
For this we gonna use 3 list 2 for loops and in-built function of list for validation and operation as follow.