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

Internal Table

Former Member
0 Likes
1,425

Hi,

I have two fields in the Internal table. Serial No, Description .

How can we find out in an internal table that there more than one record in the Internal table for a particular rserial no ?

Is it possible by using read ? . By using loop we can do it . But with out loop is there any another method ?

Bye,

Satya.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,410

would u like to know are there repeated values

or

what are the values repeating?

IF the first case,

U can know, by comparing no of times triggering using At new and no of lines there in the I.Table, using describe statement.

Reward me if useful.

15 REPLIES 15
Read only

Former Member
0 Likes
1,410

sy-tabix .

reward points if it is usefull

Girish

Read only

0 Likes
1,410

How can we find out by sy-tabix ?

Can you please expain ?

Bye,

satya.

Read only

Former Member
0 Likes
1,410

Hi,

Say you have data in ITAB.

now,

jtab[] = itab[].

delete jtab where serial no <> 1.

describe jtab lines line_count.

if line_count > 1.

more than 1 record.

endif.

Reward if useful.

Read only

0 Likes
1,410

Hi,

This is only for particular record. But I have so many records in the internal table. For Every record I have to check it . Then Performance will decrese. Apart from this is there any another method ?

Bye,

Satya.

Read only

Former Member
0 Likes
1,410

Yes..,

sort itab by serialno.

<b>delete adjacent duplicates from itab comparing serialno.</b>

if sy-subrc eq 0.

-


More than one record for same serial number----


else.

-


No multiple records-------

endif.

reward all helpful answers !!

regards,

sai ramesh

Read only

Former Member
0 Likes
1,410

Use this one:

data: l_line type i,

l_line2 type i.

i_test2[] = i_test1[].

Describe table <i>i_test1</i> lines l_line.

delete adjacent duplicates i_test1 comparing serial no.

Describe table <i>i_test2</i> lines l_line2.

if i_l_line1 > l_line2.

"serial has more than one record

endif.

with this method u can find out how many records in your internal table.

Message was edited by:

Memeo

Read only

0 Likes
1,410

can we use two fields in delete adjacent duplicate comparin field1 feild 2 ?

bye,

satya.

Read only

0 Likes
1,410

yes you can use

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING F1 F2.

Read only

0 Likes
1,410

<b>delete adjacent duplicates returns sy-subrc ...

if it deletes at least one record then sy-subrc eq 0.</b>

sort itab by serialno.

delete adjacent duplicates from itab comparing serialno.

if sy-subrc eq 0.

-


More than one record for same serial number----


else.

-


No multiple records-------

endif.

Please do remember to close the thread when ur problem is solved and reward all helpful answers !!!

regards,

sai ramesh

Read only

Former Member
0 Likes
1,411

would u like to know are there repeated values

or

what are the values repeating?

IF the first case,

U can know, by comparing no of times triggering using At new and no of lines there in the I.Table, using describe statement.

Reward me if useful.

Read only

Former Member
0 Likes
1,410

data : count type i.

count = 0.

itab_temp[] = itab[].

do 2 times.
read table itab_temp with key SNO = '001'.
if sy-sybrc eq 0.
count = count + 1.
delete  itab_temp.
endif.
enddo.

<b>if count GT 1.

  • duplicate entry exists.

endif.</b>

Read only

LeonardoAraujo
SAP Mentor
SAP Mentor
0 Likes
1,410

A couple of ways:

sort and then delete adjacent duplicates would make sure you have no duplicates at all.

if you need to find the duplicates you could have made a read before inserting into it for example.

If you cannot and just want to evaluate your data, do the following:

sort ITAB.

loop at itab into wa_itab.

l_index = sy-tabix + 1.

read table itab into wa_duplicate_itab index l_index.

if sy-subrc = 0.

if wa_itab-serialnum = wa_duplucate_itab-serialnum.

append wa_duplicate_itab to duplicate_itab.

endif.

endif.

endloop.

This is a high performance approach: select with index.

Leonardo De Araujo

Read only

Former Member
0 Likes
1,410

Hello,

Try this and reward if found helpfull.

Regards,

rakesh.


declare old_srno value 0.
sort your internal table by serial number.

loop at itab into wrk_area.
if old_srno = wrk_area-srno.
flg = 1.
endif.
old_srno = wrk_srno.
endloop.

Read only

Former Member
0 Likes
1,410

You gotto use loop, what you can do is use WHERE in loop, i don't think its easy to find duplicate records using read

Read only

Former Member
0 Likes
1,410

Loop at itab.

loop at itab where sernr = itab-sernr.

endloop.

endloop.