Dear Deborah,
Please use event 05, which gets triggered when you hit enter in SM30.
Loop over <total> internal table and for the new record, <action> will be equal to 'N' and then u can compare the new record with the rest of <total> table data with a read statement and if u find another record which has the same 3rd, 4th & 5th, then just raise an error with message statement and your validation will work and mark vim_abort_saving = 'X'.
Working Code Sample :-
types begin of ty_tab. types ffc type char4." First 4 characters include type <table_name>. types end of ty_tab. data : it_new_tab type standard table of ty_tab, it_tab type standard table of <table_name>, wa_tab like line of it_tab, wa_new_tab like line of it_new_tab. data : r_ffc type range of char4, r_ffc_line like line of r_ffc. loop at total. if <action> eq 'N'. wa_new_tab-ffc = total+5(4). wa_new_tab-amsmind = total+3(1). wa_new_tab-amspind = total+4(1). wa_new_tab-value = total+5(15). append wa_new_tab to it_new_tab. endif. wa_tab-amsmind = total+3(1). wa_tab-amspind = total+4(1). wa_tab-value = total+5(15). append wa_tab to it_tab. if wa_tab-amsmind = 'B' and wa_tab-amspind = 'P'. r_ffc_line-sign = 'I'. r_ffc_line-option = 'EQ'. r_ffc_line-low = total+5(4). append r_ffc_line to r_ffc. endif. endloop. clear wa_new_tab. * Single Entry wa_new_tab-ffc = zams_param_table+5(4). wa_new_tab-amsmind = zams_param_table+3(1). wa_new_tab-amspind = zams_param_table+4(1). wa_new_tab-value = zams_param_table+5(15). append wa_new_tab to it_new_tab. if wa_new_tab-amsmind = 'B' and wa_new_tab-amspind = 'P'. r_ffc_line-sign = 'I'. r_ffc_line-option = 'EQ'. r_ffc_line-low = total+5(4). append r_ffc_line to r_ffc. endif. delete it_new_tab where amsmind ne 'B' or amspind ne 'I'. loop at it_new_tab into wa_new_tab. if wa_new_tab-ffc not in r_ffc or r_ffc is initial. message e000(zams) with wa_new_tab-value ' - Initial 4 characters for this'(006) 'material not maintained as a Material pattern'(007). vim_abort_saving = 'X'. exit. endif. endloop.
Regards,
Aashrith.