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 STMT

Former Member
0 Likes
734

fOLLOWING SELECT STMT GIVING ERROR.cAN ANYONE TELL ME Y??

SELECT MATNR

WERKS

LGORT

ERSDA

SUM( LABST,SPEME,INSME,RETME,UMLME ) I

INTO TABLE T_MARD

FROM MARD

FOR ALL ENTRIES IN T_EKORG

WHERE WERKS = T_EKORG-WERKS AND

LGORT IN S_LGORT.

ERROR:COMMA WIDOUT PRECEDING COLON(AFTER SELECT?).

6 REPLIES 6
Read only

Former Member
0 Likes
707

Hi,

Check whether the spaces of the bracket are provided or not.

It is the problem i think.

Read only

Former Member
0 Likes
707

This might be because of the comma u have placed in between the field names whithin the sum clause of the select stmnt.

Try removing the comma and replace it with a space.

Reward if helpfull.

Jayadeep.

Read only

Former Member
0 Likes
707

remove the spaces between ( and fieldnames .

eq

instead of ( f1 , f2 )

write (f1,f2)

Read only

prasanth_kasturi
Active Contributor
0 Likes
707

hi

remove the spaces between the brackets and fields

use like this

SELECT MATNR

WERKS

LGORT

ERSDA

SUM ( LABST SPEME INSME RETME UMLME )

INTO TABLE T_MARD

FROM MARD

FOR ALL ENTRIES IN T_EKORG

WHERE WERKS = T_EKORG-WERKS AND

LGORT IN S_LGORT.

moreover

The statement SUM can only be specified within a loop starting with LOOP, and is only considered within a AT- ENDAT control structure. Prerequisites for using the statement SUM include using the addition INTO in the LOOP statement, and that the specified work area wa is compatible with the row type of the internal table. In addition, SUM cannot be used when the row type of the internal table itab contains components that are tables.

The statement SUM calculates the component total with the numeric data type (i, p, f) of all rows in the current control level and assigns these to the components of the work area wa. In the control levels FIRST, LAST, and outside of an AT-ENDAT control structure, the system calculates the sum of numeric components of all rows in the internal table.

reward if helpful

prasanth

Read only

Former Member
0 Likes
707

Hi madan,

Don't give comas in fields whatever u used for SUM.

like this

SELECT MATNR

WERKS

LGORT

ERSDA

SUM( LABST SPEME INSME RETME UMLME ) I

INTO TABLE T_MARD

FROM MARD

FOR ALL ENTRIES IN T_EKORG

WHERE WERKS = T_EKORG-WERKS AND

LGORT IN S_LGORT.

If useful give reward,

Thanks ,

Narasimha

Read only

Former Member
0 Likes
707

There is another option

Since you want to sum 4 fields, you can use 4 SUM clauses

and store result for each sum in another variable.

Finally you can add up these 4 variables to get the final sum.

eq

select f1 SUM(f2) sum(f3)

into (v_1,v_2,v_3)

from...

where...

v_f = v_1 + v_2 + v_3 .

Hope this solves the problem