‎2008 Apr 07 11:12 AM
""""""""""""""""""''''This is my PAI
loop at lt_zmm_isslip.
chain.
field zmm_isslip-matnr.
field zmm_isslip-lgort.
field zmm_isslip-menge_r.
module check_matnr.
module check_str_locand_quantity.
module check_duplicate_entry.
endchain.
module read_table_control_0100.
endloop.
module user_command_0100.
*********
MODULE CHECK_DUPLICATE_ENTRY INPUT.
*check duplicate
read table lt_zmm_isslip into wa_zmm_isslip
with key matnr = zmm_isslip-matnr
werks = zmm_isslip-werks
lgort = zmm_isslip-lgort.
if sy-subrc = 0.
Message 'Duplicate entry' type 'E'.
clear : lt_zmm_isslip.
refresh : lt_zmm_isslip.
endif.
endmodule.
I wish to check duplicate values if user has already enter the same value it should say duplicate entry.
This concept is not working properly.It is showing 1st entered record as duplicate.But it shold say 2 nd entered record is duplicate.
Please suggest.
Thanks in advance
‎2008 Apr 07 12:13 PM
Hello Abut,
I can see from the Code provided by you that the Current selction of the Table is not taken in to consideration for Validation
LOOP AT t_cost INTO e_cost
WITH CONTROL tc_cost
CURSOR tc_cost-current_line.
Before Validation we need to capture the Current line selection
You can have another Module in the Loop to get the current line selection and then in the Module for Duplicate_enter check that current line against the existing enteries in the table.
Delcaration:
Controls :
tc_item TYPE TABLEVIEW USING SCREEN 2000.
Data : w_lin TYPE i,
w_lin = tc_item-current_line .
The table control has got the field called Current_line thru which we can get the current Selection.
Regards
Usha
‎2008 Apr 07 11:58 AM
hey dear.. to restrict duplicate entries in the table simply define the table as sorted by unique id.
or even u can use apend statment instead of insert so as to omit th duplicate entries
<REMOVED BY MODERATOR>
tnks and regards,
Anoop Gupta
Edited by: Alvaro Tejada Galindo on Apr 7, 2008 5:27 PM
‎2008 Apr 07 12:23 PM
One of the ways of pointing out the current entry as duplicate is as follows:
1) Move the current contents of internal table to another internal table.
2) Delete the entry at index SY_STEPL from the new internal table. As a result, the new internal table contains all the records except the current record.
3) Check this new iternal table with the entry made at this step. If any record is found, it implies that it is a duplicate. then throw an erro at the current step usig original table control.
‎2008 Apr 07 12:13 PM
Hello Abut,
I can see from the Code provided by you that the Current selction of the Table is not taken in to consideration for Validation
LOOP AT t_cost INTO e_cost
WITH CONTROL tc_cost
CURSOR tc_cost-current_line.
Before Validation we need to capture the Current line selection
You can have another Module in the Loop to get the current line selection and then in the Module for Duplicate_enter check that current line against the existing enteries in the table.
Delcaration:
Controls :
tc_item TYPE TABLEVIEW USING SCREEN 2000.
Data : w_lin TYPE i,
w_lin = tc_item-current_line .
The table control has got the field called Current_line thru which we can get the current Selection.
Regards
Usha
‎2008 Apr 07 12:17 PM
Hi,
Use this,
Tables: mara.
loop at lt_zmm_isslip.
chain.
field zmm_isslip-matnr.
field zmm_isslip-lgort.
field zmm_isslip-menge_r.
module check_matnr.
module check_str_locand_quantity.
module check_duplicate_entry.
endchain.
module read_table_control_0100.
endloop.
module user_command_0100.
*********
MODULE CHECK_DUPLICATE_ENTRY INPUT.
*check duplicate
*read table lt_zmm_isslip into wa_zmm_isslip
*with key matnr = zmm_isslip-matnr
*werks = zmm_isslip-werks
*lgort = zmm_isslip-lgort.
select single * from mara where
matnr = zmm_isslip-matnr.
if sy-subrc = 0.
Message 'Duplicate entry' type 'E'.
clear : lt_zmm_isslip.
refresh : lt_zmm_isslip.
endif.
Regards,
Brown.
endmodule.
‎2008 Apr 07 12:52 PM
Try like this
MODULE CHECK_DUPLICATE_ENTRY INPUT.
loop at lt_zmm_isslip into wa_zmm_isslip.
If wa_zmm_isslip-matnr = zmm_isslip-matnr
and wa_zmm_isslip-werks = zmm_isslip-werks
and wa_zmm_isslip-lgort = zmm_isslip-lgort.
if sy-tabix ne <TBCTRL>-current_line.
Message 'Duplicate entry' type 'E'.
clear : lt_zmm_isslip.
refresh : lt_zmm_isslip.
endif.
endif.
endmodule.
Here <TBCTRL> is the name of your table control.