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.
DECLARE rInputAddress REFERENCE TO InputRoot.DFDL.Invoice.Customer.Address;
DECLARE rOutputCustomer REFERENCE TO OutputRoot.DFDL.Invoice.Customer;
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.
DECLARE rProduct REFERENCE TO InputRoot.DFDL.Invoice.Product;
WHILE LASTMOVE(rProduct) DO
…some logic
MOVE rProduct NEXTSIBLING NAME 'Product';
END WHILE;