2009 Feb 03 4:55 AM
Hi,
Have written the select query as
SELECT lifnr gjahr belnr buzei bldat zfbdt zbd1t dmbe2 shkzg
INTO TABLE gt_bsik
FROM bsik FOR ALL ENTRIES IN gt_lfb1
WHERE bukrs EQ p_bukrs
AND lifnr EQ gt_lfb1-lifnr
AND umsks EQ space
AND umskz EQ space
AND augbl EQ space
AND zfbdt LE p_nedat.
next i have to find the sum of buzei field.How to do this.Please help
2009 Feb 03 5:06 AM
Hi Hema,
You can use keyword SUM for your requirement, as explained above.
Here is an alternative approach:
DATA: w_sum type i.
w_sum = 0.
LOOP AT gt_bsik INTO wa_bsik.
w_sum = w_sum + wa_bsik-buzei.
ENDLOOP.
WRITE:/ w_sum.
Hope this will help.
Regards,
Nitin
2009 Feb 03 4:57 AM
you can use control break statements.
at end of buzei.
sum.
endat.
hope this helps.
2009 Feb 03 4:59 AM
Hi.
Here is s sample code. make it change according to ur need
TYPES: BEGIN OF t_for_all,
matnr LIKE mbew-matnr,
bwkey LIKE mbew-bwkey,
END OF t_for_all.
TYPES: BEGIN OF t_mbew,
bwkey LIKE mbew-bwkey,
matnr LIKE mbew-matnr,
salk3 TYPE p,
END OF t_mbew.
DATA: it1_mbew TYPE STANDARD TABLE OF t_mbew WITH HEADER LINE,
it2_mbew TYPE STANDARD TABLE OF t_mbew WITH HEADER LINE,
it_for_all TYPE STANDARD TABLE OF t_for_all,
wa_it_for_all TYPE t_for_all.
wa_it_for_all-matnr = '000000002001000111'.
APPEND wa_it_for_all TO it_for_all.
wa_it_for_all-matnr = '000000000000000042'.
APPEND wa_it_for_all TO it_for_all.
CLEAR: wa_it_for_all.
wa_it_for_all-bwkey = '3000'.
APPEND wa_it_for_all TO it_for_all.
SELECT matnr bwkey bwtar salk3 FROM mbew
INTO CORRESPONDING FIELDS OF it1_mbew
FOR ALL ENTRIES IN it_for_all
WHERE matnr = it_for_all-matnr.
COLLECT it1_mbew INTO it1_mbew. " Use Collect in this way it will solve out your problem
ENDSELECT.
SELECT bwkey bwtar salk3 FROM mbew
INTO CORRESPONDING FIELDS OF it2_mbew
FOR ALL ENTRIES IN it_for_all
WHERE bwkey = it_for_all-bwkey
AND salk3 NE '0.00'.
COLLECT it2_mbew INTO it2_mbew. " Use Collect in this way it will solve out your problem
ENDSELECT.U just view the select and in select view the collect statement and make it change according to ur table
2009 Feb 03 5:03 AM
Hi,
Check using Aggregate functions..
SELECT lifnr gjahr belnr bldat zfbdt zbd1t dmbe2 shkzg
SUM ( buzei )
INTO TABLE gt_bsik
FROM bsik FOR ALL ENTRIES IN gt_lfb1
WHERE bukrs EQ p_bukrs
AND lifnr EQ gt_lfb1-lifnr
AND umsks EQ space
AND umskz EQ space
AND augbl EQ space
AND zfbdt LE p_nedat.OR
Loop the gt_bsik and find the sum of buzei.
2009 Feb 03 5:08 AM
Hi,
I tried the aggregate function sum(buzei) but its displaying error message as "Unknown column name "SUM". not determined until runtime, you cannot specify a field list",
How to correct it
2009 Feb 03 5:06 AM
Hi Hema,
You can use keyword SUM for your requirement, as explained above.
Here is an alternative approach:
DATA: w_sum type i.
w_sum = 0.
LOOP AT gt_bsik INTO wa_bsik.
w_sum = w_sum + wa_bsik-buzei.
ENDLOOP.
WRITE:/ w_sum.
Hope this will help.
Regards,
Nitin
2009 Feb 03 5:13 AM
DATA : begin of itab OCCURS 0,
pernr like pa0000-pernr,
END OF itab.
DATA : begin of itab1 OCCURS 0,
pernr like pa0000-pernr,
END OF itab1.
select pernr from pa0000 into table itab where pernr lt '10'.
clear itab.
loop at itab.
itab1-pernr = itab1-pernr + itab-pernr.
endloop.
loop at itab1.
write: itab1-pernr .
endloop.
2009 Feb 03 5:14 AM
>
> next i have to find the sum of buzei field.How to do this.Please help
Hello Hema,
I think you got the requirement wrong. BUZEI is the line item number of an a/c'ing doc. I think its wrong to aggregate BUZEI.
Please clarify what exactly do you want?
BR,
Suhas
2009 Feb 03 5:15 AM
you could just write a piece of code to loop the table and sum the values in the column.
data wa like line of gt_lfb1.
data s type i value 0.
Loop at gt_lfb1 into wa.
s = s + wa-buzei.
endloop.
in the end, the variable s should give u the sum.
hope it helps.