07-10-2007 2:56 AM
Hi Experts ,
I need some logic from u r side ..
For example !!!
1 . iam having table sbook which contains some duplicate entries.
my ques is iam planning to write some logic in my ypsu_cos Program.
i.e 1. First it has to delete all duplicate entries from sbook table .
2. from now onwards it has to check each & evry time , if any duplicate entry exits or not ? if so it has to delete the entry & if not it has to insert the value
Regs ,
Narayana Murthy
07-10-2007 3:14 AM
07-10-2007 3:35 AM
Hi Narayana,
You can use this logic:
1.
SORT itab BY field1 field2. " Sort the internal table first
DELETE ADJACENT DUPLICATES FROM itab COMPARING field1 field2.
2.
READ TABLE itab INTO wa_itab WITH KEY field1 = new-field1 field2 = new-field2.
IF sy-subrc NE 0.
APPEND new TO itab.
ENDIF.
07-10-2007 3:52 AM
Hi Murthy,
Do the following, it will solve your problem.
1) SORT <internal table name> by field.
DELETE ADJACENT DUPLICATE ENTIRES FROM < internal table name>.
2) READ TABLE <internal table name> FROM <work area>
IF sy-subrc NE 0.
***INSERT your value
ENDIF.
Reward point if useful.
Regards,
SaiRam
07-10-2007 3:56 AM
Narayana,
You can use this logic:
1.
SORT itab BY field1 . " Sort the internal table first
DELETE ADJACENT DUPLICATES FROM itab COMPARING field1.
2.
In your loop of internal table...
LOOP AT ITAB
READ TABLE itab WITH KEY field1 = new-field1 binary search.
IF sy-subrc NE 0.
APPEND new TO itab.
ENDIF.
ENDLOOP.
Don't forget to reward if useful....
07-10-2007 4:21 AM
1) sort itab by <field name>.
delete adjacent duplicates from itab [comparing <field name(s)>].
2) take a int table ifinal like your itab(which contains data).
now..
loop at itab.
read table ifinal with key <field> = itab-<field>.
if sy-subrc = 0.
<you can modify ifinal by modify ifinal index sy-tabix after calculation.>
else.
append itab to ifinal.
endif.
clear : ifinal.
endloop.
regards
shiba dutta
07-10-2007 4:30 AM
Hi Narayana,
<u>You have to sort the table first then delete the duplicate entries as shown below:</u>
<b>sort itab by field1 field2 field3.
DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>
COMPARING field1 field2 field3.</b>
Regards,
Moqeeth.
07-10-2007 4:38 AM
see the below program for deleteing the dupicate Entries ...
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.
INSERT ADJACENT DUPLICATES FROM connection_tab.
DELETE ADJACENT DUPLICATES FROM connection_tab.
.
reward points if it is usefull ...
Girish
07-10-2007 5:21 AM
Hi Narayana,
Use this Command to avoid dublicate.
First sort that internal table by any of that field.
SORT ITAB_HEADER BY BANFN.
DELETE ADJACENT DUPLICATES FROM ITAB_HEADER COMPARING BANFN.
ITAB_HEADER is internal table.
IF USEFULL REWARD.