2010 Mar 03 6:33 AM
Hi All,
I have a scenario i got one internal table itab1 with 3 fields f1,f2,f3 and i am fetching some data from a standard table.Now i want to loop through the table itab1-f1 and see if there is any duplicate entries.How can this be done.I want some logic which is efficient.
Regards,
Ravi
Edited by: ravi r on Mar 3, 2010 7:34 AM
2010 Mar 03 6:44 AM
If you already have data in itab1 from standard table then check something like this.
Sort itab by f1.
Loop at itab.
Delete adjacent duplicates from itab comparing f1.
endloop.
If you already have data in itab1 from standard table then check something like this.
Sort itab by f1.
Loop at itab.
Delete adjacent duplicates from itab comparing f1.
endloop.
2010 Mar 03 6:42 AM
Hello ravi r ,
Your can very well use contror break for the itab for itab-f1 and write the logic in same u can use CNT(itab-F1) for counting the duplicates Chek for F1 help...!
AT END.
ENDAT.
in your loop.
or the other way is Sort and Loop ...use binary search ..Use parell Cursor for effeciency...!
Edited by: Anup Deshmukh on Mar 3, 2010 7:43 AM
2010 Mar 03 6:44 AM
If you already have data in itab1 from standard table then check something like this.
Sort itab by f1.
Loop at itab.
Delete adjacent duplicates from itab comparing f1.
endloop.
2010 Mar 03 6:46 AM
check example cnt will give you the number of duplicates count
NODES: spfli, sflight.
FIELD-GROUPS: header, flight_info, flight_date.
START-OF-SELECTION.
INSERT: spfli-carrid spfli-connid sflight-fldate
INTO header,
spfli-cityfrom spfli-cityto
INTO flight_info.
GET spfli.
EXTRACT flight_info.
GET sflight.
EXTRACT flight_date.
END-OF-SELECTION.
SORT STABLE.
LOOP.
AT FIRST.
WRITE / 'Flight list'.
ULINE.
ENDAT.
AT flight_info WITH flight_date.
WRITE: / spfli-carrid , spfli-connid, sflight-fldate,
spfli-cityfrom, spfli-cityto.
ENDAT.
AT flight_date.
WRITE: / spfli-carrid , spfli-connid, sflight-fldate.
ENDAT.
AT LAST.
ULINE.
WRITE: cnt(spfli-carrid), 'Airlines'.
ULINE.
ENDAT.
ENDLOOP.
Edited by: Anup Deshmukh on Mar 3, 2010 7:46 AM
2010 Mar 03 6:47 AM
Hi,
Use the following logic.
SORT itab ASCENDING BY f1.
LOOP AT itab.
MOVE SY-INDEX to indx.
indx = indx + 1.
READ itab into wa_temp with index indx.
IF itab-f1 eq wa_temp-f1.
duplicate.
ELSE.
process your logic.
ENDIF.
CLEAR indx.
ENDLOOP.Regards,
Shankar.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |