The JOIN Command

With the JOIN command, you can link two or more Master Files together for reporting purposes. The connected Master Files are treated as one structure even though they remain physically separate. Master Files stay joined for the duration of your session or until you issue the JOIN CLEAR command.

You can join the Master Files describing any of these data sources to that of your IDMS data source:

A JOIN structure is implemented by matching one field that is common to both data sources. The fields on the IDMS target file can be:

The fields on the host file can be:

In the Master File, the names of common fields can differ, but their field formats (ACTUAL and USAGE) must be the same.


Top of page

Syntax: How to Join Two Data Sources

JOIN field1 [WITH rfield] IN hostfile [TAG tag1]
TO [ALL] field2 IN crfile [TAG tag2] [AS name]
[END]

where:

field1, field2
Are the fields common to both Master Files.

WITH rfield1
Use only if field1 is a virtual field; assigns a logical home with a real field in the host file.

hostfile
Is the host Master File.

TAG tag1
Is a tag name of up to eight characters (usually the name of the Master File), which is used as a unique qualifier for fields and aliases in the host file.

The tag name for the host file must be the same in all the JOIN commands of a joined structure.

ALL
Use if non-unique relationships exist in the target file.

crfile
Is the target or cross-referenced Master File.

TAG tag2
Is a tag name of up to eight characters (usually the name of the Master File), which is used as a unique qualifier for fields and aliases in the cross-referenced file. In a recursive joined structure, if no tag name is provided, all field names and aliases are prefixed with the first four characters of the join name.

AS name
Assigns a name to the JOIN structure. You must assign a unique name to a join structure if:

END
Required when the JOIN command is longer than one line; terminates the command.

To join more than two files as a single structure, indicate the common fields as follows:

JOIN field1 IN file1 TO field2 IN file2 AS name1
JOIN field3 IN file1 TO field4 IN file3 AS name2

Top of page

Reference: Usage Notes for the JOIN Command


Top of page

Syntax: How to List JOIN Structures

To list your JOIN structures, enter:

? JOIN

Top of page

Syntax: How to Clear JOIN Structures

To clear a specific JOIN structure, specify the name that you assigned to the join:

JOIN CLEAR name

Top of page

Syntax: How to Clear All JOIN Structures

To clear all structures, use an asterisk (*) instead of a join name:

JOIN CLEAR *

For more information about JOIN commands, refer to your FOCUS documentation.


Top of page

Example: Reporting From a Joined Structure

This example joins the FOCUS data source JOBFILE to the IDMS EMPFULL data source based on job codes. First the JOBCODE field in JOBFILE is edited to make it compatible with the JOB_ID field in EMPFULL. The JOIN command is issued prior to the DEFINE. If the DEFINE were issued first, it would be cleared by the JOIN command:

JOIN JOBID WITH JOBCODE IN JOBFILE TO                 
ALL JOB_ID IN EMPFULL AS J1
END
DEFINE FILE JOBFILE
JCODE/A2 = IF JOBCODE LIKE 'A__' THEN '10' ELSE '20';
JOBID/A4 = JCODE|EDIT(JOBCODE,'$99');
END
TABLE FILE JOBFILE
SUM EMP_NAME IN 25 TITLE
BY DEPT_NAME
END

The output is:

DEPT_NAME               EMP_NAME                   TITLE             
--------- -------- -----
ACCOUNTING AND PAYROLL RUPERT JENSON MGR ACCTNG/PAYROLL
PERSONNEL ELEANOR PEOPLES MGR PERSONNEL

Information Builders