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
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.
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).
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.
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 .
* Get customer name
select single name1 land1
where kunnr = zcust-kunnr.
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.