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:
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.
Dependencies
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
*---------------------------------------------------------*
***INCLUDE LZCUSTF01 .
*---------------------------------------------------------*
FORM GET_CUSTOMER_DATA.
* Get customer name
select single name1 land1
into (zcust-name1,zcust-land1)
from kna1
where kunnr = zcust-kunnr.
ENDFORM. "GET_CUSTOMER_DATA
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.

Conclusion
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.
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:
- Maintaining the subroutine in view V_TVIMF for a particular custom table.
- Logic for extracting relevant data for the fields entered, when user press enter button.
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.
Dependencies
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
*---------------------------------------------------------*
***INCLUDE LZCUSTF01 .
*---------------------------------------------------------*
FORM GET_CUSTOMER_DATA.
* Get customer name
select single name1 land1
into (zcust-name1,zcust-land1)
from kna1
where kunnr = zcust-kunnr.
ENDFORM. "GET_CUSTOMER_DATA
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.

Conclusion
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.