Maintenance view event for checking if field is initial or not

21.6k views Asked by At

I'm trying to check if a field is leaved initial or not in sm30 with a table that I've made. I've gone to table maintenance generator, then Environment->Modifications->Events and made an entrance named check_class with type 01 (before saving the data in the database) with the following code:

FORM CHECK_CLASS.

IF z10ficlassfica-z_class IS INITIAL.
  MESSAGE text-001 TYPE 'E'.
ENDIF.

ENDFORM.

It works all fine except that when z10ficlassfica is initial it doesn't stay in the maintenance of the table and goes to the sm30 first screen. How can I make it stay on the maintenance screen of sm30? Hope I've made myself clear. Thank you.

2

There are 2 answers

4
tomdemuyt On BEST ANSWER

please see this link :

  • You can use events, and should use them, dont go modify generated screens, that is why SAP provided events.
  • You just need 2 things to stop saving and stay on screen
    • MESSAGE 'Currency must be USD or IDR' TYPE 'S' DISPLAY LIKE 'E'.
    • vim_abort_saving = 'X'.
  • Read that link, there is a lot of information you need in there.
  • As a good practice, use the key of the record that went wrong in the error message, so the user can find the record back when entering thousands of new records
0
vwegert On

Please edit your original question instead adding another one. I've answered the question there already: Do not use an event, but modify the generated screen. Events are unsuitable here because you have to raise the MESSAGE within the screen LOOP statement.