Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

My Timesheet v2 app extension

Hi Experts,

We have a client requirement to add a text field to display remaining hours (target hours -(minus) clocked duration) below the calendar date.

How to extend sap.me.calendar control to add the remaining hours/day under the date? Is this attainable.. Pls help! 

Attached screenshot of the requirement..

Thanks and regards,

Saranya

timesheet.png (61294 B)
Tags:
replied

Assuming that you have provided an id of "remainTimeTxt" for the flexbox, start by creating a controller extension of the S3 controller.  In the controller provide the code

onInit: function() {

       this.loadListParentFn = hcm.mytimesheet.view.S3.prototype.loadList;

  },

loadList: function() {

       this.loadListParentFn();

       this.addCustomData();

  },

addCustomData: function(){

       var oModel = this.oApplicationFacade.oApplicationImplementation.getModel("TSM_WEEKLY");

       var days = oModel.getData().days;

       var sResult;

       var oTxtList = this.getView().byId("remainTimeTxt");

       var oCal = this.getView().byId("WEEKLY_CALENDAR");

       var daysIndex = 0;

       var calDay = oModel.getData().weekStart;

       //clean any previous data

       oTxtList.removeAllItems();

       for (var i = 0; i < oCal.getWeeksPerRow() * 7; i++) {

            if(days[daysIndex] && days[daysIndex].dateStr === calDay){

                 sResult = days[daysIndex].targetHours - days[daysIndex].recordedHours;

                 daysIndex++;

            }else{

                 sResult = "0";

        }

       calDay = new Date(calDay.substr(0,4), calDay.substr(4,2) - 1, calDay.substr(6,2));

       calDay.setTime( calDay.getTime() + 1 * 86400000 );

       calDay = calDay.toISOString();

       calDay = calDay.split("T")[0].replace(/-/g,"");

       oTxtList.addItem(new sap.m.Text({text: sResult}));

       }

  }

Regards,

Jamie

SAP - Technology RIG

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question