cancel
Showing results for 
Search instead for 
Did you mean: 

How to create cds entity with Association to table function with input parameter

aliaksandr_yazerski
Discoverer
0 Kudos

I am referring to URL:

https://cap.cloud.sap/docs/advanced/hana

Please get back to me on the following feedback:

Hello

I have table function with input parameter. Entity which represent this table function is define like

namespace cii.persistence;
@cds.persistence.exists
@cds.persistence.udf
entity Test_Hierarchy_Function(in_email: String) {
key nodeID: Integer;
superParent: Integer;
hierarchyLevel: Integer;
parentNodeID: Integer;
description: String;
drillState: String;
interest: String;
score: Integer;
email: String;
}

And I have another CDS view like

namespace cii.persistence;
using {cii.persistence as cii} from '.';
@cds.persistence.exists
entity Profile_Admin_View {
customer_id: Integer64;
key email: String(255);
customer: Association to one cii.Customer_With_Consent on customer.customer_id = customer_id;
consent_status: String;
is_legitimate: Boolean @Consumption.filter:{ mandatory:true };
interest_1: String;
interest_2: String;
interest_3: String;
interest_4: String;
interest_5: String;
criticality_1: Integer;
criticality_2: Integer;
criticality_3: Integer;
criticality_4: Integer;
criticality_5: Integer;
//table_function: Association to many cii.Test_Hierarchy_Function(in_email = $projection.email);
}

And I want to add Association to my table function and somehow pass input parameter (value of 'email' field).

But I don't have any idea how it can me done. And CAP documentation also doesn't explain how to reach this.

Please help me

0 Kudos

The idea is that the user of the association provides the value, like in

@cds.persistence.exists
@cds.persistence.udf
entity T( P: String ) {
  key id: Integer;
}
entity E {
  key id: Integer;
  t: Association to T;
}
entity V as select from E {
  id,
  t(P: 'E').id as tid
};

Accepted Solutions (0)

Answers (1)

Answers (1)

robinjayasinghe
Advisor
Advisor
0 Kudos

Using an entity mapped to an UDF is currently not supported in CAP CDS. You could, however, introduce an additional (view) entity that wraps the UDF entity and use that as a target entity of your association. Please check our documentation for further details.

aliaksandr_yazerski
Discoverer
0 Kudos

Thank you for your reply. Unfortunarly your documentation doenn't explain how to dynamicly pass input parameter to such view.

You provided example for calculation view.

@cds.persistence.exists
@cds.persistence.calcview
entity AddressCalcView (USERID: Integer) {
key id: Integer;
};
view WeUseAddressCalcView as select from AddressCalcView(USERID: 4711);

Then you wrap this calculation view to additional view. But when you define this additional view you hardcoded input parameter.

Is it possible to input parameter for this wrap view in association?

robinjayasinghe
Advisor
Advisor