09-12-2008 5:12 AM
hi all
pl review following code
SORT i_pri BY part_nbr mfgng_duns_nbr.
LOOP AT i_pri INTO i_pri5.
IF sy-subrc = 0.
IF i_pri5-part_nbr = wa_pri_dup-part_nbr AND
i_pri5-mfgng_duns_nbr = wa_pri_dup-mfgng_duns_nbr.
i_pri5-status = 'D'.
i_pri5-error_text = 'Duplicate Record'.
modify i_pri FROM i_pri5.
ENDIF.
wa_pri_dup = i_pri5.
ENDIF.
ENDLOOP.
in the above code i am trying to find duplicate records.
code is showing all duplicate records as status D including first duplicate record. what i want is if there are 3 duplicate records then first record should not have status D where are other should have status D.
record1 status ' '
record2 status 'D'
record3 status 'D'.
is my requirement
is there any solution for this problem?
please help
thanx
rocky
09-12-2008 5:21 AM
Hi,
Use a flag to over come your problem, i have modified the pasted code to your requirement, please find that below.
data: v_flag type i.
SORT i_pri BY part_nbr mfgng_duns_nbr.
LOOP AT i_pri INTO i_pri5.
IF sy-subrc = 0.
CLEAR V_FLAG.
ON CHANGE OF part_nbr mfgng_duns_nbr.
IF i_pri5-part_nbr = wa_pri_dup-part_nbr AND
i_pri5-mfgng_duns_nbr = wa_pri_dup-mfgng_duns_nbr.
v_flag = v_flag + 1.
if v_flag GT 1.
i_pri5-status = 'D'.
i_pri5-error_text = 'Duplicate Record'.
modify i_pri FROM i_pri5.
ENDIF.
ENDIF.
ENDON.
wa_pri_dup = i_pri5.
ENDIF.
ENDLOOP.
With best wishes,
Murthy.
09-12-2008 5:23 AM
how you are telling that there are duplicates( based on some fields, you can treat them as keys)
sort the tabble with those keys and modify the records.
using at new you can modify only the first record.
loop at itab.
at new keyfield.
itab-status = ''.
modify itab transporting status.
endat.
endloop.