‎2011 Oct 05 5:59 AM
Hi All,
In my module pool program I have a table, in the table entry field the user should not enter same entry in second time. If user enter wrongly same entry second time the error message should come.
Please guide me on this.
Regards,
Krish......
‎2011 Oct 05 11:25 AM
Hi,
in PAI
Loop at itab.
field itab-field1 check_duplicate on request. " This should be on REQUEST only so that first entry is ignored at the loop pass
module modify_tc.
endloop.
in program
module check_duplicate.
read table itab with key field1 = itab-field1.
if sy-subrc = 0.
message ' This Values is already entered' type 'E' " Or you can use ITAB as SORTED TABLE which does not allow
" Duplicate entries
endmodule.
module modify_tc.
describe table itab lines tc-lines.
if tc-current_line > tc-lines.
append itab.
endif.
endmodule.For more info go through F1 help on SORTED TABLE here you should not use APPEND key word instead use INSERT key word
Cheerz
Ramchander Rao.K
‎2011 Oct 05 6:08 AM
dear krish
For that porpuse use check on the screen like perform check....
first check for whether this is correct entry or not by select statement on table then check the entry was not exit in table where you have to insert the data.........
regards
Ajit
‎2011 Oct 05 7:29 AM
hI,
Try this
Select field into (itab-fieldd)
from table tablename
where condition.
loop at itab.
if field = itab-field.
message 'error' type 'e'.
endif.
endloop.
Regards,
koolspy.
‎2011 Oct 05 9:44 AM
‎2011 Oct 05 11:25 AM
Hi,
in PAI
Loop at itab.
field itab-field1 check_duplicate on request. " This should be on REQUEST only so that first entry is ignored at the loop pass
module modify_tc.
endloop.
in program
module check_duplicate.
read table itab with key field1 = itab-field1.
if sy-subrc = 0.
message ' This Values is already entered' type 'E' " Or you can use ITAB as SORTED TABLE which does not allow
" Duplicate entries
endmodule.
module modify_tc.
describe table itab lines tc-lines.
if tc-current_line > tc-lines.
append itab.
endif.
endmodule.For more info go through F1 help on SORTED TABLE here you should not use APPEND key word instead use INSERT key word
Cheerz
Ramchander Rao.K
‎2011 Oct 05 1:47 PM
in PAI..
PROCESS AFTER INPUT.
....
....
MODULE CHECK_DUPLICATE.MODULE CHECK_DUPLICATE INPUT.
DATA wa TYPE <table_name>.
SELECT SINGLE * FROM <table_name>
INTO wa WHERE <give condition>.
IF SY-SUBRC = 0.
MESSAGE 'Record Already Exists' TYPE 'E'.
RETURN.
ENDIF.
ENDMODULE.