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

Comparing data in internal table data with record by record

Former Member
0 Likes
1,448

Hi Guys,

In my internal table there are two fields material and keyfigure.

my requirement is to compare the 1st record with remaining records of internal table.

Ex:

internal table has 10 records with 10 materials

first record of material keyfigure value should compare with remaining 9records of materials keyfigures.

please suggest me with code how to get the second ,third .....records with first record of internal table.

Thanks in Advance

Venkat

Edited by: venkat venkata on Jan 15, 2009 8:27 PM

1 ACCEPTED SOLUTION
Read only

Former Member
637

*move the data to a temporary table
itab1[] = itab[].
* get your first record
read table itab1 into wa_itab
index 1.
*delete the 1st record
DELETE  itab1 INDEX 1.
*loop at rest of the records
loop at itab1 into wa_itab1.
*compare the MATNR 
if wa_itab1-matnr <> wa_itab-matnr.
  " your logic here
endif.
endloop.
3 REPLIES 3
Read only

Former Member
0 Likes
637

data: l_first(1),

begin of itab occurs 0,

matr like --

keyfigure like--

end of itab,

wa_itab like line of itab,

la_itab like line of itab.

clear l_first.

loop at itab into wa_itab.

if l_first eq ' '.

la_itab = wa_itab.

l_first = 'X'.

endif.

write code here comparing la_itab-matr and la_itab-keyfigure with wa_itab values.

endloop.

Read only

0 Likes
637

Thank you very much.

Read only

Former Member
638

*move the data to a temporary table
itab1[] = itab[].
* get your first record
read table itab1 into wa_itab
index 1.
*delete the 1st record
DELETE  itab1 INDEX 1.
*loop at rest of the records
loop at itab1 into wa_itab1.
*compare the MATNR 
if wa_itab1-matnr <> wa_itab-matnr.
  " your logic here
endif.
endloop.