‎2006 Mar 21 5:04 AM
Hi,
How to get(Date & Time) the recent updated records in a database table. The table will have the updated Date & Time fields also.
Thanks
Suganya
‎2006 Mar 21 5:10 AM
H Suganya,
You can do this in the table modification events part itself. Thus via sm14 or tcode, whenever u modify a record the events will get the modified date and time which can be later selected via a select stmt in ur program.
I shall explain u how to do it in table maintenance if needed.
Regards
Anjali
‎2006 Mar 21 5:15 AM
Hi,
Goto Utilities->tablemainte Gen.->Environment->Modification->Events.
(only if u have further acess...)
u can create a form for several events like:
- before saving an entry
- after saving an entry
- before deleting an entry
- before creating an entry
To exactly do the stuff:
05 - "At_create" press enter
in the Editor->
INCLUDE LZtableF03
form at_create.
Ztable-ZCREATEDATE = sy-datum.
Ztable-ZCREATETIME = sy-uzeit.
endform.save and activate.
Go back.
Create another event : 02 " After_save" press enter.
in the Editor.
inside same include:
FORM after_save.
DATA: lc_sap TYPE zco001-zawsys VALUE 'SAP'.
ztable-mandt = extract+0(3).Break-point. and chek the values in the "extract" and use offsets properly.
ztable-field1 = extract+3(3).
ztable-field2 = extract+6(15).
ztable-field3 = extract+21(20).
ztable-field4 = extract+41(40).
ztable-zcreatedate = sy-datum.
ztable-zcreatetime = sy-uzeit.
MODIFY ztable.
ENDFORM. "after_saveCheck out this weblog on table maintenance:
/people/sudheer.cheedella/blog/2006/02/20/extracting-data-in-table-maintenance
Regards,
Anjali
‎2006 Mar 21 5:21 AM
Hi,
I have mentioned below a portion of code wherein I use two ztables.
Refer this code:
SELECT * FROM ZPS001
INTO TABLE GT_ZPS001.
* Get the latest record.
CHECK GT_ZPS001[] IS NOT INITIAL.
READ TABLE GT_ZPS001 INTO WA_ZPS001 INDEX 1.
* CHECK FOR RUNNING DATE VALUE
IF S_ZRUNDT[] IS INITIAL.
SELECT * FROM ZCO001
INTO TABLE GT_ZCO001
WHERE ZCREATEDATE GE WA_ZPS001-ZRUNDT
AND ZCREATETIME > WA_ZPS001-ZRUNTIME.
ELSE.
SELECT * FROM ZCO001
INTO TABLE GT_ZCO001
WHERE ZCREATEDATE IN S_ZRUNDT.
ENDIF.ZPS001 table contains fields like last run date,last run time.
ZcO001 table is the database table to be updated.
Regards,
Gayathri
‎2006 Mar 21 5:32 AM
Hi Suganya,
If you want to know when the database record got inserted / modified then you should have two column added
to your database table.
add a column of type d and another column of type t.
then when you are inserting or updating a value in the database then update these columns as
1. date column with sy-datum.
2. time column with sy-timlo.
Without having two columns you cannot find the date and time.
Hope it helps.
Regards,
Maheswaran.B
‎2006 Mar 21 5:43 AM
are you saying that you want to READ the most recently updated entries in a table which has date and timestamp fields?
If so try,
select single datum max( uzeit ) as uzeit from ztab
into corresponding fields of ztab
where datum = ( select max( datum ) from ztab )
group by datum
.
If your table is very big it may need to be recoded for speed.