cancel
Showing results for 
Search instead for 
Did you mean: 

'managed' aspect adding createdBy_user, modifiedBy_user columns in SAP CAPM framework

sreehari_vpillai
Active Contributor
0 Kudos
809

mtayaml.txt

packagejson.txt

Hello .

I have a simple CDS structure like below.

namespace com.atom.app; 
using {managed ,Currency , temporal } from '@sap/cds/common'; 
entity Product { 
key productId   : Integer; 
productType : Integer; 
name        : String(30); 
description : String(100); 
basePrice   : Decimal(10, 3); 
currency    : Currency ; 
ItsProductType : Association to one ProductType on ItsProductType.productTypeId = $self.productType; 
}; 

entity ProductType : managed { 
key productTypeId : Integer; 
name          : String(20); 
description   : String(100); 
ItsProducts   : Association to many Product on ItsProducts.productType = $self.productTypeId;
 };

if you look at the ProductType entity , I am using managed aspect. I am deploying this structure to HANA Express edition XSA ( virtual machine ). Corresponding hdbcds has the below fields

using COM_ATOM_APP_PRODUCT as COM_ATOM_APP_PRODUCT;
entity COM_ATOM_APP_PRODUCTTYPE {
  CREATEDAT : UTCTimestamp;
  CREATEDBY : String(255);
  MODIFIEDAT : UTCTimestamp;
  MODIFIEDBY : String(255);
  key PRODUCTTYPEID : Integer;
  NAME : String(20);
  DESCRIPTION : String(100);
  ITSPRODUCTS : association[*] to COM_ATOM_APP_PRODUCT on ITSPRODUCTS.PRODUCTTYPE = PRODUCTTYPEID;
};

But, when I am trying to post a record against this entity set , it throws an error message saying " "message": "invalid column name: CREATEDBY_USER"

Backend logs :

ERR query: 'INSERT INTO com_atom_app_ProductType ( productTypeId, name, description, createdAt, createdBy_user, modifiedAt, modifiedBy_user, createdBy, modifiedBy ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ? )

Why is the framework expecting the table to have createdBy_user & modifiedBy_user ? Is it anything to do with the version of npm packages I am using ?

error is thrown from my VS code ( when I run CDS watch ) and from XSA as well after deployment.

attached mta.yaml and package.json of my CDS project

Accepted Solutions (0)

Answers (1)

Answers (1)

gregorw
Active Contributor
0 Kudos

The column name is CREATEDBY not createdBy_user.

sreehari_vpillai
Active Contributor
0 Kudos

It must have been. But , not sure why , the framework expected createdBy_user.

this was the error I got.

ERR query: 'INSERT INTO com_atom_app_ProductType ( productTypeId, name, description, createdAt, createdBy_user, modifiedAt, modifiedBy_user, createdBy, modifiedBy ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ? )

anyway , after re pushing certain more changes , this issue doesnt show up any more ( tbh I don't know what fixed it )