You are on page 1of 10

Change Record in Table Maintenace using Events

https://archive.sap.com/discussions/thread/3408672

Get Started (http://go.sap.com/community/getting-started.html)

(http://go.sap.com/index.html)

(https://onedx.find.sap.com)

(htt
ps:/
/sh
are
dui.
ser
vice
s.sa
p.c
om
/pro
tect
ed.
htm
l?re
f=ht
tps:
//ar
chiv
e.s
ap.
co
m/)

(https://www.facebook.com/sapcommunitynetwork?ref=ts)
(https://plus.google.com/u/0/+SAPCommunities/posts)

(https://twitter.com/sapcommnet)
(https://instagram.com/sap/)

(https://www.youtube.com/user/SAPCommunities)

(https://www.linkedin.com/company/sap)

(http://www.slideshare.net/SAP)

Privacy (http://go.sap.com/about/legal/privacy.html)
Terms of Use (http://go.sap.com/corporate/en/legal/terms-of-use.html)
Legal Disclosure (http://go.sap.com/about/legal/impressum.html)
Copyright (http://go.sap.com/about
/legal/copyright.html)
Trademark (http://go.sap.com/about/legal/trademark.html)
Sitemap (http://www.sap.com/sitemap/index.html)
Newsletter (https://go.sap.com/registration/newsletter.html)

1 of 10

23-12-2016 18:04

Change Record in Table Maintenace using Events

https://archive.sap.com/discussions/thread/3408672

Archives (/) /

Discussions Archive (/discussions)

/ ABAP Development (/discussions/space/abap) /

Change Record in Table Maintenace

using Events

Hi,

(https://people.sap.com

I have a z table and have created table maintenanace for it. In my Z table I have below fields.

/vikas.badhan2)

delivery no

vikas badhan (https://people.sap.com/vikas.badhan2)

delivery type

April 02, 2015 at 03:51 AM

created on

0 Likes

created by
changed on
chnged by
When I am creating a new entry. Created on and Created by are geeting filled automatically
using Event 05.
But, When I am trying to change the record any field. Change on and changed By are not
getting filled in the maintenace screen as well as in database.
Please let me know how we can handle this.
Thanks in Advance.
Vikas

Arindam Mondal (https://people.sap.com/arindam.mondal)replied

(https://people.sap.com/arindam.mondal)

2 of 10

August 19, 2013 at 09:23 AM

23-12-2016 18:04

Change Record in Table Maintenace using Events

https://archive.sap.com/discussions/thread/3408672

Hi,
May be you need to do it in the following event:
01

Before saving the data in the database

Check the below link for further details:


http://wiki.sdn.sap.com/wiki/display/ABAP/TABLE+MAINTENANCE+GENERATOR+and+ITS+EVENTS (http://wiki.sdn.sap.com
/wiki/display/ABAP/TABLE+MAINTENANCE+GENERATOR+and+ITS+EVENTS)
Cheers,
Arindam
0

(https://people.sap.com/arahiman.nadaf)

Abdul Rahiman Nadaf (https://people.sap.com/arahiman.nadaf)replied

August 19, 2013 at 10:10 AM

Hi,
Use event number 01 to serve your requirement.
And in subroutine,use EXTRACT and TOTAL internal tables to update your database
table.
EXTRACT and TOTAL are system defined internal tables.Check for these tables on
internet.
This would help you.Let me know if you want more help.
Regards,
Abdul
0

(https://people.sap.com/vikas.badhan2)

vikas badhan (https://people.sap.com/vikas.badhan2)replied

August 19, 2013 at 11:25 AM

Hi Abdul,
I have checked in Debugging mode and changed the values. It worked. but not sure
how we will achieve this through code because the values are coming as text in field
LINE.
Please help.
Thanks in Advance.

3 of 10

23-12-2016 18:04

Change Record in Table Maintenace using Events

https://archive.sap.com/discussions/thread/3408672

Vikas
0

(https://people.sap.com/venkat.sesha)

V S BHARGAV MYLAVARAPU (https://people.sap.com/venkat.sesha)replied


August 19, 2013 at 11:44 AM

Hi Vikas,
How many screen do you have...?
These discussions happened lot of times in SCN. so
Please be specific about the issue.
You can achieve it several ways.. Using Events or
using PBO/PAI code of the particular screen in the
TMG and the Function Group. What is your problem
exactly.
0

(https://people.sap.com/arahiman.nadaf)

Abdul Rahiman Nadaf (https://people.sap.com/arahiman.nadaf)replied


August 19, 2013 at 13:13 PM

Hi Vikas,
What is the issue exactly??
Regards,
Abdul
0

swadhin ghatuary (https://people.sap.com/swadhin.ghatuary)replied

(https://people.sap.com/swadhin.ghatuary)

August 19, 2013 at 11:54 AM

Hello Vikas ,
you have to use 01 event instead of 05 as you already create the record.
01

Before saving the data in the database

02

After saving the data in the database

03

Before deleting the data displayed

04

After deleting the data displayed

05

Creating a new entry

4 of 10

23-12-2016 18:04

Change Record in Table Maintenace using Events

https://archive.sap.com/discussions/thread/3408672

(https://people.sap.com/prabakaran.a)

Prabakaran A (https://people.sap.com/prabakaran.a)replied

August 22, 2013 at 07:19 AM

Hi,

Have to write code for updating the field Change on and changed by.
We can use the Even 01 and create the form routine
The field <VIM_XTOTAL_KEY> contains the key.
For changing the current record, we need to modify both the corresponding extract and
total table values.
The <ACTION> field indicates the current user action : new insertion or updation or
deletion.

FIELD-SYMBOLS: <record> TYPE ANY. " Work area for table


* Modify changed by and changed on fields for any updates
LOOP AT total.
* Assign the table header line to the work area
ASSIGN total TO <record>.
IF sy-subrc = 0. " If assigning is successful.
* Check if data was changed and get the corresponding line index
IF <action> = 'U' " Updated entry
Update the changed by and changed on to the total.
Thanks,
Prabakaran
Applexus Technologies
0

(https://people.sap.com/sravan.kilari3)

Sravan kilari (https://people.sap.com/sravan.kilari3)replied

August 19, 2013 at 12:59 PM

Hi Vikas,
you created table key field is delivery no.

5 of 10

23-12-2016 18:04

Change Record in Table Maintenace using Events

https://archive.sap.com/discussions/thread/3408672

can you check the one how to created table entries and events in table maintenance generator
.
http://wiki.sdn.sap.com/wiki/display/ABAP/TABLE+MAINTENANCE+GENERATOR+and+ITS+EVENTS (http://wiki.sdn.sap.com
/wiki/display/ABAP/TABLE+MAINTENANCE+GENERATOR+and+ITS+EVENTS)
0

Sreedhar Chittari (https://people.sap.com/chittari.sreedhar)replied

(https://people.sap.com/chittari.sreedhar)

August 19, 2013 at 13:02 PM

Hi Vikas,
Table maintenance event 5 will be triggered only, when a new entry is created.
Try other events like 01(Before saving) or 02(After Saving) to fill change date and change
time while changing a table entry
Hope this Helps
Sreedhar
0

Jeffin George (https://people.sap.com/jeffingeorge)replied

(https://people.sap.com/jeffingeorge)

August 22, 2013 at 07:43 AM

Hi Vikas,
The event 05 (New entries) will work only if you create new entries
When changing the data the event 05 will not work.
You have to use the event 01 (Before saving the data).
This event will be triggered when you save the data.
Regards,
Jeffin
0

6 of 10

23-12-2016 18:04

Change Record in Table Maintenace using Events

https://archive.sap.com/discussions/thread/3408672

(https://people.sap.com/alext.jose)

Alex T Jose (https://people.sap.com/alext.jose)replied

August 22, 2013 at 07:45 AM

Hi Vikas,
Go to the flow logic of the TMG screen where you input the values to the filled.
Ceck whether your field is included in the
CHAIN.
.
.
.
ENDCHAIN.
Statement in the PAI of the screen.
Please refer this code of such a TMG Screen attached below.

Regards.
0

Eric Peterson (https://people.sap.com/eric.peterson2)replied

(https://people.sap.com/eric.peterson2)

August 22, 2013 at 17:49 PM

I had this exact problem a month ago and solved it by putting this code in event 01, before
saving in the database.

7 of 10

23-12-2016 18:04

Change Record in Table Maintenace using Events

https://archive.sap.com/discussions/thread/3408672

FORM before_save.

DATA: f_indx LIKE sy-tabix. "Index to note the lines found

* Variable TOTAL is not transparent, this structure is how we access


* the individual fields.
DATA BEGIN OF l_row.
INCLUDE STRUCTURE zcatsappr_nogl.
INCLUDE STRUCTURE vimtbflags.
DATA END OF l_row.
*Add Changed-By and Changed-On for changed entries.
LOOP AT total.
CHECK <action> = aendern.
READ TABLE extract WITH KEY <vim_xtotal_key>.
IF sy-subrc EQ 0.
f_indx = sy-tabix.
ELSE.
CLEAR f_indx.
ENDIF.
l_row = total.
l_row-changed_on = sy-datum.
l_row-changed_by = sy-uname.
total = l_row.
MODIFY total.
CHECK f_indx GT 0.
extract = total.
MODIFY extract INDEX f_indx.
ENDLOOP.
sy-subrc = 0.
ENDFORM.

"before_save

The code was adapted from the sample in Event 01: Before Saving the Data in the Database (http://help.sap.com
/erp2005_ehp_04/helpdata/EN/91/ca9f0ba9d111d1a5690000e82deaaa/content.htm). Let me know if this doesn't work for you!

8 of 10

23-12-2016 18:04

Change Record in Table Maintenace using Events

https://archive.sap.com/discussions/thread/3408672

Benjamin Pereira (https://people.sap.com/benjnw)replied

(https://people.sap.com/benjnw)

January 20, 2014 at 17:19 PM

In my case, the problem wasn't solved. The fields aren't filled when I update data.
0

K Suresh (https://people.sap.com/k.suresh2)replied

(https://people.sap.com/k.suresh2)

January 20, 2014 at 22:01 PM

Use event 21 as change by and change date is for modification history, hence you
can keep them as hidden fields by changing the attributes of TMG screen and
populate as below. It will work in all scenarios.
ztab-changedby = sy-uname.
ztab-udate

= sy-datum.

ztab-utime

= sy-uzeit.

Thanks,
Suresh
1

Benjamin Pereira (https://people.sap.com/benjnw)replied

(https://people.sap.com/benjnw)

January 21, 2014 at 14:12 PM

Thanks K Suresh, but it worked when I added <ACTION> = AENDERN. before


of MODIFY total.
1

Amanda Ho (https://people.sap.com/aho)replied

(https://people.sap.com/aho)

April 02, 2015 at 03:51 AM

Thanks with event 21 the field was able to update. Example code as below:
" Populate update date field with today's date
ztbl-udate = sy-datum.

" If Update then modify table

9 of 10

23-12-2016 18:04

Change Record in Table Maintenace using Events

https://archive.sap.com/discussions/thread/3408672

IF <action> = aendern.
MODIFY ztbl.
ENDIF.

Thanks once again


0

Tharindu Dissanayake (https://people.sap.com/tharindud)replied

(https://people.sap.com/tharindud)

January 20, 2014 at 18:47 PM

I normally use Event 21 to fill the Changed by and Changed on fields.


0

10 of 10

23-12-2016 18:04

You might also like