data :Begin of I_data
data1,
data2,
data3,
end of i_data
I have a internal table I_dat filled with
data1 data2 data3
1) x y z
2) x y z
3) x y i
4) c n o
5) c n o
6) n p l
7) j k o
8) b l n
9) b l n
10) j k y
I would like to have only lines which are repeating I would like to have lines 1,2,4,5,8,9.
Any idea how could I do.
Best Regards,
Mark
Hi,
Check this code :
i_data1[] = i_data[]. loop at i_data1. count = 0. loop at i_data. read table i_data with key data1 = i_data1-data1 data2 = i_data1-data2 data3 = i_data1-data3. if sy-subrc eq 0. count = count + 1. endif. endloop. if count LE 1. delete i_data1. endif. endloop.
now i_data1 will contain repeated value entries.
Regards
Appana
Try this:
DATA: aux_itab LIKE i_dat OCCURS 0 WITH HEADER LINE, aux_cont TYPE i. SORT i_dat BY data1 data2 data3. aux_itab[] = i_dat[]. LOOP AT i_dat. CLEAR aux_cont. LOOP aux_itab WHERE data1 = i_dat-data1 AND data2 = i_dat-data2 AND data3 = i_dat-data3. ADD 1 TO aux_cont. ENDLOOP. IF aux_cont EQ 1. DELETE i_dat. ENDIF. ENDLOOP.
Here is one way to keep the duplicates.
report zrich_0001. data :begin of i_data occurs 0, data1, data2, data3, end of i_data. data :begin of i_data2 occurs 0, data1, data2, data3, end of i_data2. data: counter type i. i_data = 'xyz'. append i_data. i_data = 'xyz'. append i_data. i_data = 'xyi'. append i_data. i_data = 'cno'. append i_data. i_data = 'cno'. append i_data. i_data = 'npl'. append i_data. i_data = 'jko'. append i_data. i_data = 'bln'. append i_data. i_data = 'bln'. append i_data. i_data = 'jky'. append i_data. i_data2[] = i_data[]. sort i_data2 ascending by data1 data2 data3. delete adjacent duplicates from i_data2 comparing data1 data2 data3. loop at i_data2. clear counter. loop at i_data where data1 = i_data2-data1 and data2 = i_data2-data2 and data3 = i_data2-data3. counter = counter + 1. endloop. if counter = 1. delete i_data2. endif. endloop. loop at i_data2. write:/ i_data2-data1, i_data2-data2, i_data2-data3. endloop.
Regards,
Rich Heilman
Add a comment