Skip to Content
Author's profile photo Kiran Kerudi

Validate data in Table Maintenance Generator event

The TMG event 01: Before Save., can be used instead of going for event 05: New Entry if you have validation process to do.

The problem with event 05 is that, control goes into the include/form only on the newly created entries. So, if you have you had to change any existing data, the control will not pass through the validation code !!

Here is a piece of code that you can use for your development purpose.


  • <action> is a flag that will have values as ‘N’ if a new entry is made or as ‘U’ if existing entry is modified.
  • <vim_total_struc> is a structure that holds the current looped value on TOTAL table.
  • it_total_zdata, internal table should be of type table z-table.

LOOP AT total.

  IF <action> EQ ‘N’ OR <action> EQ ‘U’.

    APPEND <vim_total_struc> TO it_total_zdata.



IF it_total_zdata[] IS NOT INITIAL.

* Perform validation

    LOOP AT it_total_zdata.

      IF it_total_zdata-name NE ‘TESTNAME’.


        vim_abort_saving = c_abrt_save.

        sysubrc = 4.






  • Message should be of type ‘S’. If not, the screen returns to SM30, which looks bad !! Make sure its displayed either as ‘Error’ or ‘Warning’.
  • vim_abort_saving has to be set to ‘X’ to avoid data being saved. (Since the message popped is of type ‘S’, control proceeds further!!)
  • Set sy-subrc as ‘4’ which stops further processing.

The above points are mandatory, if you want a message to be popped and wrong data still to be seen giving an opportunity to the user to rectify.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Good πŸ™‚

      Author's profile photo Kiran Kerudi
      Kiran Kerudi
      Blog Post Author

      Thanks Gilbert πŸ™‚

      Author's profile photo Former Member
      Former Member


      Author's profile photo Kiran Kerudi
      Kiran Kerudi
      Blog Post Author

      Özgün, You're welcome πŸ™‚

      Author's profile photo Former Member
      Former Member

      Hi Kiran,

      Great post!! Short and precise!

      I was looking for info and found a lot of forum posts, but some of them proposed modify the pai of the auto generated dynpro or create a program to call a fm that opened the table (like sm30).

      Your post was key to my success, especially the vim_abort_save and the issue with total and the field symbol of the structure.

      I didn't fill the z internal table, but passed the field symbol in the loop to a structure like my z table and right there I did the validations

      Thanks a lot!

      Author's profile photo Kiran Kerudi
      Kiran Kerudi
      Blog Post Author

      Hi Jose,

      Thanks! Hope it could help πŸ™‚



      Author's profile photo Richard Harper
      Richard Harper

      How about using domains and foreign keys to validate your entry ?

      Author's profile photo Nirmal Kumar Jain S S
      Nirmal Kumar Jain S S

      ThanksΒ  a lot!!! your suggestion is worked for me πŸ™‚



      Author's profile photo Matias Miranda
      Matias Miranda

      Thank you very much!! I was wondering how to implement this kind of validations. It's works great!

      Author's profile photo Pallavi Priya
      Pallavi Priya

      Hi, thanks for your post. However, when I implemented the above code, it's displaying the error message but still saving the invalid entry. Are you able to advise on how to avoid saving the invalid entry ?


      Author's profile photo vishal agrawal
      vishal agrawal

      Thank you Kiran.

      I think I have been looking for this code from ever since I remember.

      Thank you very much.




      Vishal Agrawal