Thursday, 13 December 2012

Table Maintenance Generation Events

INTRODUCTION

Table maintenance generation events can help us to perform validations while creating new entries in a table or hiding the fields or assigning default values to table fields.
There are large number of events present which can be used for such purposes.Some of them are :


01  Before saving the data in the database
02  After saving the data in the database
03  Before deleting the data displayed
04  After deleting the data displayed
05  Creating a new entry


15  Before retrieving deleted entries
16  After retrieving deleted entries

21  Fill hidden fields 

In total there are 39 events provided by SAP.

HOW TO USE THESE EVENTS?

Now we will learn how to use these events in some simple steps:

1. Create a table in SE11.
2. Go to Utilities ->Table Maintenance Generator -> Fill Required data of this Screen -> Environment -> Modification -> Events.
3. Select the event.
4. Give the form name and click on the editor icon.
5. Select the include to place your form definition.
6. Within the form write your code . Save and Activate.
7. Now just go to SM35 to maintain your table to witness the events trigger.

EXAMPLE 

Table : Let us take a simple table having fields as employee id  ,  employee name and date on which  entry created.

Requirement : The employee name and date should get automatically populated while creating a new entry.

Table Name : ZTEST_EVENTS

Fields :                           Type 
ZEMPID                        NUMC
ZNAME                        CHAR
ZDATE                          DATS

Now create the Table Maintenance Generator.

Select Event :  05  Creating a new entry.

Give the form name as : CREATE_ENTRY and write the following code.

FORM create_entry.
ztest_events-zname = sy-uname.
ztest-events-zdate   = sy-datum.
ENDFORM.

Save and Activate.

Now if we go to maintain the table and leave name and date as blank , we will see that they are automatically created.

Hence , In this way events can be used.



2 comments:

  1. hello sir u r doing well but i want FAQ's for 3.5 years of experence in sap abap&webdynpro(ale,oops is very need for me) if it is possiable plz post those things

    ReplyDelete
    Replies
    1. Thanks for your feedback !! We will definitely come up with posts on FAQs and ABAP OOPS.

      Delete