Example: A bank wants to join three separate files to produce a report that shows recent transactions by customers, sorted by outstanding balance. The final report shows transaction information from a transaction file, customer name and address data from a master file containing basic customer information, and the outstanding balance from a third file containing such information. The record layout for the transaction file is contained below in the figure Input Record Layout for First File.
The master file record layout is shown in the figure Input Record Layout for Second File.
These two files can be joined on the transaction customer number from the first file and the master customer number from the second file. These numbers are in zoned decimal (ZD) format, but because all of the zones are the same in every record, these fields can be used as character data for the join function.
The figure JCL and Required Control Statements contains the JCL and control statements to join these two files.
Next, a third file containing outstanding balances is added.
To do that, the following is coded.
The output from the first step: