Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Aggregate Function + Summation

Former Member
0 Likes
741

Hi

I am using the below code the collect the sum of the fields H_RECIPTS and H_PAYMENTS into w_oreceipts, w_opayments.

Can you tell what is the problem with the below code as it does not give the sum, its just blank at runtime..

I checked whether there was any data with the below selection and found entries in TCJ_DOCUMENTS but the summation does not show up..

SELECT SUM( h_receipts ) SUM( h_payments )
               INTO (w_oreceipts, w_opayments)
               FROM   tcj_documents
               WHERE  comp_code     = p_bukrs
                AND   cajo_number   = wa_tcjdocs-cajo_number
                AND   document_date < s_date-low.

7 REPLIES 7
Read only

Former Member
0 Likes
710

Hi,

u can't use up to two SUM of vriable's content.

Use following types.......it may be useful to u.

SELECT SUM( h_receipts )

INTO (w_oreceipts)

FROM tcj_documents

WHERE comp_code = p_bukrs

AND cajo_number = wa_tcjdocs-cajo_number

AND document_date < s_date-low.

SELECT SUM( h_payments )

INTO ( w_opayments)

FROM tcj_documents

WHERE comp_code = p_bukrs

AND cajo_number = wa_tcjdocs-cajo_number

AND document_date < s_date-low.

Regards

ricky

Edited by: Ricky Maheshwari on Aug 29, 2008 10:48 AM

Read only

0 Likes
710

>

> Hi,

> u can't use up to two SUM of vriable's content

>

>Hi Smith,

>It is not possible to do two summations in one select statement.

Totally wrong, both of you. Of course you can have more than one SUM in the same select statement.

To the OP. The select statement looks ok to me. Are you completely sure that there are non 0 value in the two columns? What do you get when you remove the SUMs and run the query?

Read only

Former Member
0 Likes
710

Hi Smith,

It is not possible to do two summations in one select statement.

Your code should be slightly modified in the following way.

SELECT SUM( h_receipts )

INTO (w_oreceipts)

FROM tcj_documents

WHERE comp_code = p_bukrs

AND cajo_number = wa_tcjdocs-cajo_number

AND document_date < s_date-low.

SELECT SUM( h_payments )

INTO (w_opayments)

FROM tcj_documents

WHERE comp_code = p_bukrs

AND cajo_number = wa_tcjdocs-cajo_number

AND document_date < s_date-low.

bye

Prasad G.V.K

Read only

Former Member
0 Likes
710

Hi,

This code is working fine for meee..

tables mara.

data : VOLUM1 type TCJ_DOCUMENTS-H_RECEIPTS,

VOLUM2 type TCJ_DOCUMENTS-H_PAYMENTS.

select sum( H_RECEIPTS ) sum( H_PAYMENTS )

from TCJ_DOCUMENTS

into (VOLUM1,VOLUM2).

write : VOLUM1, VOLUM2.

Read only

Former Member
0 Likes
710

hi,

I have seen the Entries in the table, Why do u want to do Perform Summation.

Can you breif the Question. how are the entries are in the Table TCJ_DOCUMENTS.

Thanks & Regards,

Deepthi Dandibhotla.

Read only

0 Likes
710

Hi,

You can perform the Summation Seperatly for both H_Receipts and H_Payments.

Thanks & Regards,

Deepthi Dandibhotla.

Read only

Former Member
0 Likes
710

This is really weird, it works on ECC6 but not on 4.6 C