02-07-2008 2:06 PM
Hey Folks,
I have a requiremnet where i have a table
itab
field1 field2 field3 field4
12 45 60 57
23 56 78 90
-
35 101 138 147
I need the table t be modified like this
itab
field1 field2 field3 field4
0 0 0 0
0 0 0 0
-
35 101 138 147
I need to clear the 2 records without disturbing the sum.
how wud i achieve this.
thanks in advance.
Regards
Rock
Edited by: Alvaro Tejada Galindo on Feb 7, 2008 9:22 AM
02-07-2008 2:30 PM
check this code...
DATA : BEGIN OF itab OCCURS 0,
f1(4) TYPE p,
f2(4) TYPE p,
f3(4) TYPE p,
f4(4) TYPE p,
END OF itab.
DATA : itab2 LIKE itab OCCURS 0 WITH HEADER LINE.
itab-f1 = 20.
itab-f2 = 10.
itab-f3 = 30.
itab-f4 = 40.
APPEND itab.
itab-f1 = 11.
itab-f2 = 14.
itab-f3 = 23.
itab-f4 = 24.
APPEND itab.
LOOP AT itab.
AT LAST.
SUM.
MOVE-CORRESPONDING itab TO itab2.
APPEND itab2. "totals will be stored in itab2.
ENDAT.
ENDLOOP.
CLEAR itab[]. "clear first internal table.
02-07-2008 2:17 PM
you do one thing that make a new field in table and then move components of sum to that like
move oldsum to newsum.
now whatever you do with your old fields this field is unaffected.
after deleting contents of new back to old
move newsum to oldsum.
<REMOVED BY MODERATOR>
vivek
Edited by: Alvaro Tejada Galindo on Feb 7, 2008 9:24 AM
02-07-2008 2:22 PM
02-07-2008 2:30 PM
YOU DO ONE THING -
make a table of same fields.
now move your sum to this table .
this can be done by -
append sum into it_newtab.
now whatever u do to ur old table ur new table is unaffected
plz reward if useful
vivek
02-07-2008 2:30 PM
check this code...
DATA : BEGIN OF itab OCCURS 0,
f1(4) TYPE p,
f2(4) TYPE p,
f3(4) TYPE p,
f4(4) TYPE p,
END OF itab.
DATA : itab2 LIKE itab OCCURS 0 WITH HEADER LINE.
itab-f1 = 20.
itab-f2 = 10.
itab-f3 = 30.
itab-f4 = 40.
APPEND itab.
itab-f1 = 11.
itab-f2 = 14.
itab-f3 = 23.
itab-f4 = 24.
APPEND itab.
LOOP AT itab.
AT LAST.
SUM.
MOVE-CORRESPONDING itab TO itab2.
APPEND itab2. "totals will be stored in itab2.
ENDAT.
ENDLOOP.
CLEAR itab[]. "clear first internal table.
02-07-2008 2:48 PM
Hey folks,
I have already summed up the records i need to just clear the 2 records without disturbing the sum.
02-07-2008 2:49 PM
02-07-2008 2:57 PM
Hey,
but how to clear only those 2 records without disturbing the sum..
02-07-2008 2:59 PM
tats what i said
f1
f2
f3
f1=10
f2=20
fe= f1+f2
f3= 30.
after this clear f1 nd f2