In SAP ABAP, a TMG (Table Maintenance Generator) is used to create a standard maintenance screen for a table (so that users can create, update, or delete table entries easily).
Now, TMG Events are hooks (user-exits) provided by SAP within the Table Maintenance Generator. They let you insert custom logic during specific points of table maintenance processing — without modifying SAP standard code.
Uses of TMG Events
- To perform validations before saving data.
- To default values when creating new entries.
- To restrict or control user actions (e.g., prevent deletion of certain entries).
- To update dependent tables automatically when the main table is changed.
- To call function modules, BAPIs, or custom programs at certain points in the table maintenance cycle.
How TMG Events Work
When you create a TMG for a table (via SE11 → Utilities → Table Maintenance Generator), SAP provides a list of predefined events (like “before saving the data”, “after saving”, “before deleting”, etc.).
Each event corresponds to a FORM routine in an include program (L<tablename>F01
), where you can write your custom ABAP code.
Examples of TMG Events
Some commonly used events:
- 01 – Before saving the data in the database
→ Use to validate entries or prevent saving if conditions aren’t met. - 02 – After saving the data in the database
→ Useful to update dependent/custom tables. - 05 – Creating a new entry
→ Can default field values. - 21 – Before deleting an entry
→ Prevent deletion of critical data (e.g., master records in use).
Example Scenario:
Suppose you have a ZCUSTOMER_CONFIG table maintained via TMG.
- If the user enters an invalid plant code, you can use Event 01 (Before saving) to check the plant in
T001W
. If invalid → show error and prevent saving. - If a new record is created, use Event 05 to default the “Created By” and “Created On” fields automatically.