TABLE MAINTENANCE GENERATOR IN DATA DICTIONARY

TABLE MAINTENANCE GENERATOR:

Table Maintenance Generator is used to create the user interface to the database table to perform the insert, update and delete operations on the database table without any code.

Steps to create the table:

1. Execute SE11.
2. Select the radio button " Database table ".
3. Provide database table name ( Eg: ZSTU_DETAILS ) and click on Create.



4. Provide short description ( Eg: Student details ).
5. Provide Delivery class ( Eg: A ) and Data browser ( Eg: Display / Maintenance Allowed ). 



6. Click on Fields tab and provide the field name and data element as below.



7. Double click on Data element. Click on Yes. Save. Enter. Click on Yes.
8. Provide short description ( Eg: Student Id ).
9. Provide Domain name ( Eg: ZDM_STUID ).



10. Double click on domain name. Click on Yes. Save. Click on Yes.
11. Provide short description ( Eg: Student Id ), Data type ( Eg: Char ) and No. of Characters ( Eg: 10 ).



12. Save, Check and Activate the domain. Click on back.
13. Save, Check and Activate the data element. Click on back.
14. Similarly, provide the other fields in the table.




15. Click on Technical settings in the application tool bar.
16. Provide Data class ( Eg: APPL0 ) and provide Size category ( Eg: 0 ).



17. Save, Click on back.
18. Save, Check and Activate the table.

Steps to create the Table Maintenance Generator: 

1. Execute SE11
2. Select the radio button " Database table ".
3. Provide the table name for which we want to create the TMG and click on Change.



4. In the menu bar click on Utilities. Select Table Maintenance Generator.
5. Select the authorization group ( Eg: &NC& )
6. Provide the function group as table name ( Eg: ZSTU_DETAILS ).
7. Select the maintenance type ( Eg: One step ).
8. Provide the screen no ( Eg: 2345 ).






9. Click on Create in the application tool bar. Save.

Steps to maintain the data in the table by using TMG:

1. Execute SM30.
2. Provide the table / View name  ( Eg: ZSTU_DETAILS ).
3. Click on maintain. Enter.

Steps to create the Tcode for TMG (or) Table:

1. Execute SE93.
2. Provide the transaction code as table name ( Eg: ZSTU_DETAILS ).
3. Click on Create.



4. Provide short description ( Eg: Transaction code for student table ) and select the radio button Transaction with parameters. Enter.



5. Provide the transaction code SM30.
6. Select the checkbox skip initial screen.
7. Select all the SAP GUI Check boxes
8. Provide the name of the screen field and value as below.



9. Click on save.
10. Now execute the transaction code ( Eg: ZSTU ) to maintain the data in the table ( ZSTU_DETAILS ).



11. Here, I added some records if you want you can perform insert, update and delete operations.


Events in Table Maintenance Generator:

EVENT 1: 03- Before deleting the data displayed 

This event gets triggered whenever user delete a record i.e. select a record and click on ‘delete’. 

1. Execute SE11.
2. Provide the table name ( Eg: ZSTU_DETAILS ) and click on Change.



3. In the menu bar click on Utilities. Select Table Maintenance Generator.



4. In the menu bar click on Environment. Select Modification and click on Events.



5. Now the screen as below.



6. Click on New Entries and select the requied event ( Eg: Before deleting the data displayed ) and provide the form routine and click on save.



7. Click on Editor.The following screen would appear. We can use an already existing include or a new include also.



8. After selecting the ‘Include’, write the code inside the ‘include’ of function group of the event and activate the ‘include’. Write the following code in the FORM routine. Please note that FORM and ENDFORM statements have to be added on our own because these statements would appear automatically.

*----------------------------------------------------------------------*
***INCLUDE LZSTU_DETAILSF01.
*----------------------------------------------------------------------*
FORM before_delete.

  
DATA lv_ans TYPE c.

  
IF ok_code EQ 'DELE' OR funtion EQ 'DELE'.

    
CALL FUNCTION 'POPUP_TO_CONFIRM'
      
EXPORTING
      
titlebar                    'Popup'
*       DIAGNOSE_OBJECT             = ' '
        text_question               
'Are you sure to delete the record'
       text_button_1               
'Yes'
*       ICON_BUTTON_1               = ' '
       text_button_2               
'No'
*       ICON_BUTTON_2               = ' '
       default_button              
'1'
       display_cancel_button       
' '
*       USERDEFINED_F1_HELP         = ' '
       start_column                
25
       start_row                   
6
*       POPUP_TYPE                  =
*       IV_QUICKINFO_BUTTON_1       = ' '
*       IV_QUICKINFO_BUTTON_2       = ' '
     
IMPORTING
       answer                      
lv_ans
*     TABLES
*       PARAMETER                   =
*     EXCEPTIONS
*       TEXT_NOT_FOUND              = 1
*       OTHERS                      = 2
              
.
    
IF sy-subrc <> 0.
* Implement suitable error handling here
    
ENDIF.

    
IF lv_ans EQ 2.
      
LEAVE TO SCREEN 0.
      
ENDIF.

    
ENDIF.

  
ENDFORM.


Note: Whenever a new ‘include’ is created for a function group, the function group becomes deactivated. In this case both ‘include’ and function group has to be activated. If the function group is not activated, a runtime error is generated while maintaining the table through SM30. Function group can be activated in transaction SE80.  ( Function group : ZSTU_DETAILS )

9. Execute the transaction ( Eg: ZSTU ). 
10. Select the record and click on delete record.



11. Display the following screen .



12. Click on Yes to delete the record and click on Save to save the data or click on No to leave the screen.
13. Execute the transaction code again and check the records available.