‎2008 May 20 10:43 AM
SELECT SINGLE SUM(ERFMG) FROM MSEG INTO ITAB-ERFMG WHERE MBLNR = ITAB-MBLNR AND LGORT = 'FGS' AND BWART = '101'.
this stmt is not working why?
‎2008 May 28 5:58 AM
Hi,
In your code ...
********************
SELECT SINGLE SUM(ERFMG) FROM MSEG INTO ITAB-ERFMG WHERE MBLNR = ITAB-MBLNR AND LGORT = 'FGS' AND BWART = '101'.
Change it like this.....
SELECT SINGLE SUM( ERFMG ) FROM MSEG INTO ITAB-ERFMG WHERE MBLNR = '10032333' AND LGORT = 'FGS' AND BWART = '101'.
*********************************
So in your the mistakes is the way you gave Sum(ERFMG) it shopuld be like Sum( ERFMG ) and in the where clause you cant use a field of itab as it is still initial...
Reward if helpful.
Regards,
Syed
‎2008 May 20 10:47 AM
hi
you need spaces Abap is very sensitive with that
try
SUM( ERFMG )
or what was the exact error ?
regards
‎2008 May 20 10:51 AM
i have given space but stil not giving output. Its saying Sum un known coloumn name
‎2008 May 20 11:00 AM
HI,
I THINK YOU HAVE GIVEN SPACE BETWEEN SUM AND THE BRACKET.
GIVE THE FOLLOWING WAY
SUM( ERFMG ).
REWARD IF HELPFUL
PRASANTH
‎2008 May 20 11:08 AM
Hi Anuradha,
try this code
SELECT SUM(ERFMG)
INTO ITAB-ERFMG
FROM MSEG
WHERE MBLNR = ITAB-MBLNR
AND LGORT = 'FGS'
AND BWART = '101'.
IF Found Helpfull DO Reward.
Regards.
Eshwar.
‎2008 May 20 12:06 PM
hi there....
i think the error is here
MBLNR = ITAB-MBLNR
u cannot apply this as itab currently is empty....
here itab is not the internal table but the work area which is empty when the query is called. u need to put this inside a loop at itab to get the query working.
do reward if helpful.
‎2008 May 20 5:44 PM
Hi,
Actually sum you should't use in select querys why becuase it is a performance issue.
anyhow, your select query is in loop or not. if it is in loop ok. but it is not in loop
itab-mblnr is empty so it won't work. then you have to read that table itab.
if it is one time requirement you can use read statement.
or it is required for all entries in itab then you have use loop.
below 2 eg are there 1st one is for read table and 2nd one is looping table
Eg: read table itab with key mblnr = mblnr.
Eg:
loop at itab.
select query.
endloop.
Regard
Ganesh
‎2008 May 20 7:15 PM
Hi Anuradha,
I have checked this query now and its working 100% correctly.
SELECT sum( erfmg )
INTO lv_erfmg
FROM mseg
WHERE mblnr = '4900000010'
AND lgort = '1020'
AND bwart = '561'.
Check: There is no gap between sum and starting bracket also check your doc number in debug mode.. if its not in compatible format thats in table no data will be fetched. You will have to apeend zeros or something.
Please award points to all correct answers in this thread and mark question as answered.
Thanks,
Ags..
‎2008 May 27 10:23 AM
y thr is necessary to SUM
ur using select single ,only one value will come .
use either select single erfmg
or select sum( erfmg )
as per ur requirement.
‎2008 May 28 2:46 AM
Hi,
Try this.
IF NOT ITAB-MBLNR IS INITIAL.
SELECT SUM( ERFMG ) FROM MSEG INTO
ITAB-ERFMG WHERE MBLNR = ITAB-MBLNR
AND LGORT = 'FGS' AND BWART = '101'.
ENDIF.
Hope it helps you.
Murthy.
‎2008 May 28 5:58 AM
Hi,
In your code ...
********************
SELECT SINGLE SUM(ERFMG) FROM MSEG INTO ITAB-ERFMG WHERE MBLNR = ITAB-MBLNR AND LGORT = 'FGS' AND BWART = '101'.
Change it like this.....
SELECT SINGLE SUM( ERFMG ) FROM MSEG INTO ITAB-ERFMG WHERE MBLNR = '10032333' AND LGORT = 'FGS' AND BWART = '101'.
*********************************
So in your the mistakes is the way you gave Sum(ERFMG) it shopuld be like Sum( ERFMG ) and in the where clause you cant use a field of itab as it is still initial...
Reward if helpful.
Regards,
Syed