‎2007 Jul 05 1:33 PM
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.
‎2007 Jul 05 1:38 PM
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.
‎2007 Jul 05 1:35 PM
‎2007 Jul 05 1:36 PM
How can we find out by sy-tabix ?
Can you please expain ?
Bye,
satya.
‎2007 Jul 05 1:36 PM
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.
‎2007 Jul 05 1:39 PM
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.
‎2007 Jul 05 1:37 PM
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
‎2007 Jul 05 1:38 PM
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
‎2007 Jul 05 1:45 PM
can we use two fields in delete adjacent duplicate comparin field1 feild 2 ?
bye,
satya.
‎2007 Jul 05 1:49 PM
yes you can use
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING F1 F2.
‎2007 Jul 05 1:53 PM
<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
‎2007 Jul 05 1:38 PM
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.
‎2007 Jul 05 1:40 PM
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>
‎2007 Jul 05 1:40 PM
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
‎2007 Jul 05 1:40 PM
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.
‎2007 Jul 05 1:44 PM
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
‎2007 Jul 05 2:00 PM
Loop at itab.
loop at itab where sernr = itab-sernr.
endloop.
endloop.