Application Development 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: 

need logic for this output itab format

Former Member
0 Kudos

hi guys

i need the output itab in following format

i have data in my present itab

itab-f1 itab-f2 itab-f3

AAA 10 (means null,' ')

AAA 20

BBB 10

BBB 20 A1

BBB 30

and i want output in following way output itab

itab-f1 itab-f2 itab-f3

AAA 30

BBB 60 A1

can anyone suggest me code for this

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You want the sum of f2 for a group of f1's?

Is f3 going to be the same for that group?

Try this


sum = 0
sort itab by f1.
itab2 like itab.
loop itab.
sum = itab-f2 + sum.
f3var = tab-f3.
at end of f1.
move itab-f1 to itab2-f1.
move sum to itab2-f2.
move f3var to itab2-f3.
append itab2.
sum = 0.
endat.
endloop.

Edited by: Ramiro Escamilla on Feb 7, 2008 11:29 PM

2 REPLIES 2

Former Member
0 Kudos

You want the sum of f2 for a group of f1's?

Is f3 going to be the same for that group?

Try this


sum = 0
sort itab by f1.
itab2 like itab.
loop itab.
sum = itab-f2 + sum.
f3var = tab-f3.
at end of f1.
move itab-f1 to itab2-f1.
move sum to itab2-f2.
move f3var to itab2-f3.
append itab2.
sum = 0.
endat.
endloop.

Edited by: Ramiro Escamilla on Feb 7, 2008 11:29 PM

0 Kudos

Thank you very much my friend

it works fine