The EXCHANGE LIST is the preferred way of passing information from function to function within LANSA applications. Only ever use PARAMETERS to pass information from RPGIII or CL into LANSA applications.
When a new application system is being defined, it is useful to identify any information which should always be available to be exchanged by every program within the application. This can save having to make later complex amendments to program suites, AND will often improve application performance by saving repetitive logic in many different programs.
Let's take an example of information falling into this category within an application suite - a general ledger system. During the design phase of this system the analyst or designer would fairly quickly identify that:
The best way to achieve these aims is to define a "global" exchange list as in the example below. Such a list should be included into all programs which are part of the application system - whether these programs appear to use the information or not.
EXCHANGE FIELDS(#COMPNOUSE #COMPDSUSE #ACCNOUSE)
Some points to note about this command are:
The use of work fields is done for one reason only. To prevent an RDML function that is FETCHing or SELECTing data from the database (i.e., fields named #COMPNO, #COMPDS and #ACCNO) from inadvertently overwriting the global exchange values with something that may well be rubbish. The three 'USE' versions of the fields would all be defined in the data dictionary.
For instance, the following sample GROUP_BY (used for screens layouts) and DEF_HEAD (used for report layouts) commands might be included into a template:
GROUP_BY NAME(#XXXXXXXXX) FIELDS((#COMPNOUSE *L3 *P2 *LABEL) +
(#COMPDSUSE *L3 *P20 *NOID))
DEF_HEAD NAME(#XXXXXXXXX) FIELDS((#COMPNOUSE *L1 *P1 *LABEL) +
(#COMPDSUSE *L1 *P20 *NOID)(#TIMEDATE *L2 *P1 *LABEL) +
(#JOB *L2 *P20 *LABEL)(#USER *L2 *P45 *NOID) +
(#JOBNBR *L2 *P52 *NOID))