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: 

problem with for all entries in select querry

Former Member
0 Kudos
2,703

hi,

Hi,

I am using select queery like this


SELECT  version  COUNT( * )  
from ztbi_default_va4 
INTO  CORRESPONDING FIELDS OF TABLE   lit_new  
FOR ALL ENTRIES IN lit_new1 
WHERE network = lit_new1-network GROUP BY version.

this is not working showing error as:

The addition "FOR ALL ENTRIES" excludes all aggregate functions with

the exception of "COUNT( * )" as the single element of the SELECT clause.

I am using only count(*) ,not using othes like max,min etc,,,,,,,,,

please suggest any missing in syntax,,,,attach relavant code using count(*) with for all entreis

any help appriciated,,,,,

Thanks in advance,,,,

1 ACCEPTED SOLUTION

Former Member
0 Kudos
467

hi ,

count(*) is also one of agregate functions so it will also not work here.

But still if you want to have total no of entries selected, you can use the following logic:-

data var type i value 0.

SELECT version COUNT( * )

from ztbi_default_va4

INTO CORRESPONDING FIELDS OF lit_new

FOR ALL ENTRIES IN lit_new1

WHERE network = lit_new1-network GROUP BY version.

var= var+1.

END SELECT.

var will have the total no of records selected.

i hope this helps.

regards,

somesh

Edited by: someshuttarwar on Feb 17, 2012 4:56 PM

6 REPLIES 6

Former Member
0 Kudos
467

Hi,

You should not use the (*) these type of key words in For all entries, Its going to refer other table with field to field.

Regards,

Mallikarjuna

Former Member
0 Kudos
468

hi ,

count(*) is also one of agregate functions so it will also not work here.

But still if you want to have total no of entries selected, you can use the following logic:-

data var type i value 0.

SELECT version COUNT( * )

from ztbi_default_va4

INTO CORRESPONDING FIELDS OF lit_new

FOR ALL ENTRIES IN lit_new1

WHERE network = lit_new1-network GROUP BY version.

var= var+1.

END SELECT.

var will have the total no of records selected.

i hope this helps.

regards,

somesh

Edited by: someshuttarwar on Feb 17, 2012 4:56 PM

Harsh_Bansal
Contributor
0 Kudos
467

Hi,

As the error is saying..you can't use any other field along with count(*) when using for all entries. You are selecting version also here along with it. So the error is coming.

You can select version based on for all entries, then loop on internal table and using counter store count in the other field.

Regards,

Harsh Bansal

0 Kudos
467

HI,

Harsh Bansal

I am geeting your point,,please insert any relavant code that might help me to understand properly

thanks

Harsh_Bansal
Contributor
0 Kudos
467

Hi,

Try this -


TYPES: begin of t_data,
             version TYPE version,
             count    type i,
             end of t_data.

DATA: i_data TYPE STANDARD TABLE OF t_data,
           wa_data TYPE t_data.
DATA: l_version TYPE version,
           l_count TYPE i.

SELECT  version  COUNT( * )  
from ztbi_default_va4 
INTO  CORRESPONDING FIELDS OF TABLE   lit_new  
FOR ALL ENTRIES IN lit_new1 
WHERE network = lit_new1-network.
SORT lit_new.

LOOP AT lit_new INTO lwa_new.
    IF lwa_new EQ l_version.
      l_count = l_count + 1.
    ELSE.
      wa_data-version = l_version.
      wa_data-count = l_count + 1.
      APPEND wa_data TO i_data.
      CLEAR: wa_data.
      CLEAR: l_count.
    ENDIF.
    l_version = lwa_new-version.
    CLEAR: lwa_new.

I hope this will do.

Make any necessary changes.

Regards,

Harsh Bansal

Former Member
0 Kudos
467

thanks