In this section: |
How to: |
With universal concatenation, you can retrieve data from unlike data sources in a single request; all data, regardless of source, appears to come from a single file. The MORE phrase can concatenate all types of data sources (such as, FOCUS, DB2, IMS, and VSAM), provided they share corresponding fields with the same format. You can use WHERE and IF selection tests in conjunction with MORE. For related information, see Selecting Records for Your Report.
To use MORE, you must divide your request into:
During retrieval, data is gathered from each data source in turn, then all data is sorted and the output formatted as specified in the main request.
The MORE phrase, which is accessible within the TABLE and MATCH commands, specifies how to concatenate data from sources with dissimilar Master Files.
{TABLE|MATCH} FILE file1main request MORE FILE file2 subrequest MORE FILE file3 subrequest MORE . . . {END|RUN}
where:
Begins the request that concatenates the data sources.
Is the name of the first data source.
Is a request, without END or RUN, that retrieves the first data source and defines the data fields, sorting criteria, and output format for all data. WHERE and IF criteria in the main request apply only to file1.
When concatenating files within the TABLE command, you can also define calculated values for the first data source.
Begins a subrequest. There is no limit to the number of subrequests, other than available memory.
Defines file2 as the second data source for concatenation.
Is a subrequest. Subrequests can only include WHERE and IF phrases.
Ends the request.
Both the EMPLOYEE and the EXPERSON data sources contain employee information. You can concatenate their common data into a single file:
The following annotated request concatenates the two data sources:
DEFINE FILE EXPERSON 1. EMP_ID/A9 = SSN; CURR_SAL/D12.2 = WAGE; END 2. TABLE FILE EMPLOYEE PRINT CURR_SAL BY EMP_ID 3. MORE FILE EXPERSON END
All fields referenced in the main request must either exist with the same names and formats in all the concatenated files, or be remapped to those names and formats using virtual fields. Referenced fields include those used in COMPUTE commands, headings, aggregation phrases, sort phrases, and the PRINT, LIST, SUM, COUNT, WRITE, or ADD commands.
A successful format match means that:
Usage Format Type |
Correspondence |
---|---|
A |
Format type and length must be equal. |
I, F, D |
Format type must be the same. |
P |
Format type and scale must be equal. |
DATE (new) |
Format information (type, length, components, and order) must always correspond. |
DATE (old) |
Edit options must be the same. |
DATE -TIME |
Format information (type, length, components, and order) must always correspond. |
Text (TX) fields and CLOB fields (if supported) cannot be concatenated.
The following annotated example concatenates data from the EMPDATA and SALHIST data sources.
DEFINE FILE EMPDATA 1. NEWID/A11=EDIT (ID,'999-99-9999'); END DEFINE FILE SALHIST 2. NEWID/A11=EDIT (ID,'999-99-9999'); CSAL/D12.2M=OLDSALARY; END 3. TABLE FILE EMPDATA HEADING "EMPLOYEE SALARIES" " " PRINT CSAL BY NEWID 4. WHERE CSAL GT 65000 5. MORE FILE SALHIST 6. WHERE OLDSALARY GT 65000 END
The output is:
EMPLOYEE SALARIES |
|
NEWID |
SALARY |
000-00-0030 |
$70,000.00 |
$70,000.00 |
|
000-00-0070 |
$83,000.00 |
$83,000.00 |
|
$79,100.00 |
|
000-00-0200 |
$115,000.00 |
$115,000.00 |
|
$102,500.00 |
|
$89,500.00 |
|
000-00-0230 |
$80,500.00 |
$80,500.00 |
|
$75,000.00 |
|
$70,800.00 |
|
000-00-0300 |
$79,000.00 |
$79,000.00 |
|
$75,000.00 |
|
$70,000.00 |
When you concatenate data, record sets are simply appended, not grouped or aggregated across files. Therefore, if duplicate sort fields exist, they show up twice in the report output.