on 2022 Apr 25 4:42 PM
Hi all.
We need to automatically update a timestamp field with the current date and time in a table that is not updated via maintenance view (SM30), every time that a record is inserted or updated. Is it possible to do it? If this is the case, how it can be done?
In SAP I know how to do it if the table is updated via SM30, but this is not the case.
Thanks in advance.
This is true.
It will only work with fields where the underlying table uses appropriate data elements such as
created_at : abp_creation_tstmpl;
last_changed_at : abp_locinst_lastchange_tstmpl;
local_last_changed_at : abp_lastchange_tstmpl;
or TZNTSTMPL
or TIMESTAMPL
Regards,
Andre
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it is not updated via SM30 how is it updated then?
Is it your own code in the Z-namespace?
Then you can simply store the current time that you get from the GET TIME STAMP command and store it in your DB table.
GET TIME STAMP - ABAP Keyword Documentation (sap.com)
In SAP S/4HANA you would use a RAP BO and you would add the following annotations to your CDS view and the framework would stored the data for you automatically.
@Semantics.user.createdBy: true
local_created_by as LocalCreatedBy,
@Semantics.systemDateTime.createdAt: true
local_created_at as LocalCreatedAt,
@Semantics.user.lastChangedBy: true
local_last_changed_by as LocalLastChangedBy,
//local ETag field --> OData ETag
@Semantics.systemDateTime.localInstanceLastChangedAt: true
local_last_changed_at as LocalLastChangedAt,
//total ETag field
@Semantics.systemDateTime.lastChangedAt: true
last_changed_at as LastChangedAt,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andre,
The annotation however does not seem to auto update isolated date and time fields.
For example, is there a way to auto-populate the fields for below example:
@Semantics.user.createdBy: true
local_created_by as LocalCreatedBy,
@Semantics.systemDate.createdAt: true
local_created_date as LocalCreatedDate,
@Semantics.systemTime.createdAt: true
local_created_time as LocalCreatedTime,
@Semantics.user.lastChangedBy: true
local_last_changed_by as LocalLastChangedBy,
//total ETag field
@Semantics.systemDate.lastChangedDate: true
last_changed_date as LastChangedAt,
@Semantics.systemTime.lastChangedAt: true
last_changed_time as LastChangedTime
User | Count |
---|---|
102 | |
9 | |
7 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.