Full Day/Half Day Customisation of My Leave Requests

Welcome to my first blog post. I hope you find this informative/useful. This post is about how I customised the My Leave Request App within my organisation to meet our corporate policy.

For this post I will be starting from the point where the app has already been downloaded in to the WebIDE and an extension project exists. In the case of this example the extension project is HCM_LR_CREExtenstion.

I won’t be going in to too much detail about every single change I made, this is only to give and over view of the extension.

Introduction

After researching the SAP standard implementation of My Leave Request(v1) it was decided it did not meet the requirements of our organisations Leave Policy. As a result the decision was made to customise the app and a specification was drawn up:

Specification

Users should only be able to book either a Full Day or Half Day Leave

Users should not be able to manually enter times for leave.

Users in Personnel SubArea 1000 (not the actual sub area just an example) can still book partial leave and manually enter time.

Implementation

In order to implement the three elements of the specification I had to extend Views, Controllers and Services. I also had to create some new utility files.

View Customisations

Views

When I customised the views for this project, rather than extend the views I chose to replace the ones I needed with a copy so I had more control over the elements.

S1

S1 is the view where the user manually enters their leave request details. As you can see below the time selection fields have been removed and replaced with two radio buttons, offering “Full Day” and “Half Day” options

If the user selects “Half Day”, they are presented with two additional radio buttons to allow the user to identify which half of their day they would like off. It will also populate the “Notes” with the details of the leave.

S3 and S6

S3 and S6 are the views that show your leave history and further details. Only minor changes we made to these pages to hide the leave time, and only show the leave days.

Controllers

Again with controller rather than extend i replaced the original with a copy. This way I could just uncomment the function I wish to customise.

S1 Controller

The majority S1’s changes involved making sure the new fields showed correctly, the next couple of images show some simple hide/show functions, but also additions to the standard onTapDate() function.

In order to account for the new inputs I also made changes to the Submit() function.

S3 and S6

Only a small minor change was made to these controllers, so that the times were not output in the view. This meant changing the setMasterListItems() function in S3, and the handleRouteMatched() function in S6.

Service

Because of the changes I made in the previous 2 elements I needed to edit the OData service in order to extract new data fields and accept new inputs in to the database. The two main OData classes that changed were made ConfigurationCollection and WorkScheduleCollection. In the two images below there are two new fields at the bottom of the ConfigurationCollection – PersonnelArea and PersonnelSubArea. WorkScheduleCollection now shows WorkingHours, StartOfDay, EndOfDay, StartOfBreak, EndOfBreak, and BreakDuration. We don’t need all of these field, but they will be useful in future.

Note: These changes were made in our ABAP system!

This was probably the most challenging task! as a lot of elements within the standard service had to copied so that the code could be extended. Also having no experiance in ABAP this was a big learning curve!

Utilities

In order to cope with the service changes I had to create some new utility files. This included a customFormatter and CustomDataManager.

Custom Formatter

Handles formatting any new elements I have added, the image below shows the code to format the new time fields I collected in the workScheduleCollection.

Custom Data Manager

The new data manager collects new data from the OData service and makes it usable in the app. The image below shows the method for getting the new work schedule data and also shows some submit funcitonality, due to changing the input values.

There you go. I think I have covered everything, but I left a lot in the hope this post generates some questions/comments. This is my first blog post on here so I hope people find this useful. We are making more changes to this app, so hopefully I will be able to post new updated blogs soon!!

Please create a new Discussion marked as a Question. Comments to a Blog (or Document) is not the right vehicle for asking questions as the results are not easily searchable. Once your issue is solved, a Discussion with the solution (and marked with Correct Answer) makes the results visible to others experiencing a similar problem. If a blog or document is related, put in a link.

NOTE: Getting the link is easy enough for both the author and Blog. Simply MouseOver the item, Right Click, and select Copy Shortcut. Paste it into your Discussion. You can also click on the url after pasting. Click on the A to expand the options and select T (on the right) to Auto-Title the url.

I am following your blog and I am trying to reproduce the same work but facing issue with the function _initCntrls did you had to uncomment the entire function when you made the copy of the controller or simply the piece that you are interested in?
Also did you had to change/code something in the backend?