Preface – This post is part of the ABAP Beginner series.
Table of Contents
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
- Join without any Join Condition
2. Join with Condition
Here the rows who don’t meet the condition are deleted.
Here the column which comes in right hand side of the Join Condition is also deleted.
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
*Note:
- Pooled & Cluster tables cannot be joined via Join statement.
- In a single SELECT statement we must define at max 49 JOINS and specifying each table a namespace using AS.
- A WHERE condition applied with JOIN statements are actually applied on the results of the JOIN statements.
- If same column name appears in multiple tables, then its source is specified using column selector i.e. (~).
- JOIN expressions bypass BUFFERING. We can access table buffer by using FOR ALL ENTRIES.
0 Comments