Skip to Content
0
Former Member
Aug 09, 2011 at 06:01 AM

Invalid entry gets saved after message in Event 01 of Table maintenance

1854 Views

Hi All,

Want to validate a custom table entry when its new or updated in Maintennace view. In case if invalid throw message and dont save. For this created a form in event 01 (Check before save).

Its working and geeting message but after that entry got saved. Explored on SDN and tried all the suggestions related to sy-subrc, vim_abort_saving , after loop also set sy-subrc = 4, put a check condition so that code exit from the logic but nothing seems to be working.

As suggested by many copied this code in event 21 also but same behaviour.

code is as following

types: begin of ty_s_total.

include type zmara.

types: action,

mark,

end of ty_s_total.

data: ls_total type ty_s_total,

ls_extract type ty_s_total,

lv_subrc type sy-subrc,

lv_flag type c value is initial,

lv_matnr type matnr..

field-symbols: <fs_extract> type ty_s_total,

<fs_ltot> type any,

<fs_lext> type any,

<fs_total> type ty_s_total.

loop at total assigning <fs_ltot>.

assign <fs_ltot> to <fs_total> casting.

check <fs_total>-action eq 'N' or <fs_total>-action eq 'U'.

select single matnr from zmara into lv_matnr

where matnr = <fs_total>-matnr.

if sy-subrc = 0.

if lv_matnr is initial.

message s008(M3) with lv_matnr.

vim_abort_saving = 'X'.

lv_subrc = 4.

lv_flag = 'X',

endif.

endif.

check lv_flag ne 'X'.

endloop.

Sy-subrc = lv_subrc.

I know this can be done from PAI by adding conditions in a module. But Want to find out why event is not working and whats required to make it work.

Thanks

pt