Hello SAP Community Members,
We hope this post finds you well.
While there are few others which generalizes on extending standard APIs, we would like to call out the steps required to extend the API_QUALITYNOTIFICATION, should you have the same requirement(s).
Our goal is to add a field to the standard API response. This process can be adapted to add or extend multiple fields as needed.
Finding the Service Definition for the Standard API
The first step is to locate the Service Definition. For our example, the Service Definition is API_QUALITYNOTIFICATION. You can find the Service Definition using the API URL or alternatively, you can use Eclipse to perform a pattern search with the API name.
Once you have the Service Definition, identify the fields within the entities present in the service definition. For our requirement, we needed to add the NotificationPriorityText field. The path for this field is as follows:
> A_QltyNotification (viewEntity)
> R_QltyNotificationTP (viewEntity)
> I_QltyNotification (View)
> I_Notification (View)
> I_NotificationPriority (View)
> I_NotificationPriorityText (View)
> NotificationPriorityText (Field)
Creating extendView / extendViewEntity
To begin, create a new Data Definition using the template VIEW > extendView.
[Choose extendView if the original data source is a View, or extendViewEntity if the original data source is a viewEntity.]
In our case, we extended I_QltyNotification first as it was the initial CDS view from the top (note that associations cannot be used in an extendViewEntity).
extend view I_QltyNotification with <YOUR EXTEND VIEW NAME>
association [1..1] to I_NotificationPriorityText as _NotificationPriority1 on
_NotificationPriority1.NotificationPriority = $projection.notificationpriority and
_NotificationPriority1.NotificationPriorityType = $projection.notificationprioritytype and
_NotificationPriority1.Language = $projection.masterlanguage
{
_NotificationPriority1.NotificationPriorityText
}
Important Notes:
- Always choose the first CDS view from the top to minimize the number of extended views needed.
- Ensure all key fields are included in the association's ON condition. For I_NotificationPriorityText, this includes NotificationPriority, NotificationPriorityType, and Language.
Next, proceed step by step, creating one extendView / extendViewEntity at a time and adding your extended field. For our example, after extending I_QltyNotification, we extended R_QltyNotificationTP (viewEntity) next.
extend view entity R_QltyNotificationTP with {
Notification.NotificationPriorityText
}
Finally, extend A_QltyNotification (CDS View Entity), which is already exposed in the API_QualityNotification Service Definition.
extend view entity A_QltyNotification with
{
_QltyNotification.NotificationPriorityText
}
Conclusion
You have successfully extended the standard API. The newly added field can now be seen in the standard API response.
Feel free to reach out if you have any questions or need further clarification.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |