33 Flares Twitter 0 Facebook 33 Google+ 0 LinkedIn 0 Email -- Pin It Share 0 33 Flares ×

Inner Joins:

Inner Joins are usually used for extracting data from more than one table where the tables are having foreign key relation.

Whenever we are working with the inner joins then no need to declare the types for each and every table. Only declare the final types

Inner join fetch the data based on ON condition first next is based on WHERE condition



Select <t1>~<f1> <t1>~<f2> <t1>~<f3>

<t2>~<f1> <t2>~<f2>

Into table <ITAB>

From <t1> Inner join <t2>

On <t1>~<f1> = <t2>~<f1>

Where <Condition>.

In above syntax t1 and t2 are the database table names.

F1,F2,F2 are field names.


SELECT mara~matnr mara~ersda
marc~matnr marc~werks
INTO TABLE lt_material
from mara NNER JOIN marc
on mara~matnr = marc~matnr
where mara~matnr in s_matnr.


Select < Alias name of DB1>~<f1> < Alias name of DB1 >~<f2> < Alias name of DB1 >~<f3>

< Alias name of DB 2>~<f1> < Alias name of DB 2>~<f2>

Into table <ITAB>

From <t1> AS < Alias name of DB 1>

Inner join <t2> as < Alias name of DB 2>

On < Alias name of DB1>~<f1> = < Alias name of DB 2>~<f1>

Where <Condition>.


SELECT a~matnr a~ersda
b~matnr b~werks
INTO TABLE lt_material
from mara as a
INNER JOIN marc as b
on a~matnr = b~matnr
where a~matnr in s_matnr.

Ex: Retrieve the data from mara and marc tables using Inner Joins.

*//table declaration

*//types declaration
TYPES :BEGIN OF ty_final,
matnr TYPE  matnr,
ersda TYPE  ersda,
ernam TYPE ernam,
laeda TYPE laeda,
aenam TYPE aenam,
mtart TYPE mtart,
matkl TYPE matkl,
werks  TYPE werks_d,
pstat  TYPE pstat_d,
lvorm  TYPE lvowk,
mmstd  TYPE mmstd,
ekgrp  TYPE ekgrp,
END OF ty_final.

*//internal table declaration
DATA:lt_final TYPE TABLE OF ty_final.
*//work area declaration
data:wa_final TYPE ty_final.

*// selection screen design
SELECT-OPTIONS s_matnr FOR mara-matnr.

*//retrieve data from mara & marc by using inner join
select a~matnr a~ersda a~ernam a~laeda a~aenam a~mtart a~matkl
b~matnr b~werks b~pstat b~lvorm b~mmstd b~ekgrp
from mara as a
INNER JOIN marc as b
on a~matnr = b~matnr
where a~matnr in s_matnr.

LOOP AT lt_final INTO wa_final.
WRITE :  / wa_final-matnr,wa_final-ersda,wa_final-ernam,wa_final-laeda,wa_final-aenam,wa_final-mtart,



Execute the program

Provide the sample input values and click on execute

Inner Joins in ABAP


Inner Joins in ABAP1


That’s it.

Also Read :

Retrieving Data From 3 tables Using Inner Joins.

Blocked ALV in SAP ABAP.

Converting and downloading Internal Table data into HTML format.

33 Flares Twitter 0 Facebook 33 Google+ 0 LinkedIn 0 Email -- Pin It Share 0 33 Flares ×