ABAP Maintenance View
- The maintenance view is created on two or more tables, which is used to maintain the data of several tables altogether. It helps us to maintain the complex application objects easily.
- It can combine several tables in a single unit, but the tables must have a foreign key relationship.
- It allows us to maintain and read the data of the table.
- The data present on several tables create a logical unit that acts as an application object for the user. With the help of a maintenance view, we can display, modify, and maintain the data of such application objects at once.
- In the maintenance view, all tables must be linked together with the foreign key, which means the join condition must be derived from the foreign key always.
- There is always a maintenance status associated with each maintenance view, which specifies the operations that can be performed on the associated table.
- The below diagram explains the relationship between an application object, maintenance view, and the underlying database:
As we can see in the above diagram, the fields F2 and F4 of table 1 and table 2 are linked with the foreign key. Similarly, the fields F5 and F6 of table 2 and table 3 are connected with the foreign key. The maintenance view is implemented on these three tables and extracting data from F1, F2, F3, F5, and F8 fields.
Creating Maintenance View in ABAP:
- Step-1: Open the data dictionary initial screen by navigating the menu path or entering the transaction code SE11 in the command field.
- Step-2: Click the radio button in front of the View Give a name to the view, and click on the Create button, given on the screen.
- Step-3: A pop-up window will appear with all the views, from where select the "Maintenance view," and click on the Copy
The Dictionary: Maintain View Screen Appears
- Step-4: Provide the short text for an explanation of view in the "Short Description" field. E.g., Creating a maintenance view for test or Maintenance view example.
- Step- 5: Click on the Table/Join Conditions tab, provide the name of the primary table for view under the Table column.
- Step-6: Place the cursor on the name of the primary table name and click on the Relationships
- Step- 7: Tick on the checkbox in front of the table name.
- Step-8: Click on the copy button, and the secondary table will be selected.
- Step-9: Go to the selection conditions tab and provide the conditions. (If required). Here we are not providing any selection condition.
- Step-10: Go to the View fields tab, click on the Table Fields button to select the field from each table(primary and secondary).
Repeat the process for the secondary table (ZSTUDENT) also, and all the selected fields will be displayed under the view field column.
- Step-11: Go to the Maint. Status tab and select the appropriate radio button. Select the other fields, as shown in the below image:
- Step-12: Go to the Utilities> Table Maintenance Generator, as shown in the below diagram.
- Fill the details as shown by the arrow, and save it.
- Step-13: Click on Save, Save the view as the local object or under a package. Here we will save it as a local object. Check for any inconsistency and Activate the view.
- Step-14: Now select utilities> Contents. A new screen will appear, which allows you to read, maintain, and write the data.
Here we are changing the Name ANDRICK to ARMAN, which has changed successfully. Consider the below image:
Advantages of Maintenance view:
- With the help of a maintenance view, we can extract the required data from several tables, which is faster than selecting data from an individual table.
- It saves time by maintaining several tables at once, as maintaining each table separately is time taking process.