Definition of a Table-Join without Graphics 

If several tables are all linked within a SELECT statement, this is known as a join. The result set is a table, each of the lines of which contains all the fields of all the tables used in the join. The links between the various tables used in the join are all specified separately. These specify the exact combinations of records from the individual tables that become part of the result set.

The result of a table join is also a (flat) table! Therefore hierarchical relationships between tables cannot be analyzed using a table join. This requires logical databases.

More detailed information about table joins you should refer to the online documentation for the ABAP SELECT statement.

If you want to allow the user of the query to run reports, you should create an InfoSet for which you enter the name of the first table in the join in the Table field on the Title, Database screen and select the Table join field.

The table must be entered in the ABAP Dictionary and must exist in the database.

For technical reasons the first table in a join cannot be changed later. Choosing Continue takes you to the Tables in the join screen. Other information needed for the table join can be entered here.

All the tables to be included in t he join are entered on the left- hand side of this screen. The type of link to be used between each pair of tables must be specified:

A record is included in the result set for each record in the first table for which a record in the second table exists satisfying the link conditions (see below).

Each record of the first table is included in the result set. If there is no record in the second table satisfying the link conditions for a record in the first table, then a record containing fields with initial values is used for the second table.

If you want to include a table in a join more than once, you have to use an alias table. Define an alias name for the appropriate table as described in Assigning Additional Tables. You can then include the table in your join under both its original name and its alias.

Link conditions must be defined between each pair of tables in the join. Two steps are needed to do this. If just two tables are being linked in a join, then the first step is simply to call the Define condition function. The two tables will then appear on the right hand side of the screen in a list of table pairs. If more than two tables are being linked together in a join, then two tables should be selected before the Define condition function is called. Then when the function is called these two selected tables will appear on the right hand side of the screen in the list of table pairs.

The Define condition function simply determines the tables between which link conditions are to be defined. The second step is to specify each individual condition.

A link condition is specified by calling the Specify condition function. This function can be called for each table pair using the pushbutton on the screen to the right of the table pair. When the function is called another screen appears in which the link conditions for this table pair are specified. Although any conditions are possible in a table join, the query supports only the case that two fields from the two tables each have the same value (equality relationship).

The first time that the Specify condition function is called for a table pair, defaults can be defined for the condition. A suggested default is derived based on the foreign key dependencies stored in the Dictionary or on the key fields of the tables used in the join.

All fields contained in the two tables being used are listed with their technical name and long text in the Link conditions screen. The two field lists can be scrolled through independently of each other. If two fields are to be linked with the equality relationship, then the same code must be entered for both fields into an entry field assigned to both fields. This code consists of two arbitrary characters (though digits are recommended). This code is similar to the code used for field groups in that its purpose is simply to ensure a unique correspondence between fields.

There are certain restrictions in the database system, which mean that totally arbitrary combinations of fields cannot be linked together. Two fields can be linked only if both fields have the same data type in the Dictionary (including the length attribute). This means that two fields can be linked if they have the same domain. There are separate search functions for each table to assist in the search for suitable fields. Text, domains and data types can be searched for. The text search operates across the technical names of the fields as well as over the long texts. The Field documentation function can be used to find information about the technical definition of a field, so as to allow a specific search for suitable fields.

If the same code has been entered for two compatible fields, these two fields are placed in the same line (at the start of the field list) and the fact that they have been successfully linked is indicated by an equals sign. The relationship can be canceled by placing the cursor on one of two fields and calling the Remove relationship function, which is to be found on a pushbutton immediately above the equals sign.

When you have finished defining the link conditions for a table pair, you can return to the Tables in the join screen by using the Back function. When you have finished specifying all the link conditions that you have defined, you can use the Field groups function to enter the field group maintenance.

Here you have access to all the functionality that you can use for InfoSets via logical databases, e.g. inclusion of additional tables, definition of additional fields and definition of parameters and selection criteria. Please take note of the remarks made at the end of the Sequential Datasets section.

On the field group maintenance screen, all tables in the second sub-tree are arranged next to each other at the same level.

It is important to note an important difference to the logical databases: The table join results in a flat table and therefore does not permit an analysis of hierarchical relationships! For this reason additional tables, additional structures and additional fields are always connected to the first table of a join and the only code that exists is for record processing. However, all fields contained in the tables used in the join can be accessed in the WHERE conditions of connected additional tables or the code for additional fields, even through the connection is always made to the first table of the join.

The field group screen contains a Join function. This function can be used to call the table join maintenance again, so that changes may be made at any time to the definition of a join or of the link conditions. The only restrictions are that the first table of the join cannot be removed and that other tables can be removed from the join only if none of the fields of these tables are allocated to field groups.