Extended Table Maintenance
Extended Table Maintenance
Change Recording
Posted on: April 10, 2014 | By: Pawan Kesari – 9 Comments
Table maintenance generator is very powerful tool to generate simple data entry
screen for tables. For tables which store configuration data i.e. rarely modified it not
worth spending time creating module pool program for data entry. Table
maintenance generator also gives programmer opportunity to modify standard
behaviour by including additional logic. In this blog I will enhance standard table
maintenance to automatically record created by and created date/time and also last
modified by and last modified date/time.
I have this table which record additional information per plant. Instead of hard-coding
this text we decided to create a table and put these values there in case it requires
change in future.
I have fields ERNAM, ERDAT, ERZET, AENAM, AEDAT, AEZET apart from fields
which will hold actual data.
Create table maintenance from menu option Utilities->Table Maintenance Generator.
Make sure to select ‘one step’ in Maintenance type.
With standard table maintenance you will have all field active and ready for input.
Since we username and date times field to be filled automatically by program logic
we need to hide them from table maintenance screen. To do that, in table
maintenance screen double click on screen number.
It will take you to the flow logic of screen. Add module modify_element in PBO of
screen.
1
2 PROCESS BEFORE OUTPUT.
3 MODULE LISTE_INITIALISIEREN.
4
*--------------------------------------------------------------------*
5 * Hide user name and date/time column
6 *--------------------------------------------------------------------*
7 MODULE modify_element .
8 *--------------------------------------------------------------------*
9
LOOP AT EXTRACT WITH CONTROL
10
TCTRL_ZSD_PLANT_CODE CURSOR NEXTLINE.
11 MODULE LISTE_SHOW_LISTE.
12 ENDLOOP.
13 *
14
Save and double click on modify_element module to create module in new include.
If it comes back saying you are already editing main program then close everything,
open table in display mode and navigate to PBO in display mode and try again with
double click.
In module modify_element copy following code. This code is going through the table
control structure to hide columns.
1 *----------------------------------------------------------------------*
***INCLUDE LZSD_PLANT_CODEO01 .
2
3
4
*----------------------------------------------------------------------*
5 *&---------------------------------------------------------------------*
6 *& Module MODIFY_ELEMENT OUTPUT
7 *&---------------------------------------------------------------------*
8 * text
*----------------------------------------------------------------------*
9 MODULE modify_element OUTPUT.
10
11 LOOP AT <vim_tctrl>-cols INTO vim_tc_cols.
12 IF vim_tc_cols-screen-name = 'ZSD_PLANT_CODE-ERNAM' OR
13 vim_tc_cols-screen-name = 'ZSD_PLANT_CODE-ERDAT' OR
14 vim_tc_cols-screen-name = 'ZSD_PLANT_CODE-ERZET' OR
vim_tc_cols-screen-name = 'ZSD_PLANT_CODE-AENAM' OR
15 vim_tc_cols-screen-name = 'ZSD_PLANT_CODE-AEDAT' OR
16 vim_tc_cols-screen-name = 'ZSD_PLANT_CODE-AEZET' .
17
18 vim_tc_cols-invisible = 1 .
19 MODIFY <vim_tctrl>-cols FROM vim_tc_cols .
ENDIF.
20
ENDLOOP.
21
22 ENDMODULE. " MODIFY_ELEMENT OUTPUT
23
24
Save and activate all objects. Make sure the function group where table
maintenance generator code is active including screen and our new include.
If you run table maintenance now you should not see these field.
Now it’s time to add code which will fill user name, date and time when records are
created or changed.
Table Maintenance Generator offers events that during program processing and we
programmer can add our own code to execute at this point. Very similar to user-
exits. Events in which we are interested in are 05 which executes when new entry is
create and event 01 which triggers before saving the data in database. We are going
to add code at these event which will populate our fields.
Open Table Maintenance Generator in change mode and choose menu option
Environment->Modification->Events.
Click ok on dialog box which say do not change SAP data. On next screen press
‘New Entries’ and add modules at 05 and 01 events.
Click on the editor button next to form routine, create include if required, and put
following code in each of these form routines.
1
*&---------------------------------------------------------------------*
2 *& Form ZSDPLANT_NEW_ENTRY
3 *&---------------------------------------------------------------------*
4 FORM zsdplant_new_entry .
5 zsd_plant_code-ernam = sy-uname .
zsd_plant_code-erdat = sy-datum .
6
zsd_plant_code-erzet = sy-uzeit .
7 ENDFORM. "zsdplant_new_entry
8
1
2
3 *&---------------------------------------------------------------------*
4 *& Form ZSDPLANT_MODIFY_SAVE
5 *&---------------------------------------------------------------------*
6 FORM zsdplant_modify_save .
7
FIELD-SYMBOLS : <fs_field> TYPE ANY .
8
9 LOOP AT total .
10 CHECK <action> EQ aendern.
11 ASSIGN COMPONENT 'AENAM' OF STRUCTURE <vim_total_struc> TO <fs_field> .
12 IF sy-subrc = 0 .
<fs_field> = sy-uname .
13 ENDIF.
14
15 ASSIGN COMPONENT 'AEDAT' OF STRUCTURE <vim_total_struc> TO <fs_field> .
16 IF sy-subrc = 0 .
17 <fs_field> = sy-datum .
18 ENDIF.
19
ASSIGN COMPONENT 'AEZET' OF STRUCTURE <vim_total_struc> TO <fs_field> .
20 IF sy-subrc = 0 .
21 <fs_field> = sy-uzeit .
22 ENDIF.
23
24 READ TABLE extract WITH KEY <vim_xtotal_key>.
IF sy-subrc = 0.
25
extract = total .
26 MODIFY extract INDEX sy-tabix.
27 ENDIF.
28
29 MODIFY total.
30 ENDLOOP.
31 ENDFORM . "ZSDPLANT_MODIFY_SAVE
32
33
Save and Activate all objects. To activate function group you can go to SE80 and
activate from there.
I have created two entries in table maintenance and then changed one. This is how
table contents look like.
Table Maintenance options and ABAP
One of the traits I like about SAP is that you have several facilities to achieve more. One
of those characteristics is in transaction ‘SE11’. This transaction is used to create tables
and it comes with a feature where you can generate it’s own screen (dynpro) and basic
validations, like, unique index and others.
This screen(s) can be modified with our own logic and validations and even the layout.
You can add more detail as you wish. Maybe you could make this maintenance screen
making a module pool in SE80 however the point here is that with transaction ‘SE11’ you
don’t start from zero. This trait is very important because you can have a lot of features
incorporated.
1. Execute transaction ‘SE11’ and name the table whatever you want but remember to
use ‘Z’ or ‘Y’ as first letter.
The next thing we should do is to generate the maintenance screen. The option we need
here is in ‘Utilities’ menu where you select the ‘Table Maintenance Generator’ option.
Here we have some things to configure;
First you need to indicate the authorization group, here it depends on what kind of
restriction you would like this program to make, for this example type ‘&NC&’ which
means ‘w/o auth. group’. The second thing to set is the function group, personally I
would recommend to use the table name, however is up to you which name you set
here.
https://alltechtricks9.wordpress.com/2016/06/20/sap-abap-data-dictionary-interview-questions
Use case
A typical business case for the use of additional checks is the implementation of
additional checking logic for data which the user entered. In my case, I’ll use the same
table as last time, which has the company code as a key field. I will implement a check to
verify that the company code that is entered actually exists.
The implementation of custom logic in table maintenance dialogs is done using so-called
events. To get access to these, select Environment > Modification > Events from the menu
while in the table maintenance generator screen.
Your next task will be to pick the correct event for the job you want to do. Since there are
close to 40 different events available, it’s best to use the SAP documentation for extended
table maintenance events, which you can also access via the information button ( ).
For my example, I want to perform a check after data was entered. The correct event for
this is 05. You also need to enter a form routine name. Click Save after you’ve entered your
data (important!) and click on the button in the Editor column afterwards.
After you have added your include, you’re taken to the ABAP Editor. This is the place
where you can implement your custom check logic. Before I’m going into the details of the
programming itself, let me explain which variables are available to work with the data in
the table.
The interface for these hooks is always the same. There’s a set of variables and internal
tables that let you work with the data in the table control. It’s documented for each event
induvidually (such as for event 01), but the generally available variables are the following.
The internal table TOTAL contains the complete dataset that is held in the table you are
working with. Its structure is a combination of the base table structure and the
structure VIMTBFLAGS. This structure contains fields that indicate the processing status of
the table row.
Via these field symbols, you can access the processing status of the current table row of
table TOTAL, which means they mark if the record was created, updated, or deleted.
These field symbols should only be used for events that are called once for each table
entry, meaning that they are executed in a loop.
If you want to read the processing status of table rows manually, it’s better to use the
field VIM_ACT from the structure VIMTBFLAGS. <ACTION> indicates the processing status
of the table itself. <ACTION_TEXT> is used if your underlying data table has a text table
attached, and indicates the processing status of the text table.
The following constants are available to check the processing status.
While the table TOTAL contains all of the data that is in the data table, EXTRACT is the data
subset that the user is currently working with. The exact contents of this table depend on
the function the user is currently executing within the SM30 transaction. If he is adding
new lines, the table EXTRACT will contain only the newly entered lines, while the
table TOTAL will contain all old lines plus the new lines. The table EXTRACT has exactly the
same structure as the table TOTAL. More information on table extracts can be found
here: SAP documentation for table extracts.
This field symbol provides access to some general information. Especially important is the
field <STATUS>-UPD_FLAG, which indicates if any data was changed in the table control.
Especially important for the event 05 (after adding new entries), this structure will hold the
newly-entered data before it is moved to the main table. It can be accessed via the name
of your custom table (in my case, the name is ZMYTABLE) and can be used for data checks.
These are the most important variables that are available in the extended table
maintenance interface. There are a few more, but they are used only in special cases or
only in a few events. On the next page, I will show you how to use these variables to
implement a simple check on entered data.
Implementation of custom table maintenance logic in ABAP
Remember the include file you were taken to when you clicked the Editor button in the
events screen? That’s where we’ll continue now. I hope you remember the name of the
FORM you provided in the events overview, because this is the routine we have to
implement now. Unfortunately, it’s not generated automatically. It takes no parameters,
so the first step is to add just a simple FORM with no parameters to your include.
*----------------------------------------*
***INCLUDE LZMYTABLE_MAINTF01.
*----------------------------------------*
FORM check_data.
ENDFORM. "check_data
This is what we’re starting out with. Now, it’s important to know what we want to actually
check. Since the event 05 is called in a loop for each new entry made by the user, we have
a rather simple job. We don’t need to check any flags or processing statuses. All we need
to do is take the user-entered data and do a check with it. The complete implementation
of the event looks like this.
FORM check_data.
IF sy-subrc <> 0.
MESSAGE e000
WITH 'This Company Code does not exist.'.
ENDIF.
ENDFORM. "check_data
Notice that here, I’ve used the zmytable structure to read the user data. The reason for
this is the point in time at which event 05 is called. Here, the entered data has not been
transferred to TOTAL or EXTRACT yet, because we have a chance to do checks on the data
first.
Now, whenever the user enters a company code, the FORM routine will check if it is valid.
If it’s not, then an error message will be shown and the user has a chance to correct the
data.
The third thing would be to set the screens of the block ‘Maintenance screens’. In this
section you have two options:
One step
Two step
And the difference is that in the first option you make inserts and modifications in
only one dynpro, here SAP sets you a grid to make all the actions on your data. The
second option consists in specifying 2 dynpros; one for the grid and the second for
issuing the data. The first dynpro shows you the data but in order to make inserts or
changes you must make a double click to show you the data.
In our example select the first option (One step) and type '100' in the ‘Overview screen’.
Now, click on 'Create' button or press 'F6'.
The next step is to make use of events. This option is found in the menu
‘Environment’/’Events’.
If you get the following message box click the 'Ok' button.
You will get through the following screen where you must choose what events are going
to be raised.
Just for example let’s use the events ‘05’ (Creating new entry) and ‘21’ (Fill hidden
fields). Let’s say we want to put the user name and the date when the record is created
and modified it.
1. Type event ‘05’ and on the ‘FORM Routine’ column type ‘on_create’.
2. Type event ‘21’ and on the ‘FORM Routine’ column type ‘on_change’.
3. Next, click on column editor the button to type the code. You’ll be asked to
make a PAI include. Click on button ‘OK’.
4. Paste the following code.
1 form on_create.
2 ztesttab-ernam = sy-uname.
ztesttab-erdat = sy-datum.
3 ztesttab-aenam = sy-uname.
4 ztesttab-laeda = sy-datum.
5 endform.
6
7 form on_change.
8 ztesttab-aenam = sy-uname.
9 ztesttab-laeda = sy-datum.
10 endform.
11
5. Return to the event entries screen and click the save button and go back to the ‘Table
Maintenance’ screen and also save the configuration.
If you have the following message box ‘Function group ZTESTTAB cannot be
processed’ then go to transaction ‘SE80’ and select the function group ‘ZTESTTAB’ and
activate it but first change the ‘Change’ state of the table to ‘Display’. Check the images
below.
6. Create entries. Go to 'Utilities'/'Table contents'/'Create Entries' menu.
7. Finally click on button ‘New Entries’, fill the fields ‘+’ and ‘Last Name’ and press enter.
And you’ll see that fields ‘Created by’, ‘Created On’, ‘Changed by’ and ‘Changed on’ now
have the values we set in the ‘Creating a new entry’ event. The same will occur when
you change it with another user.
One last comment is that in order to protect those fields from being modified you must
edit the dynpro '100' you set in the 'Utilities'/'Table Maintenance Generator' menu and
set the ‘Input‘ column to ‘Not possible’ value in the ‘Special Attributes’ tab on the
columns ‘ERNAM’, ‘ERDAT’, ‘AENAM’ and ‘LAEDA’.
Hope it helps. See you on the next.
Client (MANDT): necessary to make the table client-specific.
Company Code (Z_BUKRS): the organizational value with which
we will apply the restriction.
Sales Organization (Z_VKORG): a second organizational value.
Approver (Z_APPROVER): an approver user according to the
combination of previous organizational values.
In the TMG, we have assigned an authorization group for our table and a
function group for the maintenance program. In addition, we have
selected the one-step maintenance type and obtained the screen number
1 using Find Scr. Number(s):
At this point, our table is ready to be modified using the TMG itself.
Conclusion
The TMG routines and events are a very versatile tool that allows
enhancing the functionality of tables in general. Many companies today
use SAP’s custom tables to expand and adapt the standard functionality to
their business processes; using this tool, it is possible to reduce the
necessary developments to achieve the goal and improve functionality
according to the more specific needs of each company. We could be
including additional validations to the information included in the table, or
we could modify the way it is displayed, to give some examples.
Wouldn’t it be much nicer if we could just have a selection screen to restrict the displayed
values, just like we know from SE16 and any report transaction? Well, we can! SAP
provides the event AA: Instead of the Standard Data Read Routine to do just that. Let’s
walk through the necessary steps to create a custom selection screen for
the SM30 maintenance functionality.
The first step is to add the hook AA to the events overview. If you’ve read my last post
about extended table maintenance, you already know how to do this. Open your table and
go to the table maintenance generator. Then select Environment > Modification > Events to
open the events overview. Add the event AA, enter a FORM name and save.
Now go to the editor. The first thing we need is, of course, the selection screen that we’re
going to show. In my example, I’m defining a simple screen with just the company code as
a parameter to restrict the values shown. In code, it looks like this.
Since we’re implementing our own data reading routine, we would now have to read the
data in table ZMYTABLE from the database. We could use OpenSQL for that, but there’s a
better way. There are already pre-defined FORM routines that do the data reading job for
us. They are:
In this case I’m using TABLE_GET_DATA since the maintenance generator is based directly
on the data table.
After executing this call, all the data from the database is in the internal table TOTAL. After
that is done, we can show our selection screen. Here it’s done as a modal popup by using
the addition STARTING AT, but we could also omit that and display it as full-screen. After
the popup has been executed, we have the filter value in the parameter P_BUKRS. I’ve
added a statement that doesn’t apply the filter when the value is empty, but that’s
optional.
Now, all we need to do is loop over the data in the table TOTAL, apply the filter condition,
and remove the record from the table if it doesn’t match. In order to have structured
access to the table, we need to define a structured variable first that the data is moved
into. Remember: the structure of the TOTAL table equals the base table plus the
structure VIMTBFLAGS.
ENDLOOP.
And we’re done! Check out the result of our programming by calling SM30 with your base
table as parameter. The popup will look like this.
The resulting table view will only contain entries that adhere to the filtering conditions.
That concludes today’s post.
This is the entire FORM routine that is needed to implement a custom selection screen
for SM30 with the event AA.
ENDLOOP.
ENDFORM.
To add a validation to prevent invalid data input while using table maintenance transaction (SM30)
is a common situation. However, it may be tricky at first if we don’t know the trick behind. So,
below is the step to add the custom validation.
For example, I want to add validation on CURR field, which should not be empty, and must have
value either ‘USD’ or ‘IDR’.
There, we could register subroutine call to an event. For list of event, just press F4 on the left most
column, which will bring up a list of event code and its event description. For our case, we want to
do validation before data is saved, so we will pick the event ’01’ – Before saving data in the
database.
After that, we have to define a name of subroutine, for example ‘F_VALIDATE_ENTRY’. Click on the
‘editor’ button, and a popup asking where to put the new subroutine will come. Create new include.
2. Add the validation code
In the new include, add below code:
form f_validate_entry.
LOOP AT total.
clear lwa_row.
if <vim_total_struc> is ASSIGNED.
MOVE-CORRESPONDING <vim_total_struc> to lwa_row.
endif.
ZEVOLVING
SEARCH
Welcome !
Welcome to Zevolving - place where you find one of the best articles, tutorials for ABAP
Recent Posts
o More Post →
OO Concepts
o Abstract class vs Interface
o Multiple Inheritance
o When to use Local Class
o Class Based Exceptions
o Constructors
o More »
Design Patterns
o Singleton
o Model View Controller
o Singleton Factory
o Decorator
o Observer
o More »
Performance
o FieldSymobls vs WA
o Parallel Cursor
o ITAB Copy
o FOR ALL Entries
o Between breakpoints
o More »
Concepts
o New TYPE Category BOXED
o Pragmas replacing Pseudo Comments
o Method Chaining
o ITAB Secondary Keys
o More »
Tutorials
o SALV Table Display
o SALV HS Table Display
o Classic
o Generic Object Services (GOS)
o Dynamic ITAB
o Case Studies
o Or Explore Archives
Code Snippets
Home
Table Maintenance
Capture Changed content after the FM VIEW_MAINTENANCE_CALL
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.
2. Call the FM VIEW_MAINTENANCE_CALL
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.
Content of the ACTION field would help us to indetify the type of change:
D – Delete
U – Update
N – New Entry
*&------------------------------------------------------------------
---*
*& Form EXPORT_TOTAL_TABLE
*&------------------------------------------------------------------
---*
* This form is called in the Event 01 of the table maintain
ence
* events
*-------------------------------------------------------------------
---*
FORM EXPORT_TOTAL_TABLE.
*
* Table of the same structure of the TOTAL which can be exported
DATA: BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE ZTEST_NP_EVENT.
INCLUDE STRUCTURE VIMFLAGTAB.
DATA: END OF ITAB.
*
* Moving data to ITAB from total
ITAB[] = TOTAL[].
*
* Clearing memory
FREE MEMORY ID 'ZTEST_EVENT'.
*
* Exporting data to Memory
EXPORT ITAB = ITAB TO MEMORY ID 'ZTEST_EVENT'.
*
ENDFORM. "EXPORT_TOTAL_TABLE
Code Snippet of the Report
*&------------------------------------------------------------------
---*
*& Report ZTEST_NP_EVENT
*&------------------------------------------------------------------
---*
*& 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
*&------------------------------------------------------------------
---*
REPORT ZTEST_NP_EVENT.
*
* Table with the Same structure of the table which is exported.
DATA: BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE ZTEST_NP_EVENT.
INCLUDE STRUCTURE VIMFLAGTAB.
DATA: END OF ITAB.
*
* Output table
TYPES: BEGIN OF TY_OUT.
INCLUDE TYPE ZTEST_NP_EVENT.
INCLUDE TYPE VIMFLAGTAB.
TYPES: END OF TY_OUT.
*
DATA: IT_OUTPUT TYPE STANDARD TABLE OF TY_OUT.
*
* Output ALV reference
DATA: O_ALV TYPE REF TO CL_SALV_TABLE.
*
*
START-OF-SELECTION.
* Start the Table maintainence
CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
EXPORTING
ACTION = 'U'
VIEW_NAME = 'ZTEST_NP_EVENT'
EXCEPTIONS
CLIENT_REFERENCE = 1
FOREIGN_LOCK = 2
INVALID_ACTION = 3
NO_CLIENTINDEPENDENT_AUTH = 4
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
UNKNOWN_FIELD_IN_DBA_SELLIST = 12
VIEW_NOT_FOUND = 13
MAINTENANCE_PROHIBITED = 14
OTHERS = 15.
IF SY-SUBRC <> 0.
ENDIF.
*
* Importing the memory from the Memory ID
* Table has been exported in the Event 01 of the Table
* maintenance events.
IMPORT ITAB TO ITAB FROM MEMORY ID 'ZTEST_EVENT'.
*
* Clear the memory id
FREE MEMORY ID 'ZTEST_EVENT'.
*
* Moving data to output
IT_OUTPUT = ITAB[].
DELETE IT_OUTPUT WHERE ACTION IS INITIAL.
*
* New ALV Instance
TRY.
CL_SALV_TABLE=>FACTORY(
EXPORTING
LIST_DISPLAY = ABAP_FALSE
IMPORTING
R_SALV_TABLE = O_ALV
CHANGING
T_TABLE = IT_OUTPUT ).
CATCH CX_SALV_MSG. "#EC NO_HANDL
ER
ENDTRY.
*
* Display the ALV
O_ALV->DISPLAY( ).
VIEW_MAINTENANCE_CALL
former_member207874
Explorer
Options
46,308
ABAP Development
Purpose:
Step1:
Step2:
Change the table structure with the addition of new field ‘EMP_AGE’ and
activate it:
Now if we display the table it will also display the new field with initial
value:
But the table maintenance generator will not contain the new field:
Step3:
Now we will adjust the Table Maintenance Generator so that this
additional field is added and other functionalities in the Table Maintenance
Generator remains intact.
Get the Function Group from the Table Maintenance Generator Display:
Go to tcode SE80 and open the function group and select the screen
number and click on Layout from toolbar.
This Design Screen will appear:
Add the column header text as follows: Name the header text field as-
*ZTEST_EMP-EMP_AGE
Save and Back. Go to Flow Logic tab and add the following line indicated:
Go to Element List->General Tab: Tick the red marked field as dictionary
field.
We will change Employee age as 30 and save the record. In the table
display we can see that age is updated.
Internal Table "TOTAL" (View
Cluster)
Definition
The table "TOTAL" contains all data which are read, changed, and created in the view cluster maintenance.
You can access the table "TOTAL" for a view cluster subobject via the field symbol <VCL_TOTAL>, if the
Structure
Structure
For views or tables without a text table, The internal table has the structure of the view or table, and also a
Example
For tables with a text table, connected via the foreign key relationship TEXT, the structure of the table
consists of the structure of the entity table, text table, and also two processing flags and a selection flag.
Example
Note
The structure of the table "TOTAL" is not transparent and the table has no header line. To access the table
fields, it isadvisable to define a record with the appropriate structure. The fields can be accessed via the
record after assigning an "TOTAL" table entry to the record, e.g. in a loop over the table or in a READ
TABLE statement.
Each record in the table "TOTAL" contains processing and selection flags . They can be found in a loop for
Changing "TOTAL"
If the table "TOTAL" is to be changed, for example, to create, delete, or change hidden entries, the form
routine EDIT_VIEW_ENTRY must be called as external perform in the function group containing the
generated maintenance dialog modules for the subobject. The routine changes the entry in the data tables,
sets the processing flag and updates the view maintenance internal status information for the subobject.
Specify parameters:
Parameter Explanation
SELLIST Selection conditions against which the validity of the entry to be created is checked
The routine returns the return code SY-SUBRC = 0 if the action was successful.
Delete an entry:
data: error_flag(1) type c,
Teilobjekt_wa like 'Teilobjektname'.
* Zugriff auf Daten und Verwaltungstabellen für Teilobjekt bereitstellen
vcl_set_table_access_for_obj using 'Teilobjektname'
changing error_flag.
Teilobjekt_wa =....
perform edit_view_entry(saplfugr)
* saplfugr ist das Rahmenprogramm, der zur Generierung
* benutzten Funktionsgruppe
tables <vcl_extract> <vcl_total>
<vcl_header> <vcl_namtab>
<vcl_dpl_sellist>
using Teilobjekt_wa 'DEL'.
Note
The entry to be created is checked against the conditions in the parameter SELLIST. If the subobject
contains subset fields, an appropriate list of conditions must be passed for this entry.
We generally use TMG to create, change and delete entries from the DB
table. By following the steps mentioned in this post, you can change the
look and feel of the screen as per your requirement.
In my case, I’m using the DB Table with the structure illustrated below.
Step 2: Create TMG for the Table.
I’ve used ‘One Step’ as a maintenance type and Overview Screen ‘110’.
Step 4: Click on the ‘Layout’ option, it will navigate to the screen painter.
If there are several fields, we need to scroll the page to view the fields.
But we can avoid the above case by changing the value in the Attributes
section.
Step 5: Proceed to attributes section in step 3.
In the Attributes section, you can find the Editing field in the Other
Attributes section.
Step 6: Change it as per the requirement and make use of excess space
on the screen.
Here, I’ve changed it from 80 to 100 so that I can view all the fields at a
time without the need to scroll.
Step 7:
Double click on the tab below the field that you would like to move and
change the value of the column field.
If you would like to change the visible length of the field, you can do so by
changing the Vis. Length field.
Step 8: Double click on the field which you would like to modify the
properties.
In my case, I’ve changed the visible length of the Last Name field to 20.
Now, the screen layout would be as below.
You can also change label of field without changing the data-element or
domain.
You can do so by changing the Text field.
Step 9: Double click on the field that you would like to change the
properties.
abap
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:
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
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.
Former Member
Options
196,610
ABAP Development
INTRODUCTION:
Step 2:
one step
Two step
--------------------------------------------------------------
--------
***INCLUDE LZTEMP_DTLSF01.
--------------------------------------------------------------
--------
FORM update.
** -- Data Declarations
DATA: lv_timestamp TYPE tzonref-tstamps.
*-- Time stamp conversion
CALL FUNCTION 'ABI_TIMESTAMP_CONVERT_INTO'
EXPORTING
iv_date = sy-datum
iv_time = sy-uzeit
IMPORTING
ev_timestamp = lv_timestamp
EXCEPTIONS
conversion_error = 1
OTHERS = 2.
FIELD-SYMBOLS: <fs_field> TYPE any .
LOOP AT total.
CHECK <action> EQ aendern.
** -- Updated By
ASSIGN COMPONENT 'UPDTD_BY' OF STRUCTURE <vim_total_struc> TO
<fs_field>.
IF sy-subrc EQ 0.
<fs_field> = sy-uname.
ENDIF.
** -- Updated On
ASSIGN COMPONENT 'UPDTD_ON' OF STRUCTURE <vim_total_struc> TO
<fs_field>.
IF sy-subrc EQ 0.
<fs_field> = lv_timestamp.
ENDIF.
READ TABLE extract WITH KEY <vim_xtotal_key>.
IF sy-subrc EQ 0.
extract = total.
MODIFY extract INDEX sy-tabix.
ENDIF.
IF total IS NOT INITIAL.
MODIFY total.
ENDIF.
ENDLOOP.
ENDFORM.
Select the Create event and press enter, the following screen
will appear.
--------------------------------------------------------------
--------
***INCLUDE LZTEMP_DTLSF02.
--------------------------------------------------------------
--------
FORM create.
** -- Data Declarations
DATA: lv_timestamp TYPE tzonref-tstamps.
*-- Time stamp conversion
CALL FUNCTION 'ABI_TIMESTAMP_CONVERT_INTO'
EXPORTING
iv_date = sy-datum
iv_time = sy-uzeit
IMPORTING
ev_timestamp = lv_timestamp
EXCEPTIONS
conversion_error = 1
OTHERS = 2.
** -- Created On & Created By
ztemp_dtls-crtd_by = sy-uname.
ztemp_dtls-crtd_on = lv_timestamp.
ENDFORM.
FORM get_org.
TYPES:
BEGIN OF ty_t527x,
orgeh TYPE orgeh,
orgtx TYPE orgtx,
END OF ty_t527x.
DATA:
lwa_t527x TYPE ty_t527x,
lt_t527x TYPE TABLE OF ty_t527x,
lt_retval TYPE TABLE OF ddshretval,
lwa_retval TYPE ddshretval,
lt_fields TYPE TABLE OF dynpread,
lwa_fields LIKE LINE OF lt_fields.
DATA:
lv_line TYPE string.
zhr_dharmoff-orgex = lwa_t527x-orgtx.
ENDFORM. "get_org
*---------------------------------------------------------------------*
* view related PAI modules
* generation date: 12.02.2015 at 15:21:28 by user ABAP05
* view maintenance generator version: #001407#
*---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* MODULE get_org
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE get_org.
TYPES:
BEGIN OF ty_t527x,
orgeh TYPE orgeh,
orgtx TYPE orgtx,
END OF ty_t527x.
DATA:
lwa_t527x TYPE ty_t527x,
lt_t527x TYPE TABLE OF ty_t527x,
lt_retval TYPE TABLE OF ddshretval,
lwa_retval TYPE ddshretval,
lt_fields TYPE TABLE OF dynpread,
lwa_fields LIKE LINE OF lt_fields.
data:
lv_line TYPE string.
SELECT orgeh orgtx FROM t527x INTO TABLE lt_t527x WHERE sprsl = sy-langu.
lwa_fields-fieldname = 'ZHR_DHARMOFF-ORGGH'.
lwa_fields-fieldvalue = lwa_retval-fieldval.
lwa_fields-STEPL = lv_line.
APPEND lwa_fields TO lt_fields.
CLEAR: lwa_fields.
ENDMODULE. "get_org
*----------------------------------------------------------------------*
***INCLUDE LZHR_MAS_TIDI01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module GET_PERSA INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE get_persa INPUT.
TYPES:
BEGIN OF ty_T500P,
PERSA TYPE persa,
name1 TYPE PBTXT,
END OF ty_T500P.
DATA:
lwa_T500P TYPE ty_T500P,
lt_T500P TYPE TABLE OF ty_T500P,
lt_retval TYPE TABLE OF ddshretval,
lwa_retval TYPE ddshretval,
lt_fields TYPE TABLE OF dynpread,
lwa_fields LIKE LINE OF lt_fields.
data:
lv_line TYPE string.
lwa_fields-fieldname = 'ZHR_MAS_TID-PERSA'.
lwa_fields-fieldvalue = lwa_retval-fieldval.
lwa_fields-STEPL = lv_line.
APPEND lwa_fields TO lt_fields.
CLEAR: lwa_fields.
*********************************************************************
*********************************************************************
*----------------------------------------------------------------------*
***INCLUDE LZHR_MAS_TIDI02.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module GET_BTRTL INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE get_btrtl INPUT.
TYPES:
BEGIN OF ty_T001P,
BTRTL TYPE BTRTL,
BTEXT TYPE PBTXT,
END OF ty_T001P.
DATA:
lwa_T001P TYPE ty_T001P,
lt_T001P TYPE TABLE OF ty_T001P,
lt_retval1 TYPE TABLE OF ddshretval,
lwa_retval1 TYPE ddshretval,
lt_fields1 TYPE TABLE OF dynpread,
lwa_fields1 LIKE LINE OF lt_fields1.
data:
lv_line1 TYPE string.
lwa_fields1-fieldname = 'ZHR_MAS_TID-BTRTL'.
lwa_fields1-fieldvalue = lwa_retval1-fieldval.
lwa_fields1-STEPL = lv_line1.
APPEND lwa_fields1 TO lt_fields1.
CLEAR: lwa_fields1.