Operations on Services in SAP CAP

Introduction

In previous article we have explored the ways to define services in SAP CAP. In this article we will learn about the operations on Services in SAP CAP.

Operations on Services in SAP CAP

  1. Ignoring fields from Services: We can ignore fields using annotation @cds.api.ignore
  2. Adding Action and Functions: We can directly call a function/action, like we have used cancelLeave above, by mentioning it in node.js while calling the service. This can be done in two ways:
    1. Unbound action: For this type of actions, we mention the action in the service itself

srv.on(‘cancelLeave’, (req) => {

// do something …

})

  1. Bound action: For this type of actions, we mention the action at entity level. It means, we will have to mention the name of the entity during the call

srv.on(‘getEmployeeCount’, ‘Employees’, (req) => {

// do something …

})

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.