Skip to Content

Introduction:

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:

  1. Assign the source’s “record” count value to the “recCount” element of every row in the target.
  2. Concatenate the source’s “lastName” and “firstName” to the target’s “fullName”.

image

Create 2 graphical variables:

  1. Right-click on the root node (target_MT) and select “Add Variable”.

    image

  2. Name the variable “varNoOfRec”.

    image

  3. Create another variable, “varFullName”, for the target’s node “rows”, by right-clicking on “rows” and select “Add Variable”.

    image

Assign values to the 2 graphical variables:

  1. Double-click on the variable “varNoOfRec” and assign the following mapping.

    image

    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.

  2. Double-click on the variable “varFullName” and assign the following mapping.

    image

    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:

  1. Double-click on “recCount” and drag-n-drop (do not double-click) the variable “varNoOfRec” to the mapping area and assign the following mapping.

    image

  2. Double-click on “fullName” and drag-n-drop (do not double-click) the variable “varFullName” to the mapping area and assign the following mapping.

    image

  3. 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.

image

To report this post you need to login first.

16 Comments

You must be Logged on to comment or reply to a post.

    1. William Li Post author
      Hi,
      All functions in message mapping can be used to map to the graphical variable.  Treat the variable just as another target element.

      Regards,
      Bill

      (0) 
        1. William Li Post author
          Hi,
          The value of the variable is calculated each time when its parent node changes.  Not sure if you can reset that value within the recordset. 

          As for getting the last value, you might be able to create a variable at the root level and map it with an UDF to get the last recordset.

          Regards,
          Bill

          (0) 
  1. Dijesh Tanna
    This functionality is very useful and was missing in SAP XI initial version. Other mapping tools like Mercator and all have this functionality for long..and it’s very handy..
    (0) 
  2. Gaurav Jain
    Hi,

    Blog is relally helpful.

    I have tried implementing it in one of my complex mapping. Whenever variable has single value in it, its working fine.
    But when the variable is array or its queue shows multple items, if i use if it gives an error message.

    Is it like it only able to handle single value?

    Gaurav Jain

    (0) 
    1. William Li Post author
      Hi,
      Yes, it can handle only 1 value.

      When the variable is added, the occurances is (0..1).  There is no way to change it.

      Regards,
      Bill

      (0) 
  3. Christoph Gerber
    Hello,

    nice blog. But I don’t think that this feature is so important. With XI 3.0 / 7.0 you can use simple UDFs implementing global variables. This new variable feature can just handle single values, is quite unhandy (the name of the variable cannot be changed definded dynamically) and makes the graphical flow even more complex (by addding graphical variables to target structure).

    BTW: I think you mismatched “source” and “target” in somce cases, for example: “This variable “varFullName” will be executed for each occurence of “record” in the target.” I think you meant “source” as “record” is s source elemnt?

    CHRIS

    (0) 
  4. Damien O'Dowd
    This is a nice feature but at runtime the values from a variable are not displayed when you take the option – “Display queue” from the definition tab on the message mapping. This is not helpful when debugging. As per the example below, if you were to right click on the lastname in the dest dtructure tou would not be able to see the queue of values.
    (0) 
  5. Farooq Farooqui
    Hi,

    Thank you for you post.

    Why we cannot assign any variable type? I believe the default type is “xsd:string”.

    If the target field type is numeric, than variable require conversion in every mapping step?

    Regards,
    Farooq Farooqui

    (0) 
  6. Aarthi Vijayaraghavan
    Hi William,
    It was a nice blog.

    I tried to use the same in one of my mapping. (in place of UseOneAsMany, i.e to replicate the header information in all line items ). When i tried to add more than 2 variables, I m getting Java Heap space error. and while trying to save it, i m getting NullPOinter Exception.

    (0) 
  7. raj t
    Hi Bill,

    This is really useful blog .. But can we keep on increasing varCount on target depending on the source items dynamically ..
    I mean to say if there are 3 items coming from source .. I need to get 1,2,3 as varCounts in each of target field ..

    (0) 

Leave a Reply