Adjusting Table Maintenance Generator without re-generating it, when Table Structure changes
Suppose we have a table in the dictionary and it has a maintenance generator which contains many events and lot of features (display a field as drop down, check box or field header text) incorporated manually in the function group of the maintenance generator. At this moment if the table structures changes and it requires one extra field to be appended and maintenance generator needs to be there as it was previously with the amended of the new field then changing the table structure and re-generating the maintenance generator will not provide the solution. If we re-generate the maintenance generator after changing the table structure then it will incorporate the new field but all the events and other features will be deleted from the maintenance generator. So same features and events needs to be coded again.
This can be avoided by adjusting the maintenance generator manually and not re-generating it using the following steps:
Create a table ZTEST_EMP using tcode SE11 with a maintenance generator.
Now Utilities->Table Maintenance Generator and create the Maintenance Generator:
Now from SM30 tcode we can create new entries to the table:
Display table ZTEST_EMP:
Change the table structure with the addition of new field ‘EMP_AGE’ and activate it:
Now if we display the table it will also display the new field with initial value:
But the table maintenance generator will not contain the new field:
Now we will adjust the Table Maintenance Generator so that this additional field is added and other functionalities in the Table Maintenance Generator remains intact.
Get the Function Group from the Table Maintenance Generator Display:
Go to tcode SE80 and open the function group and select the screen number and click on Layout from toolbar.
This Design Screen will appear:
Add the extra column (input/output field) manually:
Name the new column as the same updated in the table structure.
Add the column header text as follows: Name the header text field as- *ZTEST_EMP-EMP_AGE
Save and Back. Go to Flow Logic tab and add the following line indicated:
Go to Element List->General Tab: Tick the red marked field as dictionary field.
Save it. Following pop up will be prompted. (Select your choice accordingly and click ok)
Then the following popup will come. (Click as per your requirement. Here we choose yes as we want new table field to be in Table Maintenance Generator)
Finally Activate the Table Maintenance Generator. If activated successfully then go to tcode SM30 to maintain data.
We will change Employee age as 30 and save the record. In the table display we can see that age is updated.
Good .........! Keep Gaining And Keep Sharing.
Wouldn't it be easier to use the Table maintenance generator? Press the change button, and a small popup comes where you can say, I have added additional field. Only those options which you select on this popup would be generated.
Interesting, but not too useful. Table maintenance generator is faster than that
Instead of taking Function Group and display it on SE80 then go to Screen, just Double click on Screen number in Table Maintenance Generator. Thanks for the Blog it is useful.
Thank you - very useful.
For previous comments about Table Maintenance Generator being easier :
Yes - its true that its easier. However, if you have used the Maintenance Events and put code into the events to fintune/control the user entries, the table maintenance re-generation wipes this off. We can certainly use INCLUDE and OO-Techniques to minimize the impact - but still the starting point of all these event code will be wiped clean when re-generating.
Hence, the technique discussed here in this Blog can be used to prevent this event code wipes.
Thanks, awesome guide.