Maintenance view event for checking if field is initial or not

18,775

Solution 1

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

Solution 2

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.

Share:
18,775

Related videos on Youtube

Eva Dias
Author by

Eva Dias

:)facebook

Updated on June 18, 2022

Comments

  • Eva Dias
    Eva Dias almost 2 years

    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.

    • vwegert
      vwegert
      Please edit the 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.
  • Eva Dias
    Eva Dias over 11 years
    Thank you, that works too and it's even more elegante than the one that I achieved.
  • vwegert
    vwegert over 11 years
    From my point of view, that's an inferior approach: You lose the option to highlight the fields that contain the invalid values. Imagine a table with thousands of lines - you'd have to search for the invalid entries for yourself. That's a bad way to fly.
  • tomdemuyt
    tomdemuyt over 11 years
    @vwegert, this only applies to new entries, there are not thousands of lines when you click 'Add new entries' in SM30, all existing entries are hidden.
  • vwegert
    vwegert over 11 years
    @tomdemuyt, so it's not allowed to enter the value FOO when adding an entry, but you can add an entry with the new value BAR and then change it to the forbidden value FOO? That makes even less sense to me.