Joins in SAP ABAP

In View, we need to join two tables; these two tables can have or cannot have Keys in common. In case of View we give Join Condition (e.g. table1-field1 = table2-field1) on basis of which records are merged. Joins in SAP ABAP can also be applied on two tables without a Join condition and in that case it will just give cross product of the two tables.

Definition

Joins in SAP ABAP are cross product of two tables which further uses Join Condition to produce desired output.

Join Condition: When the cross product of two tables doesn’t give desired result, then a condition is written which tells us how the tables are connected. A statement is written where fields of each table are written with table name and equality operator.

e.g. table1-field1 = table2-field1

 

Example:

If we have two table as shown below and we apply

  1. Join without any Join Condition

Joins in SAP ABAP without condition

2. Join with Condition

Joins in SAP ABAP with condition

Here the rows who don’t meet the condition are deleted.

 

 

Joins in SAP ABAP

Here the column which comes in right hand side of the Join Condition is also deleted.

 

 

Joins in SAP ABAP

This is the actual View as output.

*NOTE:  It is not necessary to compare two fields of different table to form a condition. A condition can also be like Table-Field1 = 1.

Types of Join

  1. Inner Join
  2. Outer Join

*Note:

  1. Pooled & Cluster tables cannot be joined via Join statement.
  2. In a single SELECT statement we must define at max 49 JOINS and specifying each table a namespace using AS.
  3. A WHERE condition applied with JOIN statements are actually applied on the results of the JOIN statements.
  4. If same column name appears in multiple tables, then its source is specified using column selector i.e. (~).
  5. JOIN expressions bypass BUFFERING. We can access table buffer by using FOR ALL ENTRIES.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Translate »