2008 Jun 16 3:21 PM
Hello,
I've got the bellow code that works ok and gets 159 rows from the database:
SELECT a~werks a~fecha_dist b~matnr b~bdmng b~meins
FROM zmtraz1 AS a INNER JOIN resb AS b
ON a~resnr_01 = b~rsnum
INTO TABLE gt_cargas
WHERE a~fecha_dist IN gt_fechas_cargas.
But I want to use SUM with the field bdmng but it doesn't return me any result, only sy-subrc = 4 because nothing has been selected, what I'm doing wrong?
The code:
SELECT a~werks a~fecha_dist b~matnr SUM( b~bdmng ) b~meins
FROM zmtraz1 AS a INNER JOIN resb AS b
ON a~resnr_01 = b~rsnum
INTO TABLE gt_cargas
WHERE a~fecha_dist IN gt_fechas_cargas
GROUP BY a~werks a~fecha_dist b~matnr b~meins.
2008 Jun 16 3:28 PM
Ups sorry, the code was OK my error was not in the statement.
2008 Jun 16 3:34 PM
After GROUP BY, the same column identifiers must be specified as after SELECT. The specification can either be specified statically as a list col1 col2 ... or dynamically as a brackted data object column_syntax that - at execution of the statement - contains the syntax of the staticspecification or is set to initial value. For column_syntax, the same applies as for the dynamic column specification after SELECT.
move the sum ( ) field to last i.e after meins.
and even change it in the internal table also.