cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem Select sum with group by.

former_member635273
Participant
0 Likes
3,970
SELECT SUM( menge ) brpme FROM zmtc_item INTO CORRESPONDING FIELDS OF TABLE it_tot
  WHERE ebeln = p_ebeln  GROUP BY brpme.

the problem is value return 0 in smartforms and UoM (M and ***) it should be (M and PC). like pic sap2.jpg

This is when i debug.

and this is in smartforms

Accepted Solutions (1)

Accepted Solutions (1)

michael_piesche
Active Contributor

You have two problems:

  1. When using „into corresponding fields“, the column names need to be identical. This is not the case for „sum( menge )“, as it is a dynamic column that will be named by the dbms or ABAP as probably „SUMMENGE“, or not get a name assigned at all
    => rename in your select statement this column: „sum( menge) as menge“
    Or use a table type that matches your selection fields in order and type, and don’t use into corresponding fields
  2. I assume the translation for PC is missing, since this is only a problem on the printout
former_member635273
Participant
0 Likes

I rename sum( menge ) as sum.still not work. So,I use table type.and it's work.

and second problem, you are right. when I insert UoM => PC, it's not appears in printout. when i insert UoM => ST. in smartform appears PC.

michael_piesche
Active Contributor
0 Likes

Sorry for that mistake of mine, of course I meant to write „sum( menge) as menge“, after all you want the column to have the same name so that the „into corresponding fields“ statement works. Sorry for the confusion.

Answers (0)