No Need to Delete and Regenerate the Table Maintenance Generator after Addition or Deletion of New Key or Non-Key Fields in Tables.
Do you know how?
Whenever we need to add a new key field or non-key field to an existing table which already has a TMG (Table Maintenance Generator), most of the developers keep a copy of all the codes written in the Tables Events and related area like PBO/PAI. So that after the new fields are added, they can delete the TMG and regenerate. Once the TMG is regenerated, all the previous codes are lost and the ABAPer has to retrofit the code back to the events from his back up.
FYI – We delete and regenarate the TMG because if we do not do it, the new fields does not get reflected in SM30 T-Code.
But what if, a new developer is in the project. He does not know that there is some custom logic written in the events. And he adds new fields and deletes existing TMG and regenerates the TMG without taking the backup?
This has been a pain in the neck even for seasoned ABAPers with over decades of hands-on experience. Today, we would show how you can add new fields and also make the existing TMG work with some simple steps without deleting the existing TMG.
Let’s start.
This is how the table looks before we add new fields:
(Assume we have some Events created for this table, ex: event 05, event 06 etc…)
Step 1: I have created a custom table with maintenance with some fields.
(Maintenance screen before adding the additional fields)
(Maintenance table)
After adding the new fields to the existing table, in general, most consultants (read ABAPers) follow one difficult path of refreshing the table maintenance generator in order to make the new fields visible.
Delete the existing TMG and creating a new one with newly added fields to the table. If we have no events, we are lucky, we do not have any issue. But if there were events, then deleting the TMG would fade off all the logic in seconds. Once you deleted you can’t get the code back (though, there are ways to get it back).
Have you been a victim of TMG deletion? Have you ever lost any code because of TMG regeneration?
Team SAPYard has always tried to provide solutions for the everyday small niggles. So here I come up with the alternative solution. We can get the new fields information without deleting the existing TMG. This would save the valuable time of ABAPers which they can utilize in some other productive actions ( i.e. watching soccer, cricket, stock market or the new kid in town i.e BitCoin). J
Also Read: Save the data in Customizing table without using transport number
Step 1: Added new fields to that table
Step 2: Adjust the table after addition of new fields in T-Code SE14.
Chose Activate and adjust database button and Save data.
Step 3: Go back to the table (in change mode) and click on table maintenance generator from Utilities menu item.
Step 4: You would be able to see the change icon on the maintenance screen.
Click it.
Step 5: Popup will appear on clicking the change icon.
Step 6: Here comes the most important section, whether you want to change or delete the fields.
If you want to add additional fields to the TMG, then select New field/sec. table in structure.
Click continue.
You must have realized, if you want to delete the fields from a table, then you need to select Field/sec. table removed from the structure.
Click continue.
Step 7: For our exercise, continuing as adding new fields
So next screen would be:
Step 8: Here too, you have a very important decision to make. You want to add a key field or normal field?
Whether it is single screen or overview screen?
Here our situation is normal filed, with overview screen.
Click continue.
Step 9: One more popup will appear after you press the continue button.
Simply click on Continue.
Note: Some processing time will take to activate
Then click on SAVE.
Congratulations you regenerated the TMG successfully without any hassle of deleting the TMG.
What are you waiting for? Go and check your maintenance (SM30).
Here you can see the result. Newly added fields are smiling and waiting for you to populate them.J
Also Read: Automatic Population of Values during Table Maintenance
Follow the same procedure when you want to:
- Add new Key fields to the table
- Delete the fields (key/non-key) from the table
Hope you liked this trick. It might look simple but trust us, many ABAPers do not know this. Next time you change the structure of a Table, you know how to regenerate TMG without any headache.
If you GENUINELY like our articles then it would be a HUGE help if you shared, subscribed and liked us on Facebook. It might seem insignificant, but it helps more than you might think.
Also Check our Step by Step Tutorials on SAP HANA-ABAP
- ABAP on SAP HANA. Part I. First Program in ABAP HANA
- ABAP on SAP HANA. Part II. ADT Eclipse and HANA Studio
- ABAP on SAP HANA. Part III. Debugging in ADT
- ABAP on SAP HANA. Part IV. Core Data Services
- ABAP on SAP HANA. Part V. Deep Dive into CDS Views
- ABAP on SAP HANA. Part VI. New Age Open SQL ABAP 740
- ABAP on SAP HANA. Part VII. SQL Script and SAP HANA Stored Procedure
- ABAP on SAP HANA. Part VIII. ADBC – ABAP DataBase Connectivity
- ABAP on SAP HANA. Part IX. AMDP – ABAP Managed Database Procedure
- ABAP on SAP HANA. Part X. AMDP with SELECT OPTIONS
- ABAP on SAP HANA. Part XI. Are Native SQL and Open SQL Competitors?
- ABAP on SAP HANA. Part XII. Open SQL, CDS or AMDP, which Code to Data Technique to use?
- ABAP on SAP HANA. Part XIII. Sample Functional Specification of HANA Project
- ABAP on SAP HANA: Part XIV. HANA Ready, HANA-tization & HANA Plus
- ABAP on SAP HANA: Part XV. Expose CDS Views as OData Service through Annotation
- ABAP on SAP HANA: Part XVI. HANAtization
- ABAP on SAP HANA: Part XVII. ATC – ABAP Test Cockpit Setup & Exemption Process
- SAP ABAP on HANA: Part XVIII. SALV IDA (Integrated Data Access)