2007 Jun 26 11:10 AM
Hi,
I hav an intrenal table y_itab .
i need to find out whether it has any duplicate entries , if ther are then display that record r else process .
Plz provide me some logic for this .
Thanks.
loop at itab1.
read table itab2 with key vbeln = itab1-vbeln and check with all fields.
if sy-subrc = 0.
itab1-count = l_count.
Modify itab1 ndex sytabix transporting count .
else.
l_count = l_couynt + 1.
endif.
endloop.
itab2[] = itab1[].
Display the data from itab1 where count is similar
2007 Jun 26 11:15 AM
HI,
YOU CAN DELEATE THOSE DUPLICATE ENTRIES FROM YOUR INTERNAL TABLE BY USING
DELEATE DUPLICATE ENTRIES IN ITAB
AND THEN PROCESS THE INTERNAL TABLE
2007 Jun 26 11:17 AM
2007 Jun 26 11:17 AM
Hi Hem,
Check this thread surely it will help you.
https://forums.sdn.sap.com/click.jspa?searchID=3455251&messageID=1260325
Thanks,
Reward If Helpful.
2007 Jun 26 11:18 AM
Hi,
DELETE - duplicates
Syntax
... ADJACENT DUPLICATES FROM itab
[COMPARING { comp1 comp2 ...}|{ALL FIELDS}]... .
Addition:
... COMPARING {comp1 comp2 ...}|{ALL FIELDS}
Effect
With these additions, the statement DELETE deletes all lines in certain groups of lines, except for the first line of the group. These are groups of lines that follow one another and have the same content in certain components. If the addition COMPARING is not specified, the groups are determined by the content of the key fields.
Lines are considered to be doubled if the content of neighboring lines is the same in the components examined. In the case of several double lines following one another, all the lines - except for the first - are deleted.
Addition
... COMPARING {comp1 comp2 ...}|{ALL FIELDS}
Effect
If the addition COMPARING is specified, the groups are determined either by the content of the specified components comp1 comp2 ... or the content of all components ALL FIELDS. The specification of individual components comp is made as described in the section Specification of Components. Access to class attributes is possible through the object component selector only as of Release 6.10.
Example
Deleting all multiple-occurring lines in the internal table connection_tab. The result of this exanple corresponds to the one in the example for the position specification for INSERT.
DATA: BEGIN OF connection,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
distid TYPE spfli-distid,
distance TYPE spfli-distance,
END OF connection.
DATA connection_tab LIKE SORTED TABLE OF connection
WITH NON-UNIQUE KEY cityfrom cityto
distid distance.
SELECT cityfrom cityto distid distance
FROM spfli
INTO TABLE connection_tab.
DELETE ADJACENT DUPLICATES FROM connection_tab.
Regards,
Priyanka.
2007 Jun 26 11:19 AM
Hi,
itab1[] = itab[].
loop at itab1.
loop at itab where condition for checking duplicate.
write : / itab.
delete itab1 where condition for checking duplicate.
endloop.
endloop.
2007 Jun 26 11:20 AM
hi,
take another intenal table of same structure y_itab. let it be y_itab1.
y_itab1[] = y_itab[]
then delete the duplicates in y_itab1[] w.r.t key field.
after that,
loop at y_itab1[]
loop at y_itab.......
if sy-subrc = 0.
count = count +1.
endif.
if count > 1.
display ur record.
clear count.
endif.
endloop.
endloop.
just an idea am giving.
try for other logic which doesn't containn nested loop if possible.
if useful reward points
thanks,
praveena.
2007 Jun 26 11:21 AM
2007 Jun 26 11:28 AM
loop at itab1.
read table itab2 with key vbeln = itab1-vbeln and check with all fields.
if sy-subrc = 0.
itab1-count = l_count.
Modify itab1 ndex sytabix transporting count .
else.
l_count = l_couynt + 1.
endif.
endloop.
itab2[] = itab1[].
Display the data from itab1 where count is similar
2007 Jun 26 11:28 AM
Hem,
Create another internal table itab1 the same way as itab .
Populate itab1 with the same data of itab .
itab1[] = itab[] .
Now to display duplicate entries,
loop at itab .
Read table itab1 with key f1 = itab-f1
f2 = itab-f2
...............
fn = itab-fn .
( Here key should be ALL the fields )
if sy-subrc = 0 .
This is the duplicate entry and display
write : itab1.
else.
*PROCESS as you want
endif .
endloop .
~ Laxmi
Reward all helpful answers
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |