Store data in variables

When combining and mapping data, you might want to use the same intermediate results more than one time. Your question then should be: must I compute the intermediate value repeatedly each time I need it? The DML language offers you a clipboard facility through objects called variables.

Variables act similar to storage bins. After created using Axway Mapping Services, you can fill your variables with data, and later retrieve them so you can put different data into that variable. Although variables can store only one piece of data at a time, you can reuse them over and over again to store different information. Their contents might vary from time to time, hence the name variable.

If you know that your expressions need to temporarily store data, you must first create enough variables to store them. This operation is done in the Axway Mapping Services where you define the name and the class of each of your variables. Variables that you define can be used in any DML expression.

You use DML to map data that the integration engine handles. This data is always structured in messages. Each time a new message comes to be processed, the value of each existing variable is restored to its initial contents. When you create a variable in Axway Mapping Services, you define an initialization expression that computes the initial content.

At any time, in any expression, you can alter the contents of a variable. This operation is called assignment. Assignment statements rely on the specific operator := . Here is an example of the assignment operation:

%avogadro_number := .60221415E24

The statement above stores the real number 6.0221415×1023 in a variable named avogadro_number. The leading percent % is the reserved character to introduce the names of variables. This assignment is only accepted if the class of the variable is R or S: in the former case a number is stored; in the later it is first converted into a string and then stored.

Any literal can be assigned to variable, provided that the classes are compatible:

%favorite_sentence := "the quick brown fox jumps over the lazy dog"
%mybirthday := '1964-05-29'
%days_in_year := 365
%concept_understood := true
%mms_in_inches := 2.54

Raw-data literals do not exist, so raw-data (V class) variables cannot be assigned in this way.

Assigning variables means altering their value, but how do you retrieve their contents? You simply use their name as part of an expression. The area of a circle is given by the formula: S = π • r2

To perform this calculation, you need three variables of R class: one to receive the area of the circle, one that contains the value of pi, and one for the circle radius. Mapping the expressions would be:

%pi :=3.1415926535;
%radius := 135;
%area := %pi * %radius * %radius

This expression sets the value of the variable area to 57255.5261116739.

Variables are visible from any expression you can write; their content is restored to the initial value only when a new message is captured by the integration engine server. Since their content is preserved from expression to expression, they offer an easy way to share information between the different components of your Maps:

A key parameter of the Map is shared  between the DML Blocks and the Validation Rules

This graphic shows how a key parameter of the Map is shared between the DML Blocks and the Validation Rules.

Related Links