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: 

Re:select statement

Former Member
0 Kudos

Hi when I writing the following select statement

SELECT SUM( menge )

INTO sumgood

FROM aufm

WHERE ( bwart EQ '101' or bwart EQ 'X01' )

AND matnr EQ it_afpo-matnr

AND aufnr EQ t_prodbom-aufnr.

It gives me a error message the statement is not accesible,

Pls send the modified statement, give u full points.

regards

Sasi

1 ACCEPTED SOLUTION

Former Member
0 Kudos

If you are written it in a REPORT program,

try to insert 'START-OF-SELECTION' before the query.

ie,

START-OF-SELECTION.

QUERY.

8 REPLIES 8

Former Member
0 Kudos

sumgood should be the same type of menge

u need to use for all entries

Former Member
0 Kudos

If you are written it in a REPORT program,

try to insert 'START-OF-SELECTION' before the query.

ie,

START-OF-SELECTION.

QUERY.

Former Member
0 Kudos

Hi,

SELECT SINGLE SUM( menge )

INTO sumgood

FROM aufm

WHERE ( bwart EQ '101' or bwart EQ 'X01' )

AND matnr EQ it_afpo-matnr

AND aufnr EQ t_prodbom-aufnr.

Cheers,

Will.

Former Member
0 Kudos

Hi,

can u give me u r entire code so that i can try to coreect it.

Regards

sunil

raymond_giuseppi
Active Contributor
0 Kudos

If i remove the two following lines,

AND matnr EQ it_afpo-matnr
AND aufnr EQ t_prodbom-aufnr.

and define

sumgood LIKE aufm-menge

the program works well. so, the question is :

Are it_afpo and t_prodbom internal table with header line?

, if not use explicit work area, or use a SELECT FOR ALL ENTRIES syntax.

Regards

Former Member
0 Kudos

sashi,

Use GROUP BY caluse in your select statement.

Ex:

SELECT SUM( menge )

INTO sumgood

FROM aufm

WHERE ( bwart EQ '101' or bwart EQ 'X01' )

AND matnr EQ it_afpo-matnr

AND aufnr EQ t_prodbom-aufnr

GROUP BY matnr." Here on which field base you are summing the merge"

Don't forget to reward if useful....

Former Member
0 Kudos

Sashi,

TRY like this also.

WHERE bwart IN ( '101' , 'X01' ).

SELECT SUM( menge )

INTO sumgood

FROM aufm

WHERE bwart IN ( '101' , 'X01' )

AND matnr EQ it_afpo-matnr

AND aufnr EQ t_prodbom-aufnr.

Don't forget to reward if useful....

Former Member
0 Kudos

Hi,

Check the syntax of SUM:

SUM( [DISTINCT] col ) Determines the sum of the content of the column col in the resulting set or in the current group. The data type of the column has to be numerical.

Regards,

Bhaskar