Skip to Content
Table Maintenance
Maintaining Custom subroutine in view V_TVIMF for extracting data while creating table entries thru transaction SM30.

Generally for inserting new records into custom table thru transaction SM30, we need to enter all the values manually and save the record.
When certain data for the key fields needs to be populated automatically while creating entries, the steps involved are:

  1. Maintaining the subroutine in view V_TVIMF for a particular custom table.
  2. Logic for extracting relevant data for the fields entered, when user press enter button.

Steps Involved
As an example, let’s create a Custom table with fields related to customer master using transaction SE11 and maintenance of that table by transaction SM30.
In this example we will consider 3 fields.
KUNNR – Customer number
NAME1 – Customer name
LAND1 – Country key

1 .Create Table ZCUST with these fields

2. Generate table maintenance for this table.

3 For maintaining data in this table we need to do thru transaction SM30.
Creating routine for Custom table ZCUST.
Logic to extract customer name and country key for the customer needs to be written in the subroutine maintained in view V_TVIMF.

4. Go to SE11 – Enter View V_TVIMF .
Utilities – Contents – Enter (table name) (Table name for which subroutine to be maintained) In this case table ZCUST. Press enter.

Following screen appears – Press New entries.

5. We need to maintain two fields in this screen
1.Table maintenance dialog event
2.FORM Routine name
Table maintenance dialog event
Key for a pre-defined time within extended table maintenance. The key is defined in the domain and is displayed with the possible entries
(F4). Use of this field :
If this pre-defined time is reached in extended table maintenance, the FORM routine specified for the current view and for this time is processed. This is useful, for example, for performing consistency checks before saving or specific actions when creating new entries.
The view, time and FORM routine are set in table TVIMF, which must currently be maintained directly using transaction SM30 (view name: V_TVIMF). Key for a pre-defined time within extended table maintenance. The key is defined in the domain and is displayed with the possible entries (F4).
FORM Routine
Name of FORM routine (extended table maintenance)
Name of the FORM routine, which is processed at particular pre-defined times during extended table maintenance.
The FORM routine must belong to the function group, to which the maintenance modules for the view are assigned.

6. Enter Table maintenance dialog event = ’05’ (Here we are writing logic when new entries are created) Depending upon the requirement other events can be used, which are available in F4 values with relevant description.

7. Enter Subroutine name as GET_CUSTOMER_DATA as shown in the screen and press enter. Select the line and press icon available in the editor field.

8. Enter new include LZCUSTF01 and press enter, an entry with this include will get inserted in the function group main program.

9. Write following code in the routine. Activate program and go to transaction SM30 for maintaining records for customer.
Code to be written in the subroutine
* Get customer name
select single name1 land1
into (zcust-name1,zcust-land1)
from kna1
where kunnr = zcust-kunnr.

Output Result
10. Now, if you enter customer number in transaction SM30 and press enter it will extract Customer name and Country key from the custom routine (GET_CUSTOMER_DATA) maintained in view V_TVIMF and displays on the screen.

From the above example we will be able to extract description or any other information thru the custom subroutine and populate fields in the custom table while creating entries thru SM30 transaction.

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Günter Stück
    Just a little remark: Instead of directly entering data into the view V_TVIMF, you could do this inside of the “Generate table maintenance dialog” (SE54) – just click Environment – Modification – Events.
  2. Faaiez Sallie

    I’m sorry to request this here but if possible do you know how to add sort functionality to the overview screen of a generated table maintenance?


  3. Jim Jackson
    This was a great help in getting behind SM30 etc. I now have a new file for Annual Customer Revenue targets with 4 fields in it i.e. mandt, kunnr, name1 and target_val. When originally created, the name field was not included and all worked well.

    I wanted to include the customer name mainly for user reference in SM30 other than just using the customer code so I followed your example. (I don’t want to update that field though via SM30 so I will need to uncheck the field from input somehow).  Now I can update the name field via the code shown and the file is updated OK with the name and the user entered fields of code and value.

    BUT SM30->Maintain or Display does not show the name field – yet via SE16 I can see the name field and it is OK with the correct customer name in it. What have I not done ??



    1. Jim Jackson
      Actually, I’ve managed to find the route within SE11 -> Table maintenance Gen -> Environment -> Modification -> Maint Screens and then untick the relevant field to prohibit input during SM30.

      But thanks again for the detailed help above and it was good to see a very relevant example with it rather than just the usual “use SE54” or similar.


  4. Functional Consultant

    I have a cluster with two tables (header & item). When I create new entries in the items table, I would like the fields from the header table to be automatically filled in.

    I tried to follow your example but unfortunately the working area of my header table contains the first record instead of the currently selected record.

    Maybe there is an easier way to do this but I don’t know.

    Any ideas on how to inherit values in clusters?



  5. Tony Shearsby
    As an example of Table Maintenanc events I think this blog is useful.
    However, the same results can be achieved through the correct use of Foriegn Key checks and a Table Maintenance View.  By using these 2 techniques no ABAP coding is required, and uses only tools SAP has already delivered to satisfy this sort of requirements.  By sticking with SAP tools you will need less time to develop, less time to test, no errors and upgrade assurance.

Leave a Reply