‎2013 Aug 19 8:15 AM
Hi,
I have a z table and have created table maintenanace for it. In my Z table I have below fields.
delivery no
delivery type
created on
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
‎2013 Aug 19 8:22 AM
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
Cheers,
Arindam
‎2013 Aug 19 8:26 AM
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
‎2013 Aug 19 9: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
‎2013 Aug 19 10:24 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.
Vikas
‎2013 Aug 19 10: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.
‎2013 Aug 19 12:13 PM
‎2013 Aug 19 9:20 AM
Hi Vikas,
you created table key field is delivery no.
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
‎2013 Aug 19 10: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 |
‎2013 Aug 22 6: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
‎2013 Aug 22 4:25 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
‎2013 Aug 22 6:42 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.
‎2013 Aug 22 4:48 PM
I had this exact problem a month ago and solved it by putting this code in event 01, before saving in the database.
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. Let me know if this doesn't work for you!
‎2014 Jan 20 4:19 PM
In my case, the problem wasn't solved. The fields aren't filled when I update data.
‎2014 Jan 20 9: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
‎2014 Jan 21 1:07 PM
Thanks K Suresh, but it worked when I added <ACTION> = AENDERN. before of MODIFY total.
‎2015 Apr 02 2: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
IF <action> = aendern.
MODIFY ztbl.
ENDIF.
Thanks once again
‎2014 Jan 20 5:47 PM
I normally use Event 21 to fill the Changed by and Changed on fields.