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: 

select SUM( ) in inner join - error in code

Former Member
0 Kudos

Hi All,

The following code is using ABAP OO and I get the following error

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

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

clause.

Here is the Code:

select a/bic/ZEDM_ENTP amaterial a~/bic/zedm_stid

a/bic/ZEDM_SDT a/bic/ZEDM_MINH a~/bic/ZEDM_EHD

SUM( b~/bic/ZEDM_QPLN )

c~/bic/ZDEMQTY

from /bic/azdrp_1900 as a inner join /bic/azdrp_0400 as b

on

a/bic/ZEDM_ENTP = b/bic/ZEDM_ENTP and

amaterial = bmaterial and

a/bic/zedm_stid = bplant and

a/bic/ZEDM_SDT = b/bic/zedm_pshp

inner join /bic/azrp_0800 as C

on

amaterial = cmaterial and

a/bic/zedm_stid = c/bic/zedm_stid and

a/bic/ZEDM_SDT = c/bic/ZEDM_ESDT

into table z_it_inv for all entries in

RESULT_PACKAGE where

a~/bic/ZEDM_ENTP = RESULT_PACKAGE-/bic/ZEDM_ENTP

and a~material = RESULT_PACKAGE-material

and a~/bic/ZEDM_SDT = RESULT_PACKAGE-/BIC/OIZEDM_EDT

and a~/bic/zedm_stid = RESULT_PACKAGE-/BIC/OIZEDM_TOST

group by b/bic/ZEDM_ENTP bmaterial b~plant

b~/bic/zedm_pshp

Can you please tell me how to correct this?

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

When you are using for 'all entries' you can not use SUM because it is an aggregate function.

4 REPLIES 4

Former Member
0 Kudos

When you are using for 'all entries' you can not use SUM because it is an aggregate function.

0 Kudos

Krishna,

Is there a workaround for this? I need to use for all entries and want to do the summation of a particular colum.

Thanks

Deepa

0 Kudos

Aggregate functions are not very efficient. Try doing the SUM after the data is selected.

Rob

0 Kudos

Hi,

You can get all records first and then LOOP AT Internal table and use COLLECT statement to sum up required column.

This will be a better idea than trying to use SUM in SELECT with JOINS.

ashish