Application Development and Automation 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: 
Read only

Join retrieving duplicate records

Former Member
0 Likes
2,214

Can someone tell me why I am returning 10 records when there only should be one. I can put in a delete duplicates record after this but i would prefer to know what is wrong with the below. Tnks.

SELECT MARAMATNR MARAPRDHA

MAKTMAKTX T179TVTEXT

APPENDING CORRESPONDING FIELDS OF TABLE GT_WK_STORAGE

FROM MARA AS MARA

INNER JOIN MAKT AS MAKT

ON MARAMATNR EQ MAKTMATNR

AND SPRAS EQ SY-LANGU

INNER JOIN T179T AS T179T

ON MARAPRDHA EQ T179TPRODH

WHERE MARA~MATNR IN S_MATNR.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,167

Hi,

I see one error in your code:

+FROM MARA AS MARA

INNER JOIN MAKT AS MAKT

ON MARAMATNR EQ MAKTMATNR

AND SPRAS EQ SY-LANGU+

how can you pretend to join tables MARA and MAKT with field SPRAS, when this field does not exist in MARA ??

I think you should modify your code this way:

SELECT MATNR PRDHA

into CORRESPONDING FIELDS OF GT_WK_STORAGE

from mara

WHERE MATNR IN S_MATNR.

SELECT single MAKTMAKTX T179TVTEXT

into CORRESPONDING FIELDS OF GT_WK_STORAGE

FROM makt inner join T179T

ON MAKTSPRAS EQ T179TSPRAS

WHERE MAKT~MATNR = GT_WK_STORAGE-MATNR

and spras = sy-langu.

append GT_WK_STORAGE.

endselect.

Check the code, that I didn´t do it in SAP.

6 REPLIES 6
Read only

Former Member
0 Likes
1,168

Hi,

I see one error in your code:

+FROM MARA AS MARA

INNER JOIN MAKT AS MAKT

ON MARAMATNR EQ MAKTMATNR

AND SPRAS EQ SY-LANGU+

how can you pretend to join tables MARA and MAKT with field SPRAS, when this field does not exist in MARA ??

I think you should modify your code this way:

SELECT MATNR PRDHA

into CORRESPONDING FIELDS OF GT_WK_STORAGE

from mara

WHERE MATNR IN S_MATNR.

SELECT single MAKTMAKTX T179TVTEXT

into CORRESPONDING FIELDS OF GT_WK_STORAGE

FROM makt inner join T179T

ON MAKTSPRAS EQ T179TSPRAS

WHERE MAKT~MATNR = GT_WK_STORAGE-MATNR

and spras = sy-langu.

append GT_WK_STORAGE.

endselect.

Check the code, that I didn´t do it in SAP.

Read only

0 Likes
1,167

Tnks but the code is not incorrect.

Read only

Former Member
0 Likes
1,167

Both tables MAKT and T179T have Language as part of their key so..

SELECT MARAMATNR MARAPRDHA

MAKTMAKTX T179TVTEXT

APPENDING CORRESPONDING FIELDS OF TABLE GT_WK_STORAGE

FROM MARA AS MARA

INNER JOIN MAKT AS MAKT

ON MARAMATNR EQ MAKTMATNR

INNER JOIN T179T AS T179T

ON MARAPRDHA EQ T179TPRODH

WHERE MARA~MATNR IN S_MATNR

<i> AND MAKT~SPRAS = SY-LANGU

AND T179T~SPRAS = SY-LANGU.</i>

One issue to be careful with is if the texts are not maintained in all sign-on languages. If they are not, you will not select anything!

Read only

0 Likes
1,167

Thats it . Thanks.

Yeah aware of inner join part but it forces them to make sure that they are maintained.

Points awarded and thank you for you time.

Read only

Former Member
0 Likes
1,167

Tried to award you points but got an error message. Not sure if you got them.

Read only

former_member378318
Contributor
0 Likes
1,167

Hi,

I don't see why this would give you duplicate enteries (it should not).

However I see that you are using the APPENDING CORRESPONDING FIELDS statement which may possibly lead to duplicates if your SELECT statement is within a LOOP.

Hope it helps