IBM Integration Bus, Version 9.0.0.5 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS

See information about the latest product version

Using reference variables

Using reference variables can reduce overhead when traversing message trees. has two benefits: Firstly they make code more readable. Secondly, and more importantly, they reduce the overhead of repeatedly traversing the message tree each time a location in the tree structure is required to be accesses. This behavior applies to any message tree such as InputRoot or OutputRoot.

The following example demonstrates Reference declarations:
DECLARE rInputAddress REFERENCE TO InputRoot.DFDL.Invoice.Customer.Address;
DECLARE rOutputCustomer REFERENCE TO OutputRoot.DFDL.Invoice.Customer;
References can be used within references. So when you need to access multiple levels of a tree structure with code, create a reference for each level. The following example demonstrates multiple reference levels:
DECLARE rInputInvoice REFERENCE TO InputRoot.DFDL.Invoice.Customer.Address;
DECLARE rInputCustomer REFERENCE TO rInputInvoice.Customer.Address;
DECLARE rInputAddress REFERENCE TO rInputCustomer.Address;

References only maintain the scope of the code block that they are defined in. For example, if you defined a reference within an IF statement, then the Reference is only accessible within that IF block. Therefore, if you need to use the same reference in multiple code blocks, you must define the reference outside of any logical statements. References are often defined at the top of each Function or Procedure to add to the readability of the code.

References can be either static (defined to a fixed location) or dynamic. The definition for both is identical but the pointer within the reference can be moved.

In the following code sample, a reference is created to Product which can occur one or more times. The LASTMOVE instruction checks if the reference that is defined has found the tree location (Product of parent Invoice). The WHILE loop iterates through each Product found by moving the reference rProduct through each sibling element of name Product:
DECLARE rProduct REFERENCE TO InputRoot.DFDL.Invoice.Product;
WHILE LASTMOVE(rProduct) DO
   …some logic
   MOVE rProduct NEXTSIBLING NAME 'Product';
END WHILE;

bj60059_.htm | 
        
        Last updated:
        
        Last updated: 2016-08-12 11:20:24