Graphical variable is a new feature in the Message Mapping tool of PI 7.1. Among many of the new features, I think this simple feature will probably be one of the most useful, if not the most used new feature in PI 7.1.
Graphical varaible will replace a lot of previously development effort for global variables. It makes the development process much easier and brings a lot of clarity on when a “global” value will be calculated.
This blog will go into the details on its advantages and usage.
Using Graphical Variable:
Let’s take a look at the following mapping requirement:
- Assign the source’s “record” count value to the “recCount” element of every row in the target.
- Concatenate the source’s “lastName” and “firstName” to the target’s “fullName”.
Create 2 graphical variables:
- Right-click on the root node (target_MT) and select “Add Variable”.
- Name the variable “varNoOfRec”.
- Create another variable, “varFullName”, for the target’s node “rows”, by right-clicking on “rows” and select “Add Variable”.
Assign values to the 2 graphical variables:
- Double-click on the variable “varNoOfRec” and assign the following mapping.
This variable “varNoOfRec” will be executed for each occurence of “target_MT”. In this case, it will be executed only once, since “target_MT” is the root.
- Double-click on the variable “varFullName” and assign the following mapping.
This variable “varFullName” will be executed for each occurence of “record” in the target.
NOTE: With where the variable is defined, it is clear as to when it will be executed and can be used.
Use the variables in mapping:
- Double-click on “recCount” and drag-n-drop (do not double-click) the variable “varNoOfRec” to the mapping area and assign the following mapping.
- Double-click on “fullName” and drag-n-drop (do not double-click) the variable “varFullName” to the mapping area and assign the following mapping.
- Assign something to the target’s “var2”, it is not important what. In this case, I just assigned it the element “data2” from the source. Also, we need to assign “record” to “rows” to complete the mapping.
Verifying the mapping:
Even though the mapping shown here is quite simple, but when there is a complex structure, using variables (especially, when they have to be re-used over-n-over again) can save a lot of development and processing time.
Below is the result of the mapping. The graphical variables are not sent to the target structure. The “recCount” value for each row is only calculate once during the mapping, not for every row. The “fullName”, however, is calculated for each row.