Top 30 SAP CAP Interview Questions and Answers

SAP CAP (Cloud Application Programming) model is the go-to programming model for business applications on SAP HANA Cloud and SAP BTP. It is a promising programming model in the ERP world and is a front-runner in SAP’s Cloud journey. In this blog post, let’s know about the commonly asked Top 30 SAP CAP Model Interview Questions and Answers.

SAP CAP Model Interview Questions

Top 30 SAP CAP Interview Questions and Answers –

Q1. What is SAP CAP Model?

AnsSAP CAP (Cloud Application Programming) Model is the programming model for business applications on SAP HANA Cloud and SAP Business Technology Platform (BTP). SAP CAP is used to develop new applications and extend existing SAP applications.

Q2. What are the basic layers of SAP CAP Model?

AnsThe basic layers of CAP Model are CDS, SAP Fiori, Java/Node.js, and SAP HANA. With the CAP approach, we will use CDS to define models and services. JAVA and node.js will be used to handle custom logic and complex validations. Fiori apps built in CAP will be used to transmit events that other services can pick up and to receive incoming requests that can trigger services. And with CAP, we will create native HANA Cloud Database artifacts such as tables, views, functions etc.

Also Read – SAP CAP Model

Q3. True or False.
For SAP BAS DEV Space, you can change the ‘SAP Extensions’ of your already created dev space at any point in time and you can delete any existing SAP extension which is of no use or can add a new one.

Ans True 

Q4. What are some restrictions of the free tier plan of SAP Business Application Studio?
  • A user can only have up to 2 dev spaces.
  • A user can only have 1 dev space in the RUNNING state at a time.
Q5. What is mta.yaml file in CAP Project?

AnsA Multi-Target-Application is a development descriptor file which is used to define the elements and dependencies of a multi-target application (MTA) and it is comprised of multiple modules that are developed using different programming languages and designed to run on different target runtime environments but with a single & consistent lifecycle.

Q6. What are the components of mta.yaml file? 
  • Global Elements contains application version and identifier, description (optional)
  • Modules modules created in the application such as SAP HANA db module, node.js module etc.
  • Resources Dependent services that are not provided by the application
  • Properties These can be specified when the value has to be determined during the deployment.
  • Parameters Reserved variables of a module, which can be accessed by other modules.
Q7. What is the difference between mta.yaml file and mtad.yaml file?

Ansmta.yaml file is a development descriptor file for a Multi-Target-Application (MTA). Information in mta.yaml file provides instructions for the MTA development and build process.

Mtad.yaml file is a deployment descriptor file for a Multi-Target-Application (MTA). Information in mtad.yaml file provides instructions for the deploy service.

Q8. What is package.json file in a SAP CAP Project?

AnsA package.json file is an application package descriptor file which is required for the configuration of the MTA project. For example, to set the version and the options of the deploy program. In case of CAP projects, this file is shared by all three modules i.e. db, srv, app.

Also Read – Create SAP Fiori Application with SAP CAP Model

Q9. What does npm install do?

Ansnpm install reads the dependencies from your package.json file and downloads all the specified modules into your CAP project from the internet.

Q10. What is package-lock.json file in SAP CAP Project?

AnsA package-lock.json file is generated in the CAP project when we execute the command npm install. It is created for locking the dependencies with the installed version. It will install the latest version of that package.

Q11. Select the correct answer.
AnsWhile defining the OData service in the CAP project, what is the extension of the file that you create?
  1. .odata
  2. .hdbcds
  3. .cds
  4. .hdbview
Q12. What is @sap/cds/common? Explain in brief.

Ans@sap/cds/common is a prebuilt model provided by SAP CAP and this prebuilt model provides the common types and common aspects for reuse.

Common Reuse Aspects are – a) cuid – used to add universally unique primary keys having type as UUID,     b) managed – used to capture 4 elements in the entity as Created At, Created By, Modified At, Modified By,   c) temporal – will add two elements in entity as Valid From, Valid To

Common Reuse Types are – a) Country, b) Currency & c) Language

Q13. What is Approuter in SAP CAP project?

AnsApprouter is an application router which provides a single point-of-entry for an application running in the Cloud Foundry environment on SAP BTP. Approuter is used to authenticate users, rewrite URLs, and forward requests to other microservices with user info.

Q14. What are the types of Application Router (Approuter)?

AnsThere are two types of Approuter –

  • User defined approuter
  • SAP defined approuter i.e., Managed approuter.
Q15. What is Managed Application Router?

AnsThe managed application router enables users to access and run HTML5 applications in a cloud environment without the need to maintain their own runtime infrastructure. SAP recommends going with Managed Application Router in most cases except some advanced cases like when application router extensibility is required.

Also Read – Add Security to SAP Fiori Application with Approuter

Q16. Explain in brief about the concept ‘route’ in SAP CAP Model.

AnsRoutes are nothing but the set of rules that decides which request should be forwarded to which destination. Routing configuration is done in the xs-app.json file of the app module.

Q17. Name the annotations used in CAP project to achieve below functionalities – 

a) to enable edit sessions with draft states in Fiori application created using SAP Fiori elements.

Ans@odata.draft.enabled

b) to enable value help functionality in Fiori application.

Ans@cds.odata.valuelist

Q18. What is xs-app.json file from the app module of the CAP Project?

Ansxs-app.json file from the app module of the CAP Project is the routing configuration file. Which request should be forwarded to which destination i.e. routes are defined inside the xs-app.json file. Its content is formatted according to JavaScript Object Notation (JSON) rules.

Q19. Scenario-based question.

Suppose in a service in the srv folder, you have defined a service entity ‘ABC’ as a projection on a table entity, and inside the same service if you have defined one more service entity ‘XYZ’ as a projection on a view entity which is a view on the same table entity. Now code editor of BAS is showing you an error message as ‘can’t auto-redirect to any of the service entity’ then how do we resolve this error?

AnsYou can use the annotation @cds.redirection.target: true before any of the service entities (ABC or XYZ) to make that entity a preferred redirection target. This will resolve the ambiguity that occurred due to both service entities trying to fetch the same data.

Q20. Scenario-based question.

While logging in to Cloud Foundry & setting the CF Targets, suppose you are successfully signed in to the Cloud Foundry and now while selecting Cloud Foundry target, the organization and space are not available then what you will do to set the correct organization and space?

AnsThis issue generally occurs when we sign in to the incorrect cloud foundry endpoint. So, I will check whether the cloud foundry endpoint to which I did the sign-in is correct, by comparing it with the correct endpoint available at the BTP subaccount level. Then I will execute the following commands in the command pallette of the BAS.

  • cf api <CF API endpoint URL> Enter the correct CF endpoint from the subaccount level.
  • cf login Enter your email and password to log in.
Q21. What is xs-security.json file of SAP CAP project?

Ansxs-security.json file is an application security descriptor file that defines the security options i.e., details of the authentication methods and authorization types to access the application.

Q22. What are the components of xs-security.json file? 
  • Scopes – A list of limitations regarding privileges and permissions and the areas to which they apply
  • Role Templates – Details about roles to apply to user
  • Attributes – List of yet undefined details like name of country or cost center.
Q23. Explain about security concept ‘Roles’ of SAP BTP.

AnsRoles are based on role templates, which are provided by applications developed using the CAP Model. Roles decide which features users can view and access, and which actions they can perform. User roles are derived from role templates that are defined in the security descriptor file (xs-security.json) of the application.

Q24. What is the difference between Authentication and Authorization concepts used in SAP CAP?

Authentication Authentication verifies the user’s identity and the presented claims such as granted roles and tenant membership. In short, Authentication provides access to the service. And to provide access to the service, you should know who is trying to access the service.

Authorization Authorization controls how the user can interact with the application’s resources according to the granted privileges.

For exampleLet’s consider an application accessed by user A and user B which means both users A and B are authenticated. Now, user A can only READ and user B can READ and WRITE the application then it is called user A is authorized to READ and user B is authorized to READ & WRITE.

Q25. What is XSUAA service?

AnsThe full form of XSUAA is ‘XS User and Authentication and Authorization’. XSUAA is a cloud-based service that is used for authentication and authorization of applications and services running on the SAP BTP. It is a full-fledged OAuth 2.0 authorization server that allows you to protect your endpoints in a productive environment.

Also Read – Add Security to SAP Fiori Application with XSUAA

Q26. Name the predefined pseudo roles that are currently supported by SAP CAP Model.
  • authenticated-user refers to (named or unnamed) users who have presented a valid authentication claim such as a logon token.
  • system-user denotes an unnamed user used for technical communication.
  • any refers to all users including anonymous ones (that means, public access without authentication).
Q27. Explain in brief about the restriction @requires in SAP CAP Model.

Ans@requires annotation is used to authorize which role a user requires to access a CDS resource. @requires allows specifying one or more user roles (as a single string or an array of strings) that the current user must be assigned. @requires restriction is applied to the CDS resources – service and action/function. In case of service resource, Role/Roles used for restriction in @requires will be applicable to all the entities of that service.

Example – service <service_name> @(requires: ‘<role_name>’);

Q28. Explain in brief about the restriction @restricts in SAP CAP Model.

Ans@restrict annotation is used to define authorization on the entity level through an array of privileges given as grant statements in the form { grant:<events>, to:<roles>, where:<filter-condition> } whereas ‘grant’ is mandatory property while ‘to’ and ‘where’ is optional property. Possible values to those properties will be like this –

  • grant accepts CDS events like READ, CREATE, UPDATE, DELETE, or * as a wildcard for all the events.
  • to property lists all the roles
  • where-clause – to filter out the entity data based on user values or entity elements.

Example –  entity <entity_name> @(restrict: [{grant: ‘<event_name>’, to: ‘<role_name>’, where: <condition>}])

Follow the udemy course SAP BTP Training – From Basics to Advanced [Hands-on] to learn in detail about – Applying Roles based Security to CAP Services, Generating Roles in xs-security file, Creating and Managing Role Collections, and Testing the Fiori Application using Postman.

Q29. What are the ways to create user roles in BTP from SAP CAP Project?

AnsThere are two ways to create user roles in SAP BTP from SAP CAP Project –

  1. Configure roles directly in xs-security.json file by defining scopes, role templates, and attributes OR
  2. Add roles to the services in srv folder and to automatically configure those roles in the xs-security.json file, execute the following command in the command pallette of your CAP project – cds compile srv/ --to xsuaa > xs-security.json

Once roles have been configured in the xs-seurity.json file by the two ways as mentioned above, build and deploy the CAP project then the roles will become available under security → Roles at subaccount level in SAP BTP.

Q30. Can we apply role-based restriction on the element/field of an entity in SAP CAP Service entity?

AnsNo, you can’t apply restrictions on the element/field of an entity. Restrictions can be defined on the following CDS resources only – Services, Entities, Actions/Functions.

» Other Interview Questions…

Top 20 SAP BTP Interview Questions and Answers

Conclusion – 

Congrats! I hope the above top 30 SAP CAP Interview Questions will help in your interview preparation and will help you to clarify the concepts as well. All the very best!!!

Please feel free to comment and let us know your feedback. 😊

If you liked it, please share it! Thank You!

» Free Step-by-Step SAP BTP Training Tutorial Exercises

What is SAP BTP? | SAP BTP Introduction
How to create SAP BTP Trial Account?
How to create SAP HANA Cloud Instance?
Create SAP Fiori Application with SAP CAP and SAP HANA Cloud – Part 1
Create SAP Fiori Application with SAP CAP and SAP HANA Cloud – Part 2
Add Security to SAP Fiori Application with XSUAA and Approuter

7 thoughts on “Top 30 SAP CAP Interview Questions and Answers”

  1. Thank you creators for these questions. All important points covered
    Also can I find a detailed explanation for question no. 25

    Reply

Leave a Comment