Table Maintenance Generator and its Modifications

Applies to:
SAP ECC (6.0). For more information, visit the ABAP homepage.

Summary
This article contains the procedure of implementation of table maintenance generator for custom tables and also explains some modifications available in the table maintenance generator Author: Nimisha Agarwal

Company: Infosys Technologies Limited Created on: 31 May 2010

Author Bio
Nimisha Agarwal is working with Infosys Technolofies Limited from last 1.5 years. She has got experience in various projects in SAP ABAP.

SAP COMMUNITY NETWORK © 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 1

Table Maintenance Generator and its Modifications

Table of Contents
Introduction ......................................................................................................................................................... 3 Reasons to use Table Maintenance Generator .............................................................................................. 3 Prerequisite to Create Table Maintenance Generator for a Custom Table .................................................... 3 Creation of Table Maintenance Generator for a Custom Table ......................................................................... 4 Maintaining the Table Through SM30 ................................................................................................................ 8 Modifications in Table Maintenance Generator .................................................................................................. 9 Maintenance Screens: .................................................................................................................................... 9 Events ........................................................................................................................................................... 13
Difference Between Event ‘05’ and ‘21’ ..................................................................................................................... 24

Disclaimer and Liability Notice .......................................................................................................................... 25

SAP COMMUNITY NETWORK © 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 2

It is generated to maintain customizing data with these maintenance dialogs. These events get triggered while maintaining the entries in the table.boc. Prerequisite to Create Table Maintenance Generator for a Custom Table While creating the table the table.sap. Therefore.com | BPX . They help in enhancing the functionality of the table maintenance. Various events can be added to the table maintenance generator to maintain the entries. This will help in maintaining the data entries for the table. deleting an entry.sdn. With the help of table maintenance generator.com | BOC . go in tab ‘Delivery and Maintenance’. such as making an entry to that table.’ as shown below. We can check the table maintenance dialog in SM30 or SE16.sap. 3. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap. 1. we should go for table maintenance generator. end-users will not be having access to transaction codes like SE11 and SE16. We have display and maintain options. So in order to edit or create the contents of a database table. Display option is used to view the table contents and maintain option is used to maintain the entries in the table. modify or delete records in the database tables.Table Maintenance Generator and its Modifications Introduction Table Maintenance Generator (TMG) is a tool which is used to create equipment by which customized tables created by end users can be changed as required. modifying an existing entry etc. 2. developers will not be having access to many transaction codes including the above SE11 and SE16. In SM30. Select the option ‘Display/Maintenance allowed’ under ‘Data Browser/Table View Maint.com 3 .uac. Table Maintenance generator can be created using transaction SE54 or SE11. A table maintenance generator is used to create table maintenance program to add. In the production system. we can edit or create multiple entries at a time.sap.com | UAC .bpx. Reasons to use Table Maintenance Generator There are different reasons due to which table maintenance generator is used.

SAP COMMUNITY NETWORK © 2010 SAP AG SDN . Let us take an example of a custom table ZMTABLE to implement the table maintenance generator and its events.sap. Go to Utilities  Table Maintenance Generator.com | UAC . 2.com | BOC .bpx.com | BPX .sap.Table Maintenance Generator and its Modifications Creation of Table Maintenance Generator for a Custom Table Steps: 1.boc.sap.sap.uac.com 4 .sdn.

The following screen would appear to implement the table maintenance generator.sap. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sdn.com | UAC .sap.com | BOC .sap.boc.com 5 .uac.sap.Table Maintenance Generator and its Modifications 3.bpx.com | BPX .

a table has to be maintained by a group of people. maximum field length is four characters. Overview screen would be displayed.  ACTVT . In this case it is auto generated which is S_TABU_DIS have following fields:  DICBERCLS .e.sap. Table/View: the name of the table or view for which table maintenance generator has to be implemented.com | BPX . next screen (single screen) would be displayed. These options are filled according to the given description. one has to give screen number in overview screen only. give the table name for which table maintenance generator is implemented.sap. one has to give the screen number for both overview screen and single screen. Authorization Object: Authorization objects can be created using transaction SU21. including access in customizing Function group: The function group is the one in which all the maintenance modules of the given table or view are generated. To create entries. Here. click on ‘New Entries’.com 6 . It has two different cases:  One step dialog: In this case.e. change or delete table entries. both the screen numbers are required i. the name of the function group can be same as that of table/ view. A function group can also be created in transaction SE80. To create entries. It can have any screen number except 1000 because 1000 is assigned to the selection screen. the overview screen contains only the key fields and texts longer than 20 characters and single screen contains all fields.: Maintenance screen numbers are the internal number for each maintenance screen. A package can be created in transaction SE21 or SPACKAGE.e. SAP COMMUNITY NETWORK © 2010 SAP AG SDN . It controls the access during following transactions:  SM31: Standard maintenance tool  SM30: Enhanced table maintenance  SE16: Data browser. You can enter one record at a time.  Two step dialog: In this case. It works as follows: Go to SM30. Maintenance Type: There are two maintenance types:  One step dialog: One step dialogs only have one maintenance screen (overview screen) containing all the fields i.Authorization group.com | BOC .sap. Enter the values and save the data. Authorization groups for a table/ view can be created using transaction SE54.uac. Authorization Group: Authorization group is used to apply authorization checks to a particular group of people i.Table Maintenance Generator and its Modifications The following are the options available in the screen. All the entries in overview screen are displayed in the form of lists. Single screen can be called from overview screen by function key. 03: Only display table contents). to specify the users who are authorized to maintain table or view contents.  Two step dialog: Two step dialogs have one additional maintenance screen (single screen) along with overview screen. Now. Function group names can have maximum of 26 alphanumeric characters. It works as follows: Go to SM30.Activity (02: Add.com | UAC . A user has to pass the check for every field to run the authorization check successfully.bpx.boc. S_TABU_DIS is used for displaying and maintaining tables. an authorization group is assigned else fill the option ‘&NC&’. All the generated maintenance modules will belong to this function group. only overview screen value is required. If in case. Multiple entries can be created using one step dialog.sdn. give the table name for which table maintenance generator is implemented. Overview screen would be displayed. An authorization object can have upto10 authorization fields which are used to verify user authorizations. Maintenance Screen No. for every entry.sap. click on ‘New Entries’. enter the values and save. Package: Package here refers to the function group package which is assigned to the table or view. Here.

sap.uac.Table Maintenance Generator and its Modifications Recording Routine: It gives the option which recording routine should be used to record the changes to table contents. There are two types of recording routines:  Standard routines: More functionality can be added to the standard routines using individual routines. Compare Flag: This flag indicates whether the maintenance transaction allows the (checked) activation of Business Configuration Sets (BC Sets). recording routine: In this case. Then click on ‘Create’.boc. or user.com | UAC .sap. It can be done automatically and manually.sdn. it’s up to the users choice whether he wants the recording or not. The Table Maintenance Generator has been implemented successfully. We can create individual routines via menu function Environment Modification Events. This is the case if the maintenance transaction can run in the background.sap.com | BOC . and the adjustment.bpx.com | BPX .  No. It concerns the events 10. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .com 7 .sap. The following settings are available for the flag:  No Information  Not adjustable  Adjustments in Dialog  Automatically Adjustable All the fields are filled according to the above mentioned description. 11 and 12.

boc.sap. 3. Go to SM30.com | BPX .Table Maintenance Generator and its Modifications Maintaining the Table Through SM30 1.sap.sap. Data would be saved in database successfully. You can click on ‘New Entries’ to make the entries to the table.com | UAC . SAP COMMUNITY NETWORK © 2010 SAP AG SDN .com 8 . 4.com | BOC . The following screen would appear. Enter the values in the following screen and click on ‘Save’.bpx.sdn.uac.sap. give table name and click on ‘Maintain’. 2.

Maintenance events are used. Go to Environment  Modifications  Maintenance Screens SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.bpx. Events: Much functionality can add to the table maintenance though the addition of events. One can define a function group interface by choosing interface to copy and change the original interface.sap. It can be achieved through following procedure: 1.  User Interface: A dialog specific interface can be created using user Interface which can be changed with Menu Painter. Source Code: It displays the function group main program and maintenance dialog top include and also the user defined includes in the ABAP editor. when certain logic is to be added in the already generated table maintenance. It navigates to the screen painter where we can modify the appearance of the screens.sap.Table Maintenance Generator and its Modifications Modifications in Table Maintenance Generator There are different types of modifications available in the table maintenance generator. We can modify the way.sap.boc.   Maintenance Screens: Maintenance screens can be modified so as to enable or disable any of the fields during table maintenance. when user maintains the table through SM30. The message ‘User Interface exists’ in the ‘Maintain Interface assignment’ dialog indicates whether an interface already exists in the current function group. The maintenance dialogs access the standard table/view maintenance interface in the function group SVIM.com | BOC . They are called when certain events are triggered.com | UAC .com | BPX .sdn.uac.com 9 . maintenance screens appears to user through the mentioned option. It means that any of the fields can be made editable or non-editable based on the requirement through modification of maintenance screens. These are as follows:  Maintenance screens: The function group which has been created in the table maintenance Generator contains the code and the maintenance screens.

Click on ‘Element List’ in the screen which appears. 3. uncheck the checkbox of the respective field.bpx.uac. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.boc.sdn.com | BOC .sap.com | BPX . In this case.e.com 10 . we would disable the username field as below.com | UAC .sap. A field can be made disabled by clicking the checkbox of the Input option of that particular field i.Table Maintenance Generator and its Modifications 2.sap. The following screen would appear thereafter.

sap.sap.sdn.com | UAC . The maintenance screen would now appear as follows in transaction SM30.com | BOC . In this ‘User name’ is now disabled.boc.Table Maintenance Generator and its Modifications 4.bpx.sap.com 11 .com | BPX .sap.uac. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .

save and activate the maintenance screen.com | BOC .sap.com 12 . The layout of the appearing screen can also be modified through the screen painter. we can also modify the screen name of a field by changing its parameters.sap. SAP COMMUNITY NETWORK © 2010 SAP AG SDN . The following screen appears: Make the changes.com | BPX .com | UAC .sdn.Table Maintenance Generator and its Modifications 5.uac. It can be achieved via Environment  Modifications  Maintenance Screens  Layout.boc.sap.sap.bpx. Here.

SAP COMMUNITY NETWORK © 2010 SAP AG SDN . The action to be performed by these events can be defined by writing the FORM routine in the ‘Includes’ generated by function group. These events are triggered when a table/view is maintained through transaction SE16 or SM30.Table Maintenance Generator and its Modifications Events Table maintenance generator is used for handling events. Events can be implemented as follows: 1. Many validations. Click on ‘New Entries’ to add events to the table. The following screen appears.com | BPX . Once table maintenance is implemented for a table. These events can be implemented using the table maintenance.com | BOC .sap.sap.sap. The events can be added in table maintenance generator via Environment  Modifications Events 2. Events are used to add custom checks for table maintenance screen generated using the table maintenance generator in SE11.com | UAC .com 13 . There is a list of predefined list of events in SAP.sap.uac.bpx.sdn. checks and functionalities can be performed while maintaining the table entries.boc. events can be handled.

sap.uac.sap. click on F4 help and the following screen of events would appear.sap.com | BPX . In the next screen.sdn.sap.Table Maintenance Generator and its Modifications 3. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .com 14 .com | UAC .boc.bpx.com | BOC .

Before deleting the data displayed This event gets triggered whenever user delete a data i.e.sap.com | UAC . Let us add first event i. before deleting the data displayed.sap.1 The following screen would appear. We can use an already existing include or a new include also.com | BOC .uac.boc.Table Maintenance Generator and its Modifications 4. 4. Give the name of the event in ‘FORM routine’ and click on ‘Editor’.sap. select a record and click on ‘delete’. EVENT 1: 03.sdn.com | BPX .bpx.sap. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .e.com 15 .

In this case.sap.sap. Save and activate the code.boc. both ‘include’ and function group has to be activated.sdn. Please note that FORM and ENDFORM statements have to be added on our own because these statements would appear automatically.sap. Write the following code in the FORM routine.com | BOC .com | UAC .Table Maintenance Generator and its Modifications 4. write the code inside the ‘include’ of function group of the event and activate the ‘include’.uac. Note: Whenever a new ‘include’ is created for a function group. If the function group is not activated.com | BPX . a runtime error is generated while maintaining the table through SM30.bpx. Function group can be activated in transaction SE80. the function group becomes deactivated.sap.2 After selecting the ‘Include’. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .com 16 .

1.bpx.boc. 4.3. select a record and click on delete.com | UAC .com | BOC .3.com 17 . the record would not get deleted. If the user clicks ‘yes’.sap. Go to transaction SM30. first screen would appear without deleting the data.3.3.sap. give the table name and Click on ‘Maintain’. The record would get deleted. Click on ‘Yes’.Table Maintenance Generator and its Modifications 4.sdn. a pop-up would be displayed asking ‘Are you sure to delete the record’.sap.4.3. the record would be deleted and if user clicks ‘No’. A popup would be displayed asking ‘Are you sure to delete the record’. In the subsequent screen. 4. Click on ‘Save’ to save the data.2. The demo has been shown in the below screenshots: 4.uac.2. If the user clicks on ‘No’ in step 4. 4.sap.3 This code would work as: Whenever a record in deleted from ZMTABLE through table maintenance.3. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .com | BPX .

include and function group. EVENT 2: 21.Fill hidden fields This event gets triggered whenever user hits ‘Enter’ key of the keyboard while creating the new entries through table maintenance. Repeat the steps from 1 to 3 and select the 21 event i. We can also generate the values of certain fields automatically on hitting of ‘Enter’ key.com | BPX . st 5.1.bpx.sap. Give a name to the event and click on editor. Select the ‘include’ from the subsequent screen and write the following code in the FORM and ENDFORM statements. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sdn.e.com | UAC . 5.com 18 . fill hidden fields.Table Maintenance Generator and its Modifications 5.com | BOC .sap.boc.sap. Let us add the second event.2. Save and activate the code. We can apply various validation checks in this routine.sap.uac.

 If the USERID field of table is left blank.com 19 .sap. In the subsequent screen.Table Maintenance Generator and its Modifications 5.sdn.sap. an error message would be thrown saying ‘User Id cannot be initial. Please enter a value.com | BOC . The following screen would appear. This code would work as follows: Whenever a user creates new entry in ZMTABLE through table maintenance and hits ‘Enter’ key on the keyboard.sap. its value is auto generated whenever user hits ‘enter’. The demo has been shown below: 5.3. since USERNAME field is an output only field.com | UAC . give the table name and Click on ‘Maintain’. click on ‘New Entries’.uac.sap.bpx. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .’  Secondly. this event would get triggered.com | BPX .boc.1. Go to transaction SM30.3.

an error message appears as follows: 5.bpx. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .Table Maintenance Generator and its Modifications 5.3.com 20 . Since a validation check has been applied to the User Id field.com | BPX . Now enter the user id of the user.sap.sap.uac.3. This screen would appear. Write only ‘Hobbies’ of the user and hit ‘Enter’ key.sdn.com | BOC .boc.2.com | UAC .sap.sap.3.

e.4.3.sdn. he can select an entry from the existing data and create its copy.boc. we can add many more validation checks to enhance the functionality of the table maintenance.uac.sap.com | BOC . The value of User Name would be automatically generated. Give a name to the event and click on editor. Click on save to save the data.com 21 . EVENT 3: 05. Let us add the third event: 6.Table Maintenance Generator and its Modifications 5. In this case. th SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap. creating a new entry.1. This event gets triggered when the user makes a copy of an existing entry. Similarly.com | BPX .bpx.Creating a new entry.sap. 6. Press the ‘Enter’ key now.sap.com | UAC . Repeat the steps from 1 to 3 and select the 5 event i.

com | BOC . This code would work as follows: This code would help the user to create a copy of an existing entry with a different key value.2.com 22 .3. Save and activate the code. give the table name and Click on ‘Maintain’.3.uac.com | UAC .boc. 6.sap. SAP COMMUNITY NETWORK © 2010 SAP AG SDN . In the subsequent screen.1. select an existing entry and click on ‘copy’. This means user can create the same record but with different key values.Table Maintenance Generator and its Modifications 6. Select the ‘include’ from the subsequent screen and write the following code in the FORM and ENDFORM statements.sdn.sap.bpx.sap. Go to transaction SM30.sap. include and function group.com | BPX . The demo of the above code has been shown below: 6.

sap.sap.sdn.2.bpx. Change t he value of User Id and hit ‘Enter’ key.com | BPX . The following screen would appear. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .3.com 23 .3.com | UAC .3.com | BOC . Please note that User name has automatically changed to the system user name.Table Maintenance Generator and its Modifications 6.sap. else an error message would be displayed saying ‘An entry already exists with the same key’.boc. Make sure that the new user id should not be an existing entry. 6. The following screen appears with a message ‘number of entries copied: 1’.sap. Click on ‘Save’ to save the data.uac.

com | BPX . Event 05.sap.Table Maintenance Generator and its Modifications Difference Between Event ‘05’ and ‘21’ The two events i.com 24 . fill hidden fields and creating new entry works on hitting ‘enter’ key of keyboard. only ‘Creating a new Entry’ event gets triggered.sap.sap. The function code for the copy statement is ‘KOPF’.boc. But the difference lies within the function code of the events.com | UAC .Fill Hidden fields: This event gets triggered when user creates a new entry in the table and hits ‘Enter’ key. to avoid the usage of second event which is being used in copy functionality. But in case. By applying this. SAP COMMUNITY NETWORK © 2010 SAP AG SDN . 1) Whenever the user creates a new entry and hits ‘Enter’ key. In that case. 2) When the user creates a copy of an existing entry and hits the ‘Enter’ key.e.e. we use function code.bpx. whenever the user creates a new entry as well as creates a copy of an existing record.sdn. This event does not get triggered when user creates a copy of an existing entry. It can be implemented as follows. Event 21. It checks the value of the function code which is ‘KOPF’ and executes the code accordingly. the first event which would get triggered is ‘Fill Hidden fields’ and then ‘Creating a new entry’.sap. the code for ‘Creating a new entry’ would not work. both the events are being used for a requirement in table maintenance. there are two cases.com | BOC .uac.Creating new entry This event gets triggered both the times i.

sdn. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample.sap. code or methods suggested in this document. and anyone using these methods does so at his/her own risk. or seek to hold. You agree that you will not hold.uac.boc.com | BOC . SAP COMMUNITY NETWORK © 2010 SAP AG SDN .com | UAC . SAP responsible or liable with respect to the content of this document.sap.com | BPX . Changes made based on this information are not supported and can be overwritten during an upgrade.Table Maintenance Generator and its Modifications Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP.sap. SAP will not be held liable for any damages caused by using or misusing the information.bpx. including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP.com 25 .sap.

Sign up to vote on this title
UsefulNot useful