Preprocessor Variables

You can define and reference variable names on the fly by bracketing them by percent signs.

These “preprocessor variables” differ from regular variables in these ways:

For example, if we have a variable named “LocID” that contains a string corresponding to the Location ID (say 540) then the statement

InsertList %LocID% ShipLOC

becomes

InsertList 540 ShipLOC

Example

The % delimiters around PO1Count show that this is not the actual name, but a variable that will point to the name. The contents might be another variable, which might contain another variable and so on. At runtime, this chain is resolved as far as it goes.

These “indirect references” are resolved when the rule is run, not when it is encountered. However, the following exits resolve the variable when the rule that they contain runs, not when the exit itself is encountered:

Variable Delimiters

  Variable contains constant Variable contains another variable

Used in CustomerFSBRerrs.txt message

#

See example 1

cannot be used in external error file

Used in hard-coded message

%

See example 2

%

See example 3

Used in body of business rule

unless noted, no delimiters

See example 4

%

See examples 5 and 6

A number of examples are below. For two complex preprocessor variable examples involving maps, see page Variable Maps.

Example 1. This example used a regular variable, not a preprocessor variable. OrderNum is a variable containing a constant value.

32005    Order #OrderNum# received on #Current_Date#

Example 2. OrderNum is a variable containing a constant value. The error message is hard-coded into the business rule and contains two variables, which have to be surrounded by percent signs.

Example 3. While this example appears this same as Example 2, in this case the variable OrderNum contains a variable LastOrderNum which can contain a constant or another variable.

Example 4. OrderNum and MinNum are regular variables containing constants. They are not surrounded by any special characters in the body of the rule except in DisplayErrorByNumber.

Example 5. This example creates a list name on the fly. The rule is inserting the contents of LineItemAMT into the list (name to be determined by resolving the variable OrderID):

Assume:    OrderID     contains     20081025A10
    LineItemAMT     contains     72.50

The parameters above becomes:
20081025A10 72.50   (insert 72.50 into the list named 20081025A10)

Example 6. Nested variables.

Assume:    ABC     contains     %DEF%
    DEF    contains    %GHI%
    GHI    contains    JOHNSONJAKE

The parameters above becomes:

JOHNSONJAKE “1”
(Add 1 to variable JOHNSONJAKE)