Showing results for 
Search instead for 
Did you mean: 

Primary Key update in RAP

0 Kudos

Hello All,

We have a requirement, where the CDS have 3 primary keys, out of which 2 keys will be entered by the user, and the 3rd primary key should be auto populated based on the 2 keys, that were entered by the user.

Consider in the Fiori app, user enters value as A and B for the first two primary keys, on clicking save, the third primary key should be auto-populated as A-B.

Is this possible? While checking the SAP help documentation, I see the concepts of UUID, late numbering, Early numbering concepts, but unable to find a way to achieve the above functionality.


Active Contributor

Hi Naga,

Have you tried to use Adjust numbering concept?

It helps you to adjust key fields during save sequence.

Best wishes,

Ramjee Korada

0 Kudos

Hi Ramjee,

We are trying update the primary which is a character based one, so I guess the adjust numbering concept will not work in this scenario.

Thanks and Regards,


Product and Topic Expert
Product and Topic Expert
0 Kudos


We helped you to accept the answer, since there were no updates after few days. You can unaccept it anytime if you have further questions.

Kind regards,


View Entire Topic
0 Kudos

Yes, it is possible to auto-populate a primary key based on values entered by the user in a Fiori app using RAP (ABAP RESTful Programming Model).

One way to achieve this functionality is by using a before-create plug, which is executed before an instance of the entity is created. In this plug, you can check if the third primary key is empty and if so, populate it based on the values of the first two primary keys. Here is an example code snippet to achieve this:

@EndUserText.label : 'My Entity'

define entity MyEntity {

key field1: String(10);

key field2: String(10);

key field3: String(20);



@EndUserText.label : 'My Service'

service {



entity MyEntity as projection on mySchema.MyEntity

before create function myCreatePlug(ctx) {

if ( == null) { = + '-' +;





In this example, we define an entity MyEntity with three primary keys: field1, field2, and field3. We also define a service that exposes this entity and specifies a before-create plug named myCreatePlug. Inside this plug, we check if the value of field3 is null (i.e., not yet populated by the user), and if so, we concatenate the values of field1 and field2 with a hyphen separator to generate the value for field3.You can customize this example code to fit your specific CDS definition and naming conventions. Additionally, you may want to consider error handling for cases where the user inputs an already existing value for field3.

0 Kudos

We are currently using RAP Framework and have never seen this before-create plugin..

Is there any blog/sap help document for this?

Is this approach via CAP model?