sapdev logo background
sapdev logo sapdev logo

Modify your SAP database table maintenance events, screen, interface and code

Once you have created your basic SAP database table and then added a standard table maintenence to it you may find that you want to change the functionality of it slightly. I.e. you may want to display a message when the data is saved or prevent users from saving certain combinations of data.

Step 1 - Modification options
SAP provides standard functionality for this purpose and is within the table maintenance create/change screen. Just to re-cap how to get to this, execute transaction SE11, enter your table name and press the change button. Within the next SE11 screen goto the menu option 'Utilities->Table Maintenance Generator'. The modifiction options are then within the menu option 'Environment->Modification'. Here you will see that you can modify the screens, interface, events and source code. For this example I am going to show you how to modify and event, the SAVE event to be specific. So when the user presses the save button with t-code SM30 for this table it will process this additional functionality automatically.

Step 2 - Access the event modification screen
Select the menu option Environment->Modification->Events, you will see the following screen which will show the list of events that have been modified. It should be blank as this is the first time in.

Step 3 - Create event modification
Click on the New entries button and use the F4 dropdown help on the first field to select the event you want to modify. You will see that there is quite a few that you can use such as before save, after save, before delete, when creating an entry etc... Select 01 (Before saving the data in the database).

Enter 'SAVE_DATA' as the form name for your event modification and press enter. Note you can give this any name you want.

You should also notice that you get an editor button in the third column, click this. You will then be asked to choose an existing include or create a new one for your code. Just keep the default as 'New Include' and press the green tick. Also click ok on the warning screen about an include statement being inserted.

Step 4 - Add code to event modification
You will now be presented with a blank include page where you can add the code for your event.

Its now time to add your ABAP code but remember you also need to add the FORM...ENDFORM code to match the form you endered on the modification screen i.e. SAVE_DATA

In this example I am simply going to display a message with some text and the value stored in field1 using the following ABAP code. I have tried to use a message class and number that should be in your system but if you have any problems use a message class you know exists in your system.

  message i899(H1) with 'Data has been saved' ztest_table-field1.

Step 5 - Save and Activate
Save and activate your include, then use the back button to return to the event modification screen and save that.

Step 6 - Execute
Now go to the table maintenace via SM30, change an entry in the table and press save. You should see you new message appear.

Create Table Maintenance
Add maintenance functionality
Create basic SAP table
Step by step guide for table creation

comments powered by Disqus