The following example applies to the EXCHANGE command in general, not to the program M@EXCHL:
Consider 2 functions being used that are named FUNC1 and FUNC2 and have RDML programs that look like this:
Function: FUNC1
REQUEST (#FIELD01 #FIELD02)
INSERT FIELDS(#FIELD01 #FIELD02) TO_FILE(FILE01)
Function: FUNC2
REQUEST (#FIELD01 #FIELD02 #FIELD03 #FIELD04)
INSERT FIELDS(#FIELD01 #FIELD02 #FIELD03 #FIELD04) TO_FILE(FILE02)
If FUNC1 had the following command added to it (as the last command) and was recompiled:
EXCHANGE FIELDS(#FIELD01 #FIELD02)
then, if the user used function FUNC1, and then used function FUNC2, the fields #FIELD01 and #FIELD02 would come up on the FUNC2 REQUEST display "prefilled" with the values entered by the user in function FUNC1.
There is no need to re-compile FUNC2 to make this happen. Remember that the exchange list is searched whenever a function is invoked. As soon as fields #FIELD01 and #FIELD02 start to appear in the exchange list they will be "mapped" into function FUNC2.
If the exchange command described above was also added to FUNC2 and FUNC2 was re-compiled then the following will happen.
Whenever FUNC2 is invoked after FUNC1 then the #FIELD01 and #FIELD02 values on the FUNC2 REQUEST display will be pre-filled with the values entered by the user in FUNC1.
Whenever FUNC1 is invoked after FUNC2 then the #FIELD01 and #FIELD02 values on the FUNC1 REQUEST display will be pre-filled with the values entered by the user in FUNC2.
If FUNC1 is invoked repeatedly from the process menu then the #FIELD01 and #FIELD02 values will be pre-filled with the values entered during the previous invocation.
In other words FUNC1 is exchanging information with itself.
The first time that FUNC1 is invoked (assuming that FUNC2 has not been used already) the exchange list will be empty. In this case #FIELD01 and #FIELD02 will be pre-filled with the default values specified for them in the data dictionary or DEFINE command.