2019 Oct 14 3:49 PM
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.
2019 Oct 14 9:53 PM
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
2019 Oct 14 4:22 PM
Please copy your code and use the 'CODE' option in editor. It increases chances to get answer.
2019 Oct 14 9:53 PM
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
2019 Oct 15 3:11 AM
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!
2019 Oct 15 6:45 AM
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