Capture Changed content after the FM VIEW_MAINTENANCE_CALL

By | September 11, 2008 | Table Maintenance | 6,013 | 1

The requirement is to capture the changed contents – updated, deleted or inserted – after the table maintenance call using the FM VIEW_MAINTENANCE_CALL.

The simple solution to handle this requirement is:
1. Get all the data from the database table for which we will call the FM VIEW_MAINTENANCE_CALL.
3. Get all the data from the database table again in separate internal table Compare the contents of the data using some utility.

This kind of generic solution would be possible, but the performance of the report would be slow. I thought of having something which can tell us directly just after the FM call, which line was changed: update or deleted or inserted. Suddenly, I thought of implementing the Event and use the same data which are there in the global tables of the Maintenance Function.

Based on the thought, new steps to achieve this solution would be:
1. Implement Event in the Maintenance. Export the Main internal table to ABAP memory, which can be accessed later from the calling program.
3. Import the data from the ABAP memory

In this later approach, we can get the data instantly from the memory. Since we will have the indicators (ACTION field in the table) which will help us to identify the type of change made to table entries.

You can find more information on the Events of the Table Maintenance at: Extended Table Maintenance Events

To implement the solution, I have used the Event 01 – Before Saving the data into Database. We need to create the subroutine which can be called when the event gets hit. When we create a subroutine, it will be created in the same Function group in which we have created the Table mainteinance. Hence, it will provide us the access to all the global tabbles. From all of these tables, we will export the internal table TOTAL to the memory.

TOTAL table contains the fields: ACTION and MARK.

Content of the ACTION field would help us to indetify the type of change:
D – Delete
U – Update
N – New Entry

Code Snippet to Export data in Event 01

*       This form is called in the Event 01 of the table maintainence
*       events
* Table of the same structure of the TOTAL which can be exported
* Moving data to ITAB from total
* Clearing memory
* Exporting data to Memory
ENDFORM.                    "EXPORT_TOTAL_TABLE

Code Snippet of the Report

*& This Report will start the Table Maintainence and after saving the
*&   data in the table maintinence, it will generate a list which will
*&   what data has been newly added, updated or deleted
* Table with the Same structure of the table which is exported.
* Output table
* Output ALV reference
* Start the Table maintainence
      ACTION                       'U'
      VIEW_NAME                    'ZTEST_NP_EVENT'
      CLIENT_REFERENCE             1
      FOREIGN_LOCK                 2
      INVALID_ACTION               3
      NO_DATABASE_FUNCTION         5
      NO_EDITOR_FUNCTION           6
      NO_SHOW_AUTH                 7
      NO_TVDIR_ENTRY               8
      NO_UPD_AUTH                  9
      ONLY_SHOW_ALLOWED            10
      SYSTEM_FAILURE               11
      VIEW_NOT_FOUND               13
      OTHERS                       15.
  IF SY-SUBRC <> 0.
* Importing the memory from the Memory ID
*   Table has been exported in the Event 01 of the Table
*   maintenance events.
* Clear the memory id
* Moving data to output
* New ALV Instance
          R_SALV_TABLE O_ALV
          T_TABLE      IT_OUTPUT ).
    CATCH CX_SALV_MSG.                                  "#EC NO_HANDLER
* Display the ALV

I came across the requirement from one of the Forum post in the ABAP Development forum on SDN. You can follow this link to view the discussion: VIEW_MAINTENANCE_CALL

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{271 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 271 articles.

Load comments

1 Comment

  • Ujjaval

    Nice work man…

    Not that I understand your SAP blog. But its amazing to see how you maintain this things beside your work along with your pencil drawings which are good.. you’ve maintained your hobby even after school.


Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.