‎2008 Jul 24 11:28 PM
Hi,
I am using chain...endchain for 8 fields to validate duplicate entries.
It is giving an error message when there is a duplicate entry and allows me to delete the entry, but the error message still appears as the value still remains in the internal table that i use for validation.
The message continues to appear until i delete enties in all the 8 fields, and i am not able to enter the value which has been once used and deleted.
here is the example code that i used to validate:
IF it_parvw IS NOT INITIAL.
CLEAR: lv_count1.
LOOP AT it_parvw INTO wa_parvw WHERE parvw EQ vbak-zzparvw1.
lv_count1 = lv_count1 + 1.
IF lv_count1 GT 2.
MESSAGE 'Duplicate Partner Types entered' TYPE 'E'.
ENDIF.
ENDLOOP.
CLEAR: lv_count2.
LOOP AT it_parvw INTO wa_parvw WHERE parvw EQ vbak-zzparvw2.
lv_count2 = lv_count2 + 1.
IF lv_count2 GT 2.
MESSAGE 'Duplicate Partner Types entered' TYPE 'E'.
ENDIF.
ENDLOOP.
CLEAR: lv_count3.
LOOP AT it_parvw INTO wa_parvw WHERE parvw EQ vbak-zzparvw3.
lv_count3 = lv_count3 + 1.
IF lv_count3 GT 2.
MESSAGE 'Duplicate Partner Types entered' TYPE 'E'.
ENDIF.
ENDLOOP.
CLEAR: lv_count4.
LOOP AT it_parvw INTO wa_parvw WHERE parvw EQ vbak-zzparvw4.
lv_count4 = lv_count4 + 1.
IF lv_count4 GT 2.
MESSAGE 'Duplicate Partner Types entered' TYPE 'E'.
ENDIF.
ENDLOOP.
CLEAR: lv_count.
LOOP AT it_parvw INTO wa_parvw WHERE parvw EQ vbak-zzparvw5.
lv_count = lv_count + 1.
IF lv_count GT 2.
MESSAGE 'Duplicate Partner Types entered' TYPE 'E'.
ENDIF.
ENDLOOP.
CLEAR: lv_count.
LOOP AT it_parvw INTO wa_parvw WHERE parvw EQ vbak-zzparvw6.
lv_count = lv_count + 1.
IF lv_count GT 2.
MESSAGE 'Duplicate Partner Types entered' TYPE 'E'.
ENDIF.
ENDLOOP.
CLEAR: lv_count.
LOOP AT it_parvw INTO wa_parvw WHERE parvw EQ vbak-zzparvw7.
lv_count = lv_count + 1.
IF lv_count GT 2.
MESSAGE 'Duplicate Partner Types entered' TYPE 'E'.
ENDIF.
ENDLOOP.
CLEAR: lv_count.
LOOP AT it_parvw INTO wa_parvw WHERE parvw EQ vbak-zzparvw8.
lv_count = lv_count + 1.
IF lv_count GT 2.
MESSAGE 'Duplicate Partner Types entered' TYPE 'E'.
ENDIF.
ENDLOOP.
ENDIF.
Please let me know how to solve this problem.
Thanks.
‎2008 Jul 25 7:35 AM
Hi,
From where u delete entries DATABASE Table or internal table
Thanx
‎2008 Jul 25 8:04 AM
Loop at itab.
chain f1
f2 .....f8
module check_dupliacates.
endchain.
endloop.
I believe as soon as you enter some data in any of these fields of internal table and hit enter you have to validate for duplicacy.
module check_dupliactes.
temp[] = itab[].
Delete the current line from the temporary table
delete temp index sy-stepl.
Read the temporary table for matching partner type. If
*an entry is found in internal table then it's a duplicate *otherwise proceed with it
read table itemp withkey ...
end module.
reward if useful.
‎2008 Jul 25 3:05 PM
Hi,
Thanks for the idea.
I tried it but it is giving a dump in runtime at the delete temp statement as sy-stepl is always showing 0.
Could you pls help me?