Skip to Content
0
Mar 23, 2010 at 11:48 PM

Finding Sum of grouped lines / Tables EKKO, EKPO

87 Views

Hi, am using the following tables:

TABLES: ekko,ekpo.

with Inner Join

select ekkobukrs ekkoebeln ekkoaedat ekkobsart ekkoekgrp ekkolifnr ekkowaers ekkowkurs ekkoernam ekpobrtwr

into CORRESPONDING FIELDS OF TABLE itab from ekko

inner join EKPO on ekPOEBELN = ekkoebeln.

end-OF-SELECTION.

Basically i want to group the result of this SQL statement by Purchasing Doc (ekko~ebeln) and display the

sum of Gross value (ekpo~brtwr) for the line items of each Purchasing Doc.

Note: i want the Purchasing Doc to appear one time only in the report

i have tried the following :

select ekkobukrs ekkoebeln ekkoaedat ekkobsart ekkoekgrp ekkolifnr ekkowaers ekkowkurs ekkoernam sum( ekpobrtwr )

into CORRESPONDING FIELDS OF TABLE itab from ekko

inner join EKPO on ekPOEBELN = ekkoebeln

WHERE ekkobukrs IN S_bukrs AND ekkobsart IN s_bsart

Group By ekkoebeln ekkobukrs ekkoaedat ekkobsart ekkoekgrp ekkolifnr ekkowaers ekkowkurs ekko~ernam.

then loop through the ITAB:

LOOP at itab.

write:/ itab-bukrs under 'Company Code',

itab-ebeln UNDER 'PO-Number',

itab-aedat UNDER 'Date' ,

itab-bsart UNDER 'Doc-Type' ,

itab-ekgrp UNDER 'Purchase-Grp' ,

itab-lifnr UNDER 'Vendor' ,

itab-waers UNDER 'Currency',

itab-wkurs UNDER 'Rate' ,

itab-brtwr under 'Gross Value',

itab-ernam UNDER 'Created By'.

ENDLOOP.

but it is not working with me, am not able to show the result of sum( ekpo~brtwr ) am getting 0 in all lines

thanks a lot for your help