You are on page 1of 6

EVENTS IN TABLE MAINTENANCE - ABAP 开发 (ABAP Develop... http://wiki.scn.sap.com/wiki/display/ABAPch/EVENTS+IN+TABLE...

Getting Started Newsletters Store

Welcome, Guest Login Register Search the Community

ABAP 开发 (ABAP Development) / ABAP开发百科

EVENTS IN TABLE MAINTENANCE


Created by Guest, last modified by HARI PRASADA REDDY MERUGU on Sep 19, 2013

Link to Content's target Space :


 Useful Information
Short quick summary to catch the reader's
http://wiki.sdn.sap.com/wiki/
attention and of course the search engine

Applies to:
SAP ECC 6.0.

Summary
This document provides 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.

Author(s): Sumit Joshi

Company: L&T InfoTech


Created on: 30 June 2010
Author(s) Bio
Sumit Joshi is a software engineer working with L&T InfoTech for the past one year as an ABAP developer.

Table of Contents
Link to Content's target Space :
Applies to:
Summary
Author(s): Sumit Joshi
Validation on table maintenance
Event Handling
Create a table ZTAB with the following fields:
Create a table maintenance generator for the table:
Create Events for table Maintenance:
Create Transaction Code:
Execute the transaction code:
Related Content

Validation on table maintenance


While creating the tables, sometimes we may need to update the table fields in the background. For example, if we create a table with 10
fields and in those 10 fields there are 2 fields which are User name and the Date, these 2 fields should update automatically when a record
Inserted/Updated in the table. It also can be used when we want provide various validations on creating, changing or saving entries in a table.

Event Handling
When we provide event handling on table maintenance, table fields will be updated automatically when a new record inserted into the table or
an existed record changes through the table maintenance generator.

To achieve the event handling in table maintenance, we need to create a table maintenance generator and then create events. Process is as
follows:

Create a table ZTAB with the following fields:

1 de 6 04/11/2015 11:22
EVENTS IN TABLE MAINTENANCE - ABAP 开发 (ABAP Develop... http://wiki.scn.sap.com/wiki/display/ABAPch/EVENTS+IN+TABLE...

Create a table maintenance generator for the table:


To create table maintenance generator go Utilities -> Table Maintenance Generator and provide following information:

Authorization Group: &NC&

Function group: Any suitable FC Eg: ZBC420XX

Maintenance type: Two Step

Maint. screen no: Overview screen 8005

Single screen 8006

Click on Create.

Create Events for table Maintenance:


To create events on table maintenance go to Environment -> Modification -> Events -> New Entries

2 de 6 04/11/2015 11:22
EVENTS IN TABLE MAINTENANCE - ABAP 开发 (ABAP Develop... http://wiki.scn.sap.com/wiki/display/ABAPch/EVENTS+IN+TABLE...

List of events available:

Choose maintenance event 05-Creating New Entry and provide a name of the event (This will become perform/subroutine).

Click on Editor Button to provide event handling code.

A popup will be appear, It will ask to create an include program, in which we'll write the event handling code.
Click on continue.

Write the following code in include for this event.

FORM new_entry.
DATA: v_nchar TYPE i.

3 de 6 04/11/2015 11:22
EVENTS IN TABLE MAINTENANCE - ABAP 开发 (ABAP Develop... http://wiki.scn.sap.com/wiki/display/ABAPch/EVENTS+IN+TABLE...

CONSTANTS: c_conlimit TYPE i VALUE 3.

ztab-changed_by = sy-uname. " current user


ztab-create_date = sy-datum. " current date
ztab-create_time = sy-uzeit. " current time

* Validation on Country Field


v_nchar = STRLEN( ztab-country ).
IF v_nchar NE c_conlimit.
MESSAGE i536.
ENDIF.
ENDFORM. "New_Entry

Create Transaction Code:


Create a transaction code to run the table maintenance generator.
Go to Tcode SE93
Transaction code: ZTAB
Short text: Test Table Maintenance Events
Start Object: Transaction with parameters (Parameter Transaction)

Transaction: SM30
Skip first Screen: Check ON
Default Values:
View Name ZTAB
Update X

Execute the transaction code:


Execute the transaction code ZTAB and click on New Entries button.

4 de 6 04/11/2015 11:22
EVENTS IN TABLE MAINTENANCE - ABAP 开发 (ABAP Develop... http://wiki.scn.sap.com/wiki/display/ABAPch/EVENTS+IN+TABLE...

Now provide a valid value in country field and remain blank another fields.

Click Enter (NEW_ENTRY event will trigger) and current User, date and time will be automatically filled in respective fields.

Save the entry and check in table.

One more entry by table maintenance:


Write country code as US in place of USA and press Enter
Information message shown that entry was not saved.

5 de 6 04/11/2015 11:22
EVENTS IN TABLE MAINTENANCE - ABAP 开发 (ABAP Develop... http://wiki.scn.sap.com/wiki/display/ABAPch/EVENTS+IN+TABLE...

Now provide USA as country code and save entry.

Related Content
Please include at least three references to SDN documents or web pages.
Reference 1

Reference 2

Reference 3

Need some more information.


standard template document paper article

3 Comments
Saifur Rahaman
Very Useful content

carmen guerrero
Hello.

I have the requirement :

http://forums.sdn.sap.com/thread.jspa?messageID=9968428&#9968428

How can solve my issue.

Regards

Carmen

Guest
Hi Sumit,

I also tried the same and it is working fine. I have an issue with the same. When you regenerate the view, the subroutine is getting deleted and the program dumps. Any idea how to keep the
validation on the field even after regeneration?

Regards,

Vignesh.S

Contact Us SAP Help Portal


Follow SCN
Privacy Terms of Use Legal Disclosure Copyright

6 de 6 04/11/2015 11:22

You might also like