Tuesday, April 19, 2011

TO IMPLEMENT EVENTS IN TABLE MAINTENANCE

This document gives a detailed description on how to implement the table maintenance events which is very helpful while creating new entries in a table. Many validations and checks can be performed while creating or saving entries in a table.
Let us consider a scenario, where a custom table has to be updated with the created/modified date and time.
The steps for implementing the same are given below:
Step1: Create a table ZTAB with the following fields:

Step 2: Create a TABLE MAINTENANCE GENERATOR FOR THE TABLE
Utilities-> Table Maintenance Generator.
Authorization Group: &NC&
Function group: Any suitable FC Eg: ZBC420XX
Maintenance type: Two Step
Maint. screen no: Overview screen 8005
Single screen 8006

Step 3: Create table Maintenance Events
Table Maintenance Environment->Modification->Events-> New Entries

List of events available:
Select 05 for an event for “Creating a new entry”.
This event will be triggered while creating a new entry in SM30 or using the TCODE.
Form Name: AT_NEWENTRY (Enter key)
Double Click on the editor.
form at_newentry.
Ztab-ZCOUNTRY = ‘India’.
Ztab-ZCREATEDATE = sy-datum.
Ztab-ZCREATETIME = sy-uzeit.

endform.
Create another event: 02 for “After Save”
FORM after_save.
Ztab-mandt = extract+0(3).
Ztab-ZCOUNTRY = extract+3(3)..
Ztab-ZCREATEDATE = sy-datum.
Ztab-ZCREATETIME = sy-uzeit.
MODIFY ztab.
ENDFORM. "after_save
Step 4: Create Transaction Code.
Go to SE93.
Transcation code: ZTAB
Transaction text Test Table Maintenance Events
Transaction: SM30, Skip first Screen
Default Values:
VIEWNAME ZTAB
UPDATE X
After this when you execute the tcode ZTAB, and create a new entry, it will update the system date and time in the tabel ZTAB.
Moreover if any of the data entries are changed, it will update with the new entries.
All sorts of validations of the entries is also possible through this event creation.


No comments:

Post a Comment