Information is exchanged between functions in an "exchange list". The format of the exchange list is something like this:
||N|T|L|D| V ||N|T|L|D| V | ....... |N|T|L|D| V ||where:
N |
is the name of a field |
T |
is the type of a field |
L |
is the length of a field |
D |
is the number of decimal positions |
V |
is the variable length value of the field |
Whenever a function is invoked the exchange list is searched. If a field is found in the exchange list with the same name as a field used in the function it is "mapped" into the function. After the search has been completed the exchange list is cleared, regardless of whether or not any fields were found in it and mapped into the function.
It can be seen that the exchange of information between functions is by name, not by position as with normal program parameters.
The "mapping" procedure mentioned above will automatically convert field types, lengths and decimal positions if the definition of the field in the exchange list is different from the definition of the field in the function.
The EXCHANGE command or the EXCHANGE parameter on the TRANSFER command are used to add a new entry into the EXCHANGE list.
The net length of the exchange list cannot exceed 2000 characters at any time or the EXCHANGE or TRANSFER command that is attempting to add information to the list will end abnormally.
When working with the function that receives the EXCHANGE information remember that the exchange of information takes place before the first RDML command in the function is executed.
If the EXCHANGE command or parameter does not appear to be working correctly it is probably because the first RDML command in the function sets the fields that have just been mapped from the exchange list to *DEFAULT or *NULL. This causes the EXCHANGE values to be lost / overwritten.