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

Select Distinct Error

Former Member
0 Likes
1,614

I want to retrieve a list of non-duplicate record from table BSEG so i code as below:

DATA: BEGIN OF it_bseg OCCURS 0,

belnr LIKE BSEG-BELNR,

vbund LIKE BSEG-VBUND,

END OF it_bseg.

SELECT DISTINCT BELNR VBUND

APPENDING CORRESPONDING FIELDS OF TABLE it_bseg

FROM BSEG

WHERE KUNNR <> '' OR KUNNR IS NOT NULL

ORDER BY BELNR.

But when i Check the code, it give me an error as below:

" Aggregate functions and the addition DISTINCT are not supported in field lists for pooled and clustered table. "

If i change the code to SELECT DISTINCT * then there is no error.

Why this error happen?

Thank you.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,155

Aaron,

First i would like to know why did you used

APPENDING statement here when there is no ENDSELECT.

Use like below

SELECT DISTINCT BELNR VBUND

into CORESPONDING FIELDS OF TABLE it_bseg

FROM BSEG

WHERE KUNNR <> '' OR KUNNR IS NOT NULL

ORDER BY BELNR.

Now it will work

Pls reward if useful

4 REPLIES 4
Read only

Former Member
0 Likes
1,155

as bseg is a cluster table so only you can use distinct * or count( * ) aggregate fn in select clause.

regards

shiba dutta

Read only

Former Member
0 Likes
1,156

Aaron,

First i would like to know why did you used

APPENDING statement here when there is no ENDSELECT.

Use like below

SELECT DISTINCT BELNR VBUND

into CORESPONDING FIELDS OF TABLE it_bseg

FROM BSEG

WHERE KUNNR <> '' OR KUNNR IS NOT NULL

ORDER BY BELNR.

Now it will work

Pls reward if useful

Read only

0 Likes
1,155

Hi muralikrishna kaipha,

I have tried on your code but it still give me the same error.

How can I check that whether a table is pooled/clustered table or not?

Thankz.

Read only

0 Likes
1,155

in se11 give the name of the table go to display mode it will show you whether it is transp table/cluster/pool table just check before the table name display text will be there.

regards

shiba dutta