Skip to Content
Author's profile photo Anson John Abraham

Modification of TMG without regeneration in SAP

What is TMG?

TMG (Table Maintenance Generator) is a tool used for maintaining entries in a table such as entering and deleting multiple records, triggering events while updating entries etc. TMG can be created using the transaction codes SE11 and SE54.

Why to modify the TMG without regenerating it?

Whenever a table is modified by inserting a new field, we have to regenerate the TMG (Table Maintenance Generator) to get the new field in the maintenance screen. It will be difficult to regenerate an existing TMG with lot of customizations made in code and screen. All those customizations will be lost during regeneration. So to retain the customizations made in TMG, a manual updating technique can be adopted.

Using TMG for maintaining entries in the table.

Before handling modification let us view an existing TMG. A custom table ‘ZNSFLIGHT’ is created and TMG is generated for demo purpose. This table is copied from the standard table ‘SFLIGHT’.

  1. Go to transaction SM30. Give your table name and click on the ‘DISPLAY’ button.

     /wp-content/uploads/2013/03/1_195501.png

2. Click on the ‘DISPLAY/CHANGE’ button.

     /wp-content/uploads/2013/03/2_195503.png

3. Now click on the ‘NEW ENTRIES’ button.

     /wp-content/uploads/2013/03/3_195504.png

4. Add new entries and save it.

     /wp-content/uploads/2013/03/4_195505.png

Modification of TMG without regeneration

Add a new field to the custom table ‘ZNSFLIGHT’ and activate it.

/wp-content/uploads/2013/03/5_195506.png

We have to include this field to the TMG of ‘ZNSFLIGHT’ without regenerating it.

  1. Go to transaction SE54. Give table name, select ‘Generated Objects’ and click on the ‘DISPLAY’ button.

     /wp-content/uploads/2013/03/6_195508.png

2. Get the function group name.

     /wp-content/uploads/2013/03/7_195509.png

3. Go to SE80 and open the corresponding function group’s code.

     /wp-content/uploads/2013/03/8_195510.png

4. Expand the ‘Screens’ node and select the screen no: 002. (In my case, screen no: 002 is displayed for adding new entries in TMG).

     /wp-content/uploads/2013/03/9_195511.png

5. Select the layout of the screen and click on the Dictionary/Program Fields button.

     /wp-content/uploads/2013/03/10_195512.png

6. Give the table name and click on ‘Get from dictionary’.

     /wp-content/uploads/2013/03/11_195513.png

7. Select the new field which was added to the table. (In this case ‘LAND1’ will be selected) and click ‘OK’.

     /wp-content/uploads/2013/03/12_195514.png

8. Drag this field and add it with other input fields. Save and activate.

     /wp-content/uploads/2013/03/13_195515.png

9. After screen modifications, activate the function group.

    NB: There is one more addition we have to do in the code (flow logic of screen 002), that part will be discussed later in this document.

10. Now for testing the TMG, go to SM30, give the table name and click on the ‘Maintain’ button.

     /wp-content/uploads/2013/03/14_195516.png

11. The new field added manually to the screen will be displayed now. Now click on the ‘New Entries’ button.

     /wp-content/uploads/2013/03/15_195517.png

12. Add new entries and click the ‘Save’ button.

     /wp-content/uploads/2013/03/16_195528.png

13. Now give another country and click the save button.

     /wp-content/uploads/2013/03/17_195529.png

14. Here the new country is not modified. It will display the old value after saving.

     /wp-content/uploads/2013/03/18_195530.png

15. In order to prevent this error, we have to modify the flow logic of the screen 002.

16. Go to SE80, give function group name and select the screen 002 and open the flow logic (Steps 3 and 4).

17. Give the new field name inside the CHAIN – ENDCHAIN, then save and activate the code.

     /wp-content/uploads/2013/03/19_195531.png

18. To test the update functionality, go to transaction SM30, give the table name and click on the ‘Display’ button.

19. Next, click on the ‘Display/Change’ button.

     /wp-content/uploads/2013/03/20_195532.png

20. Now Double click on the existing entry.

     /wp-content/uploads/2013/03/21_195536.png

21. Provide another value in the ‘Country’ field and click ‘Save’ button.

     /wp-content/uploads/2013/03/22_195537.png

22. Now the update function will work perfect.

     /wp-content/uploads/2013/03/23_195538.png

Assigned Tags

      24 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      It will be difficult to regenerate an existing TMG with lot of customizations made in code and screen. All those customizations will be lost during regeneration.

      Why were the customizations done in the first place in the TMG? Why were the TMG events not used?

      BR,

      Suhas

      Author's profile photo Anson John Abraham
      Anson John Abraham
      Blog Post Author

      Hi Suhas,

      Why were the TMG events not used?

      This is a small example to show "how to update a TMG without regeneration"; just want to show it is possible to modify the TMG without regenaration 🙂 .  Usage of TMG events is irrelevant in this simple example for adding one more field to the screen.

      Why were the customizations done in the first place in the TMG?

      I didn't get u.

      Author's profile photo Former Member
      Former Member

                                  Suhas Saha wrote:

      Why were the customizations done in the first place in the TMG? Why were the TMG events not used?

      Few years back, we developed a bespoke process  which had it's own application  document type, status and version management. Like any standard SPRO nodes, we also created a separate tree for our development ( similar to transaction OLMW ) and added the customizing tables under nodes and subnodes.  Lot of customizing tables , text tables, maintenance views and  view clusters  were created for the same.

      To make the development look professional, we tried to copy the screen of  sales doc type configuration ( transaction VOV8). If you see the overview screen of VOV8, the screen is designed manually. Now, if SAP decides to add a new element to the screen, it has to follow the steps provided in the blog otherwise the whole design will go haywire. In our case, also initially things went smooth. But later on, client asked for addition of new fields, so we too had no options but make changes without regenerating the screen. Since every step was well documented,  support team didn't have any issue.

      This kind of development makes sense, when everything is freezed and no more changes need to be done. Always better to follow standard process than look for a workaround.

      Thanks Anson John Abraham for sharing this blog.

      Regards,

      DPM

      Author's profile photo Anson John Abraham
      Anson John Abraham
      Blog Post Author

      Hi  DEBOPRIYO MALLICK,


      Thanks a lot for sharing your experience.


      I too came across such situation where the existing TMG holds many custom codes and the plan for regeneration became a nightmare for me. After some surfing I got this idea to modify the TMG without regenerating it. I have added the new fields and everything worked perfectly. 🙂

      Author's profile photo Ishani Goel
      Ishani Goel

      Very Nice Document .. really helpful.. Thanks!!

      Author's profile photo Anson John Abraham
      Anson John Abraham
      Blog Post Author

      Hi ishani Gupta,


      Happy know that it was useful to you.

      Author's profile photo Anubhab Chirui
      Anubhab Chirui

      Thanks for sharing, it was very helpful.

      Keep sharing this kind of stuffs. 🙂

      Thanks,

      Anubhab

      Author's profile photo Anson John Abraham
      Anson John Abraham
      Blog Post Author

      Thanks for the feedback Anubhab Chirui

      Author's profile photo Former Member
      Former Member

      Nice article... Well Documented...

      Author's profile photo Anson John Abraham
      Anson John Abraham
      Blog Post Author

      Thanks for the feedback Ravi.

      Author's profile photo Kiran K
      Kiran K

      John,

      Thanks for sharing another way of adding new fields into TMG without regenerating.

      But,when SAP provides the option of re-generating the TMG by just choosing the options in the menu bar why one will be interested in doing the same thing manually by adding code which is more error prone.Still,I prefer the regular way of regenerating the TMG which saves time,unless if there is any additional benefit of doing the same thing manually.

      K.Kiran.

      Author's profile photo Anson John Abraham
      Anson John Abraham
      Blog Post Author

      Hi Kiran,

      This method will be useful when the function group associated with the TMG contains lot of custom codes and we don't want to loose it during the regeneration.

      Author's profile photo Former Member
      Former Member

      This method will be useful when the function group associated with the TMG contains lot of custom codes and we don't want to loose it during the regeneration.

      Why should it contain custom code in first place? If you are manipulating the TMG FuGr manually then there is a high probability of messing it up altogether.

      Let me explain you the problem with an example.

      A developer (Mr. Smart) manually changes the TMG. After he leaves the project a new developer (Mr. Un-smart) is tasked to make some changes in the table. He modifies the table & regenerates the TMG. All the changes Mr. Smart did are lost for good!

      1. How do you think Mr. Un-smart would know that the TMG was manually modified?
      2. Does he check the TS before making any changes?
      3. Or was Mr. Smart really un-smart to manually alter the TMG?

      - Suhas

      Author's profile photo Anson John Abraham
      Anson John Abraham
      Blog Post Author

      Suhas Saha wrote:

      Why should it contain custom code in first place? If you are manipulating the TMG FuGr manually then there is a high probability of messing it up altogether.

      Let me explain you the problem with an example.

      A developer (Mr. Smart) manually changes the TMG. After he leaves the project a new developer (Mr. Un-smart) is tasked to make some changes in the table. He modifies the table & regenerates the TMG. All the changes Mr. Smart did are lost for good!

      1. How do you think Mr. Un-smart would know that the TMG was manually modified?
      2. Does he check the TS before making any changes?
      3. Or was Mr. Smart really un-smart to manually alter the TMG?

      - Suhas

      Hi Suhas,

      I came across this situation when I was working in a support project. My requirement was to add an extra field in an existing custom table and to make relevant changes in its TMG. I have gone through the funtion group of the TMG and found lot of customizations made in it. It was totally a chance of risk for me to regenerate it. Then I came up with a solution like this which will not mess up with the existing code. I have posted this article to share my experience and to give a new method to update the TMG. Also I accept that, this is not the standard way to update the TMG.

      Author's profile photo Kiran K
      Kiran K

      John,

      Now I understood the situation and empathise with you on this approach considering one has to move the custom code to the corresponding events and then regenrate the TMG.

      Earlier developer would have used EVENTS rather than coding direclty in generated INCLUDES.But still the risk of code getting vanished if somebody without checking regenrates the TMG for accomodating new fields at a later date.May be you can add  table documentation warning the Developer that TMG has custom code without EVENTS.

      K.Kiran.

      Author's profile photo Anson John Abraham
      Anson John Abraham
      Blog Post Author

      Kiran,

      I have done that 🙂

      Author's profile photo Former Member
      Former Member

      Experience shows that this approach is very far from the point where it would be advisable. Never do it this way, always try to do it be generating the TMG, use events. If all this fails, always keep your changes in a separate include.

      But if SM30 is simply not suitable, maybe do not use it at all once you do not need the transporting mechanism etc.

      Author's profile photo Former Member
      Former Member

      But if SM30 is simply not suitable, maybe do not use it at all once you do not need the transporting mechanism etc.

      Exactly, +1!

      TMG is not supposed to handle all the fancy stuff users want it to do. If you don't think TMG events cannot help you achieve your requirement, then build a custom solution.

      Author's profile photo Otto Gold
      Otto Gold

      +1 😉

      Author's profile photo Former Member
      Former Member

      Nice and simple

      Author's profile photo Former Member
      Former Member

      Thanks for sharing it sir.

      I was damn sure that there must be a way to add fields without regeneration .

      Its really worthy for me. I have a question, If a TMG in which we are using events too..wants to regenerate.


      At that situation will this procedure work ?

      Thanks & Regards

      Taran

      Author's profile photo Anson John Abraham
      Anson John Abraham
      Blog Post Author

      It should work. Technically we are adding new fields to the table and updating the module program to consider the new fields while updating data. We are not modifying the codes written inside the events.

      I also suggest you to consider the standard methods while modifying the TMG. Please read the comments provided by the experts above.

      Regards,

      Anson

      Author's profile photo sreenivas p
      sreenivas p

      thanks for the info

      Author's profile photo Bharathiyar S
      Bharathiyar S

      Guys,

      Its a good Article.. .thanks for your efforts.

       

      But here is the easy way yo do this....

      http://www.sapyard.com/sap-tmg-no-need-to-delete-regenrate-after-change-of-table-structure/

       

      Regards,

      Bharathiyar S.