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

Subtotaling

Former Member
0 Likes
519

Hi Forum,

I have a field in which i have values starting with letter

L, T, and S.

I have another field containing amount for the corresponding L, T, and S.

My requirement is like this.. i need to do subtotal for individual values..

FIELD1 FIELD2

L0001 1000

L0002 1000

Sub total 2000

T0001 0500

T0002 0200

0700

Kindly help me out

Regards

Mallika

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
487

Hi,

Sort u r table based on ( I have a field in which i have values starting with letter L, T, and S ) that field.

Use control loop events.

At end of field.

sum.

endat.

Narasimha

Hi Forum,

I have a field in which i have values starting with letter

L, T, and S.

I have another field containing amount for the corresponding L, T, and S.

My requirement is like this.. i need to do subtotal for individual values..

FIELD1 FIELD2

L0001 1000

L0002 1000

Sub total 2000

T0001 0500

T0002 0200

0700

Kindly help me out

Regards

Mallika

2 REPLIES 2
Read only

Former Member
0 Likes
488

Hi,

Sort u r table based on ( I have a field in which i have values starting with letter L, T, and S ) that field.

Use control loop events.

At end of field.

sum.

endat.

Narasimha

Read only

Former Member
0 Likes
487

Hi,

Check the below code :

types : begin of tp_input,
        field1 type string,
        field2 type i,
        end of tp_input.

data : ig_input type standard table of tp_input,
       wg_input type tp_input.

data : subtotal1(4) type n,
       subtotal2(4) type n,
       subtotal3(4) type n.

wg_input-field1 = 'L0001'.
wg_input-field2 = '1000'.

append wg_input to ig_input.


wg_input-field1 = 'L0002'.
wg_input-field2 = '1000'.

append wg_input to ig_input.

wg_input-field1 = 'T0001'.
wg_input-field2 = '0500'.

append wg_input to ig_input.

wg_input-field1 = 'T0002'.
wg_input-field2 = '0200'.

append wg_input to ig_input.


loop at ig_input into wg_input.

if wg_input-field1 ca 'L'.

subtotal1 = subtotal1 + wg_input-field2.

elseif wg_input-field1 ca 'T'.

subtotal2 = subtotal2 + wg_input-field2.

elseif wg_input-field1 ca 'S'.

subtotal3 = subtotal3 + wg_input-field2.

endif.

endloop.

Write : subtotal1, / , subtotal2, / , subtotal3.

Regards,

Raghu