approveTimeSheetLine

Purpose

Approve an existing time sheet line object in PPM.

Note: This operation supports the Day in Days option and Period in Days option, which were introduced since PPM Center version 8.00 Service Pack 1. For more information, see the Time Sheet Update Service section in Project and Portfolio Management Center Version 8.00.01 (Service Pack 1) Release Notes.

Function

This operation updates the status of a time sheet line to be "approved."

Before this operation, the status of the Line must be "submitted" or "rejected."

The user performing this operation must have the permission to approve this particular time sheet line, meaning that the user must meet the following conditions:

  • Have the Time Mgmt: Edit Time Sheets access grant.

  • Be one of the following:

    • The time sheet line approver.

    • The delegate of the time sheet line approver.

An additional field this operation updates is the Actual Approver, which is set to the approver's user ID.

Input

The ID of the time sheet and the ID of the time sheet line that you want to approve.

Return

An object of TimeSheetBean with all the fields completed.

Java Interface

ApproveTimeSheetLineResponseDocument approveTimeSheetLine(ApproveTimeSheetLineDocument in)

Parameters

Description

TimeSheetLineID

Long value of the time sheet line ID.

ApproveTimeSheetLineDocument

Wrapper for TimeSheetBean and a long value for a time sheet line ID. See the following example for the construction.

ApproveTimeSheetLineResponseDocument

Wrapper for TimeSheetBean. See the following example on how to retrieve the bean.

Java Examples

Example: approve an existing time sheet line.

TimeSheetBean createdTimeSheetBean = null;
    public void testApproveTimeSheetNotAllApproved() {
        System.out.println("testApproveTimeSheetNotAllApproved
started ...");
        try {
            if(createdTimeSheetBean == null)
                testSubmitTimeSheet();
            TimeServiceStub stub = new TimeServiceStub(ctx,
WSURL);
            ApproveTimeSheetDocument approveTimeSheetDocument =
ApproveTimeSheetDocument.Factory.newInstance();
       TimeSheetBean approveTimeSheetBean =
approveTimeSheetDocument.addNewApproveTimeSheet().addNewTimeShe
etBean();
approveTimeSheetBean.setTimeSheetId(createdTimeSheetBean.getTim
eSheetId());
approveTimeSheetBean.setResourceId(createdTimeSheetBean.getReso
urceId());
approveTimeSheetBean.setPeriodId(createdTimeSheetBean.getPeriod
Id());
           TimeSheetStatus timeSheetStatus =
approveTimeSheetBean.addNewState();
           timeSheetStatus.setCode(new BigInteger("2"));
           timeSheetStatus.setMeaning("pending-approval");
           TimeSheetLineBean timeSheetLineBean1 =
approveTimeSheetBean.addNewTimeSheetLines();
timeSheetLineBean1.setTimeSheetLineId(createdTimeSheetBean.getT
imeSheetLinesArray(0).getTimeSheetLineId());
timeSheetLineBean1.setWorkItemId(createdTimeSheetBean.getTimeSh
eetLinesArray(0).getWorkItemId());
timeSheetLineBean1.setWorkItemSetId(createdTimeSheetBean.getTim
eSheetLinesArray(0).getWorkItemSetId());
timeSheetLineBean1.setWorkItemType(createdTimeSheetBean.getTime
SheetLinesArray(0).getWorkItemType());
            TimeSheetLineStatus timeSheetLineStatus1 =
timeSheetLineBean1.addNewState();
            timeSheetLineStatus1.setCode(new BigInteger("4"));
            timeSheetLineStatus1.setMeaning("rejected");
            TimeActualsBean timeActualsBean11 =
timeSheetLineBean1.addNewTimeActualsList();
            timeActualsBean11.setTotalsFlag(true);
            timeActualsBean11.setEffortsListArray(new double[]
{1,2,3,4,5,0,0,1,2,3,4,5,0,0,10});
            TimeActualsBean timeActualsBean21 =
timeSheetLineBean1.addNewTimeActualsList();
            timeActualsBean21.setTotalsFlag(false);
            timeActualsBean21.setEffortsListArray(new double[]
{1,2,3,4,5,0,0,1,2,3,4,5,0,0,10});
            TimeSheetLineBean timeSheetLineBean2 =
approveTimeSheetBean.addNewTimeSheetLines();
timeSheetLineBean2.setTimeSheetLineId(createdTimeSheetBean.getT
imeSheetLinesArray(0).getTimeSheetLineId());
timeSheetLineBean2.setWorkItemId(createdTimeSheetBean.getTimeSh
eetLinesArray(0).getWorkItemId());
timeSheetLineBean2.setWorkItemSetId(createdTimeSheetBean.getTim
eSheetLinesArray(0).getWorkItemSetId());
timeSheetLineBean2.setWorkItemType(createdTimeSheetBean.getTime
SheetLinesArray(0).getWorkItemType());
           TimeSheetLineStatus timeSheetLineStatus2 =
timeSheetLineBean2.addNewState();
           timeSheetLineStatus2.setCode(new BigInteger("5"));
           timeSheetLineStatus2.setMeaning("cancelled");
           TimeActualsBean timeActualsBean12 =
timeSheetLineBean2.addNewTimeActualsList();
           timeActualsBean12.setTotalsFlag(true);
           timeActualsBean12.setEffortsListArray(new double[]
{1,2,3,4,5,0,0,1,2,3,4,5,0,0,10});
           TimeActualsBean timeActualsBean22 =
timeSheetLineBean2.addNewTimeActualsList();
           timeActualsBean22.setTotalsFlag(false);
           timeActualsBean22.setEffortsListArray(new double[]
{1,2,3,4,5,0,0,1,2,3,4,5,0,0,10});
            ApproveTimeSheetResponseDocument response =
stub.approveTimeSheet(approveTimeSheetDocument);
            TimeSheetBean returnTimeSheet =
response.getApproveTimeSheetResponse().getReturn();
            System.out.println("Time Sheet lines were approved "
+ returnTimeSheet.getTimeSheetId());
       }
       catch(Exception e) {
            e.printStackTrace();
       }
       System.out.println("testApproveTimeSheetNotAllApproved
completed");
  }

Errors and Exceptions

When an error occurs on this operation, you will receive a description of the root cause in the log or in the response message.

The server log file content is similar to the following:

Exception in thread "main" org.apache.axis2.AxisFault: [root cause description] 

Response message:

<exception:exceptionDetails xmlns:exception="http://
www.mercury.com/ppm/ws/exception">
<exception:detail>[root cause description] </exception:detail>
</exception:exceptionDetails>

Possible root cause descriptions:

Message Code

Message

Cause(s)

Possible Corrective Action

ex.cannotApproveTimesheetLine

User cannot approve Timesheet Line

You may not have the required access grant or Time Management License.

Check the user licenses and privileges (access grants).

ex.timesheetLineCannotbeApproved

Timesheet line is not in submitted or rejected state, it cannot be approved

You try to approve a time sheet line that is neither submitted nor rejected.

Check the state of the time sheet line that you are trying to approve.

ex.timesheetLineNotExist

Timesheet line does not exist in this timesheet

The time sheet ID or line ID is invalid, or database might be corrupt.

Check the validity of the time sheet ID and line ID.

ex.timesheetLineNullCannotbeApproved

Timesheet line or timesheet is null, cannot be approved

Time sheet ID or line ID is invalid, or database might be corrupt.

Check the validity of the time sheet ID and line ID.

ex.tsIncorrectApprovalStatus

This timesheet can not be approved as timesheet status is unsubmitted

Time sheet status is incorrect to approve.

Perform the getTimeSheet operation to check the time sheet status, and then perform other appropriate operations.

ex.timeApproverNotSet

Time Approver for this resource is not set

Time approver for this resource is not set in PPM Center.

Set time approver for this resource in PPM Center.