Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Abap inner join issue

0 Kudos

I am geeting an error while performing inner join in abap.i checked it in debugger screen but not getting any solution.kindly help me out for resolving this issue asap.

1 ACCEPTED SOLUTION

Domi
Contributor

Hi koushikbose2019

You don't have an error with the INNER JOIN, you have a problem with your target data structure!

You defined an internal sorted table with a unique key MATNR, ERNAME, MAKTX. But this SELECT statement returns multiple rows with equal field values!

So either you change the query to

SELECT DISTINCT MR~MATNR MR~ERNAME MK~MAKTX...

or you change the key of mytable to non unique:

... WITH NON-UNIQUE KEY ...

regards

Domi

4 REPLIES 4

GK817
Active Contributor

Please copy your code and use the 'CODE' option in editor. It increases chances to get answer.

Domi
Contributor

Hi koushikbose2019

You don't have an error with the INNER JOIN, you have a problem with your target data structure!

You defined an internal sorted table with a unique key MATNR, ERNAME, MAKTX. But this SELECT statement returns multiple rows with equal field values!

So either you change the query to

SELECT DISTINCT MR~MATNR MR~ERNAME MK~MAKTX...

or you change the key of mytable to non unique:

... WITH NON-UNIQUE KEY ...

regards

Domi

former_member1716
Active Contributor
0 Kudos

Hello Koushik Bose,

The issue is not with the join statements but on the resultant data. The data that you are fetching has duplicate entries, in other words for the where condition you have given there are more than one entry in your database.

You can check the same in backend in SE11 tcode by giving the same where condition.

You can either use NON UNIQUE KEY in the internal table declaration or using SELECT DISTINCT in the select statement.

One other solution would be you can just declare the table as a standard table instead of Sorted and sort your table after select statement.

Based on the logic you have incorporated using NON UNIQUE KEY or using STANDARD instead of SORTED would be an ideal solution.

Please use the CODE button next time to paste the code.

Hope this helps!!!

Regards!

keremkoseoglu
Contributor

You got to provide the language key when going to MAKT and use left join. Like:

LEFT JOIN makt ON makt~matnr EQ mara~matnr AND makt~spras EQ sy-langu