cancel
Showing results for 
Search instead for 
Did you mean: 

Foreign key relationships between entities in SAP CAPM(node.js)

adarsh-kmr
Discoverer
0 Kudos

Hi Experts,

We have multiple entities which consists of several key fields in our CAPM application. How do we define foreign key relationships between entities?

I have 3 primary keys in my main entity Demo i.e. ID1,ID2,ID3. All these 3 keys make composite primary key.

Now once I create an association from Emp entity to Demo entity, then 3 default properties gets added in Emp entity i.e. toDemo_ID1, toDemo_ID2 and toDemo_ID3. But I do not want a default properties name, rather I need my own defined properties i.e. EmpID instead of toDemo_ID1, EmpId2 instead of toDemo-Id2 and EmpId3 instead of toDemo_ID3.

Below Is the entity format which we need. Please suggest how this can be acheived

entity Demo {

key ID1 : Integer;

key ID2: Integer;

key ID3: Integer:

…};

entity Emp {

toDemo: association to Demo;

EmpId1: referring to primary key ID1 of Entity Demo;

EmpId2: referring to primary key ID2 of Entity Demo;

EmpId3: referring to primary key ID3 of Entity Demo;

…};

entity Test {

toEmp: association to Emp;

TestId1: referring to EmpID1 of Entity Emp;

TestId2: referring to EmpID2 of Entity Emp;

TestId3: referring to EmpID3 of Entity Emp;

…};

Regards,

Adarsh

View Entire Topic
hjb
Advisor
Advisor
0 Kudos

CDS supports you perfectly with this:

entity Demo {
 key ID : Integer;
};
entity Emp {
 key emp: association to Demo;
}
entity Test {
 key test: association to Emp;
};

however, don't name the associations like the source entities, always give them semantically meaningful names (toDemo, etc)...

adarsh-kmr
Discoverer
0 Kudos

Hi Hans,

Thanks for your help and input.

As per your suggestion we changed the association name to a meaning full name. Thanks for highlighting the same. But I think my issue still exist.

I have 3 primary keys in my main entity Demo i.e. ID1,ID2,ID3. All these 3 keys make composite primary key.

Now once I create an association from Emp entity to Demo entity, then 3 default properties gets added in Emp entity i.e. toDemo_ID1, toDemo_ID2 and toDemo_ID3. But I do not want a default properties name, rather I need my own defined properties i.e. EmpID instead of toDemo_ID1, EmpId2 instead of toDemo-Id2 and EmpId3 instead of toDemo_ID3.

Below Is the entity format which we need. Please suggest how this can be achieved

entity Demo {

key ID1 : Integer;

key ID2: Integer;

key ID3: Integer:

…};

entity Emp {

toDemo: association to Demo;

EmpId1: referring to primary key ID1 of Entity Demo;

EmpId2: referring to primary key ID2 of Entity Demo;

EmpId3: referring to primary key ID3 of Entity Demo;

…};

entity Test {

toEmp: association to Emp;

TestId1: referring to EmpID1 of Entity Emp;

TestId2: referring to EmpID2 of Entity Emp;

TestId3: referring to EmpID3 of Entity Emp;

…};

hjb
Advisor
Advisor
0 Kudos

A managed association is a structured element with the augmented semantics that the sub elements describe a relationship to the target. With this, a managed association underlies the same flattening rules than any other structured element. If you don't agree with this please model your own elements and use unmanaged associations (relinquishing a lot of convenience).