Employee Management Application

Context -

CAP application with below details -

Create an Employee entity containing the following fields:

  • Employee ID
  • First Name
  • Last Name
  • Email
  • Designation
  • Manager ID

Create an Project entity containing the following fields:

  • Project ID
  • Project Name

Note :-

  • One Employee can be associated with multiple projects.
  • Employee IDs should be generated in the format EMPYYYYNNN, where EMP is a fixed prefix, YYYY denotes the employee's year of joining, and NNN is an auto-incrementing sequence number. Example: EMP2026254
  • Whenever a new employee is onboarded, the Employee ID should be automatically assigned as the next sequential number based on the last existing employee record.
  • Each employee can access only their details.
  • Only Manager can add or remove any employee detail.

Integrate the SAPUI5 Application with the CAP Service -

  • Display all employee records in a SAPUI5 Table (sap.m.Table) when the application loads.
  • Implement a FilterBar on the initial page to enable employee search and filtering.
  • Upon selecting an employee, navigate to a Detail Page that displays:
    • Complete employee information
    • All projects assigned to the selected employee
  • Design the Detail Page using an Object Page Layout.
  • Provide functionality to create new employee records from the UI.

Steps -

Step 1 - Create cap application

Use the below command to create a cap application.

In our case, app name is - employee-management-cap

terminal-command
cds init employee-management-cap

move into the project folder and install the dependencies -

terminal-command
cd employee-management-cap
npm install

Step 2 - Create Required Entities

Create a schema.cds file inside the db folder to define the data model for the application.

We will define three entities in schema.cds file:

  • Employees - Stores employee details.
  • Projects - Stores project details.
  • Leaves - Stores employee leave requests.
db/schema.cds
namespace employee.management.cap.db.schema;

using {cuid} from '@sap/cds/common';

entity Employees {
    key employeeId  : String(20);
        firstName   : String(100);
        lastName    : String(100);
        email       : String(100);
        designation : String(100);
        managerID   : String(20);
        projects     : Association to many Projects on projects.employee = $self;
        leaves       : Composition of many Leaves on leaves.employee = $self;
}


entity Projects : cuid {
    projectName : String(100);
    employee    : Association to Employees;
}

//  Defining an ENUM as employee leave status can only be Pending, Approved or Rejected.
type LeaveStatus : String enum {
    PENDING;
    APPROVED;
    REJECTED;
}

entity Leaves : cuid {
    fromDate : String;
    toDate   : String;
    reason   : String;
    status   : LeaveStatus;
    employee : Association to Employees;
}

The relationship between Employees and Projects is created using an Association because both entities can exist independently. Even if an employee is deleted, the project can still exist.

The relationship between Employees and Leaves is created using a Composition because leave records belong to an employee. If an employee is deleted, all of that employee's leave records should also be deleted automatically. This is why Composition is the right choice for this relationship.

Heading 3

Heading 3

Bold Content
  • content list item 1
  • content list item 2
  • content list item 3
  • content list item 4
  • content list item 1
  • content list item 2
  • content list item 3
  • content list item 4
View1.view.xml
cds init employee-management-cap
StateCity
IndianaIndianapolis
OhioColumbus
MichiganDetroit

!!! Its Done !!!

Filter, sort on table / List Routing Navigation Page, Pannel, Shell, App Controls Formatter, Dialog, Fragment, Nested View Custom Control