Share this page

# approveTimeSheet

## Purpose

Approve an existing Time Sheet 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 all the lines of an existing time sheet, and the status of the time sheet to "approved."

Before this operation, the status of the time sheet must be "pending-approval" or "in-rework" and the statuses of each Line must be "submitted" or "rejected."

The user performing this operation must have the permission to approve this particular time sheet, 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 updated in this operation is the Actual Approver, which is set to be the approver's user ID.

## Input

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

## Return

An object of TimeSheetBean, complete with all the fields.

## Java Interface

`ApproveTimeSheetResponseDocument approveTimeSheet(ApproveTimeSheetDocument in)`

Parameters | Description
--- | ---
ApproveTimeSheetDocument | Wrapper for TimeSheetBean. See the following example for the construction.
ApproveTimeSheetResponseDocument | Wrapper for TimeSheetBean. See the following example on how to retrieve the bean.

## Java Examples

Example: approve an existing time sheet.

    TimeSheetBean createdTimeSheetBean = null;
        public void testApproveTimeSheetAllSubmitted() {
            System.out.println("testApproveTimeSheetAllSubmitted
    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 timeSheetLineBean =
    approveTimeSheetBean.addNewTimeSheetLines();

    timeSheetLineBean.setTimeSheetLineId(createdTimeSheetBean.getTi
    meSheetLinesArray(0).getTimeSheetLineId());

    timeSheetLineBean.setWorkItemId(createdTimeSheetBean.getTimeShe
    etLinesArray(0).getWorkItemId());

    timeSheetLineBean.setWorkItemSetId(createdTimeSheetBean.getTime
    SheetLinesArray(0).getWorkItemSetId());

    timeSheetLineBean.setWorkItemType(createdTimeSheetBean.getTimeS
    heetLinesArray(0).getWorkItemType());
              TimeSheetLineStatus timeSheetLineStatus =
    timeSheetLineBean.addNewState();
              timeSheetLineStatus.setCode(new BigInteger("2"));
              timeSheetLineStatus.setMeaning("submitted");
              TimeActualsBean timeActualsBean1 =
    timeSheetLineBean.addNewTimeActualsList();
              timeActualsBean1.setTotalsFlag(true);
              timeActualsBean1.setEffortsListArray(new double[]
    {1,2,3,4,5,0,0,1,2,3,4,5,0,0,10});

              TimeActualsBean timeActualsBean2 =
    timeSheetLineBean.addNewTimeActualsList();
              timeActualsBean2.setTotalsFlag(false);
              timeActualsBean2.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 was approved " +
    returnTimeSheet.getTimeSheetId());
          }
          catch(Exception e) {
              e.printStackTrace();
          }
          System.out.println("testApproveTimeSheetAllSubmitted
    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.cannotApprovefTimesheet | User cannot approve Timesheet | You may not have the required access grant or Time Management License. | Check the user licenses and privileges (access grants).
ex.timesheetCannotbeApproved | Timesheet is not in pending approval state, it cannot be approved | The time sheet that you try to approve is not pending approval. | Check the state of the time sheet that you are trying to approve.
ex.timesheetNullCannotbeApproved | Timesheet is null, cannot be approved | Time sheet ID is invalid, or database might be corrupt. | Check the validity of the time sheet ID.
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.
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.

https://admhelp.microfocus.com PPM 8942
Tips to improve your search results... OpenText™ Project and Portfolio Management Help Center PPM Help 26.2-26.3 All View Local Help Center View Online Help Center Version: