Skip to Content
0
Sep 14, 2023 at 02:03 AM

Creating an entity via EML - timestamp fields are not filled

69 Views Last edit Sep 14, 2023 at 02:19 AM 3 rev

Hi community,

I have created a simple RAP BO (without exposing it as OData) and now trying to create an entity using EML. The issue is, timestamp fields and user fields are not filled automatically. We're on S/4HANA 2022 SPS00.

image.png

The code below is my CDS view and the behavior definition.

@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Job Status'
define root view entity ZI_ACCOUNTING_JOB as select from zaccounting_job
{
    key companycode as Companycode,
    key fiscalyear as Fiscalyear,
    key accountingdocument as Accountingdocument,
    jobname as Jobname,
    jobcount as Jobcount,
    jobkey as Jobkey,
    status as Status,
    @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,
    @Semantics.systemDateTime.localInstanceLastChangedAt: true
    local_last_changed_at as LocalLastChangedAt,
    @Semantics.systemDateTime.lastChangedAt: true
    last_changed_at as LastChangedAt
}
managed implementation in class zbp_i_accounting_job unique;
strict ( 2 );

define behavior for ZI_ACCOUNTING_JOB alias AccountingJob
persistent table ZACCOUNTING_JOB
lock master
authorization master ( instance )
//etag master <field_name>
{
  create;
  update;
  delete;

}<br>

EML for creating an entity.

      MODIFY ENTITIES OF zi_accounting_job
        ENTITY accountingjob
        CREATE FIELDS ( companycode
                        fiscalyear
                        accountingdocument
                        status
                        jobkey )
        WITH VALUE #( FOR key IN mt_key_for_insert INDEX INTO index (
                       %cid = index
                        companycode = key-companycode
                        fiscalyear = key-fiscalyear
                        accountingdocument = key-accountingdocument
                        status = zif_update_job_status=>c_status-running
                        jobkey = iv_jobkey  ) )
        reported data(ls_create_reported)
        failed data(ls_create_failed).<br>

From my understanding, just by adding annotations, those fields are filled automatically. Are there any steps missing?

Regards,

Mio

Attachments

image.png (15.4 kB)