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

Table values

Former Member
0 Likes
756

Hi ,

I need to bring the total of all the data of a field of a Database table .How do I do it?Any one please give me the syntax.

Thanks

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
734

hi bharat,

use COLLECT statement.

rgds

Anver

7 REPLIES 7
Read only

Former Member
0 Likes
734
UPDATE ZTABLE set total = v_total  where field1 = v_field1.

in the where condition give all the key fields

Read only

anversha_s
Active Contributor
0 Likes
735

hi bharat,

use COLLECT statement.

rgds

Anver

Read only

Former Member
0 Likes
734

Hi Bharat,

Use SUM( database-field) to get the sum of the data field.

SELECT SUM( DBFIELD )

INTO V_SUM

FROM DB_TABLE.

Thanks,

Vinay

Read only

Former Member
0 Likes
734

hi Bharat,

Bring the data on to an Internal Table and use <b>Collect</b> or Sum statement ..

Regards,

Santosh

Read only

Former Member
0 Likes
734

take the data into internal table

and then use<b> COLLECT</b>

Read only

Former Member
0 Likes
734

Hi,

Use SUM instead of Collect statement .

Cheers.

Read only

Former Member
0 Likes
734

Hi there. You can use SUM to accomplish this. Here's some example code:

DATA: itab_wa LIKE LINE OF itab.

LOOP AT itab INTO itab_wa.

AT LAST.

SUM.

WRITE: / 'Sum', itab_wa-numfield.

ENDAT.

ENDLOOP.

The SUM statement will put the sum of the numeric fields for your internal table (itab) into the itab_wa record. Hope this helps.

- April King