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!!
Nice blog Chantele!
Thanks! 🙂
Nice Blog Chantele,
I have been doing almost the same stuff in our setup and have been "fighting" as well 🙂
Could you post your Transactional LPD_CUST setup for this?
I have done all the work in Fiori admin etc. and I am calling a custom Alias in LPD_cust but I am not sure which component to refer to in additional information - The extended component url??
Hi Jesper,
Sorry for the extremely late reply to your query. I hope your issue is resolved, but i will post a screen shot of LPD_CUST soon for you.
Regards
Chantele
Hi Jesper please see my new blog post
Full Day/Half Day Customisation of My Leave Requests - Part 2
Thanks for detailed blog.
Have you also did same kind of changes in Approve Leave requests application, please share your experience.
Best Regards,
Ajay
Hi Ajay,
I haven't done approve leave, but I will be in the future. Once done i'll post a new blog.
Regards
Chantele
Hi Chantele,
I am doing the exactly the same Fiori -extension for my client with slight difference.
I have create an Extension project using the HCM_IRQ(downloaded from ECC using se38 ). My question is do we need to proceed S1Custom.view.xml as a view replacement?
As we cannot implement the radio button at the top as you did (for Full/ Part day select). since the <core:ExtensionPoint> is available at the bottom in the standard apps.
Could you please share your code/configuration in this blog. It will be really helpful for my development as a reference.
Thanks.
Veera P,
Hi Veera,
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.
Thanks, Mike (Moderator)
SAP Technology RIG
Hi Veera,
As Michael states below, this really should have been a discussion question. However, as the answer as quick i'll throw it up here.
Yes i had to do a replace on the views I edited, due to the extensions not supporting the types of change i wanted to make.
Make sure you replace with a copy of the original though.
Hope that helps.
Chantele
Hi Chantele,
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?
Thanks,
Best regards,
Nabil
Hi Nabil,
I'm sorry you are having trouble with this.
Please feel free to message me with more details about the issues you are facing, and i'll try and help where I can.
In terms of the _initControls i did uncomment the method, but only to add reference to my own controls in there, and uncomment a couple of the standard controls.
Regards
Chantele
Hi Chantele,
We are trying to implement the "half a day solution" you explained but in the HCM_LRQ_CRE Fiori App.
We are following the steps you have explained but WE have facing some problems.
Can I write a private message, I don't know if this is possible, to ask you our doubts ?
Thanks in advance
Hi Jose
I've not been on the community for the while, but yes please message me and i'll try and help anyway i can.
Regards
Chantele