Maintenance view event for checking if field is initial or not

Eva Dias picture Eva Dias · Oct 16, 2012 · Viewed 18.9k times · Source

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.

Answer

tomdemuyt picture tomdemuyt · Oct 16, 2012

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