Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need to avoid multiple same entry's in dynpro table

Former Member
0 Likes
569

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......

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
534

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

5 REPLIES 5
Read only

Former Member
0 Likes
534

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

Read only

koolspy_ultimate
Active Contributor
0 Likes
534

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.

Read only

Former Member
0 Likes
534

Are you talking about table control on screen and avoiding duplicate entries there.If yes then refer below thread

Thanks,

Pawan

Read only

Former Member
0 Likes
535

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

Read only

surajarafath
Contributor
0 Likes
534

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.