Skip to Content
0
Former Member
Jul 09, 2007 at 06:36 PM

insert specific line in an internal table at a specific place

1157 Views

Hi

i have an internal table (itab) let's say

Name1 Name2 NUM1 NUM2 NUM3

Which already populater with data.

i have to do a subtotal for every NAME1 and insert a line just after the NAME1 in the internal table

and another subtotal by every NAME1 NAME2 and insert a line just after every NAME1 and NAME2 in the internal table

then another Grand total at the end of the table

My psudeo code is a bit like that but the insert is done in the wrong row

Index=1

LOOP at itab index

if itab-name1 NE old

insert structure in itab index

elseif itab-name1 NE old and itab-name2 NE old

insert structure in itab index

elseif itab EQ last line

insert structure in itab index

else

structure-num1 = structure-num1 + itab-num1

structure-num2 = structure-num2 + itab-num2

endif

index = index + 1

endloop

Do you think i need to use a temporary table here. can u guide me in code plz..