2013 Aug 01 9:42 AM
Hi Expert,
Following IT_final data to be filtered..
Field1 Field2 Field3
1 ABC 234
3 234
4 CDE 89
5 XYZ 22
6 SLK SPA
8 89
9 DF 888
10 FSD
12 234
Note: To delete the final table based on Red marked one where you can find logic ...the field3 would be coming same no again with blank space then to be deleted.
Here....Row 3, 8,12 should be deleted based on condition equal to previous field3 and field2 values and field3 next row.
thanks
shree
2013 Aug 01 12:14 PM
Hi,
FIELD-SYBBOLS : <fs_final> TYPE LINE OF it_final.
DATA : v_tabix TYPE sy-tabix.
* Add a last field as flag TYPE c LENGTH 1, in the it_final.
LOOP AT it_final INTO wa_final.
v_tabix = sy-tabix + 1.
READ TABLE it_final ASSIGNING <fs_final>
INDEX v_tabix.
IF sy-subrc = 0 AND
<fs_final>-field2 = wa_final-field3 AND
<fs_final>-field3 = ' '.
<fs_final>-flag = 'X'.
ENDIF.
CLEAR : wa_final, v_tabix.
ENDLOOP.
DELETE it_final WHERE flag = 'X'.
Thanks & Regards
Bala Krishna
2013 Aug 01 12:31 PM
Hi Bala,
you use read statment. In case same record twice in the reading table..What can be don?
Thanks
shree
2013 Aug 01 3:07 PM
Then first use DELETE ADJUSCENT DUPLICATE ENTRIES FROM it_final COMPARING ALL FIELDS. and then use my logic.
2013 Aug 01 12:26 PM
Hi Shree,
Create an internal table where you can save values of third field.
Loop at your internal table and in each loop append the third field to the new internal table.
After appending sort the new internal table.
Inside the same Loop read the new internal table with third field value to check whether any record has the same value in second field.
If found delete the record.
Regards,
Vinay Mutt
2013 Aug 01 3:23 PM
Hello,
use the following
Make a copy of IT_final with data.(IT_final_cpy)
then
loop at IT_final into Is_final.
read table IT_final_cpy into Is_final_cpy with key field2 = ls_final-Field2.
if sy-subrc = 0.
delete IT_final_cpy index sy-tabix.
else.
read table IT_final_cpy into Is_final_cpy with key field3 = ls_final-Field2.
if sy-subrc = 0.
delete IT_final_cpy index sy-tabix.
else.
read table IT_final_cpy into Is_final_cpy with key field3 = ls_final-Field3.
if sy-subrc = 0.
delete IT_final_cpy index sy-tabix.
endif.
endif.
endif.
IT_final_cpy have correct data you want.
BR
Chandra...