Skip to Content
0
Jul 18, 2016 at 06:48 PM

Use of inserting record with sy-tabix in at new and at end

138 Views

Hi all,

I have some logical issue while using at new and at end of concept .

My requirement, calculated record will insert on the at end of section.

Pls see my code here.

IT2[] = IT1[] " it contains more than 50 records.

sort it1 by date plant material type

sort it2 by date plant material type

my input it1,

date plant material type

19072016 A X sale

19072016 A X stock

19072016 B X stock

19072016 C X sale

19072016 C X stock

loop at it1 into wa1

at new matnr.

clear : wa1.

end at.

if wa1-type = 'stock'

wa1-st = value.

else

wal1-sa = value.

endif.

at end matnr.

if wa1-type = 'sale'

sal1-sa =value.

else

wa1-st = value.

endif.

wa1-cal = wa1-st / wa1-sal.

sy tab = sy tab + 1.

insert wa1 to it2 index into sy tabix.

Here, same material have sale and stock means, loop will executed twice and record will inserted third place.

another material only have sale or stock means, loop will executed once and record to be inserted on fifth place.

the above two scenario will come next records.

How it can be achieved. Please help.