Problem with setting actuals fields with Aspose Tasks Java API - What am I doing wrong?

Hi,


I’ve been trying to use Aspose Tasks Java API to generate a simple work plan with actuals (3 tasks) from a blank MPP file.

However, I cannot succeed in getting all the tasks fields (schedule & actuals) from the generated mpp file to be the same as in the reference MPP file I’m trying to reproduce.

Here are the discrepancies I’m getting, highlighted in the attached picture:
- Start date of the 2 tasks with no assignment are set to the same date as the finish date, for no reason
- Actual duration of the completed task with no assignment is incorrectly set to 8 days (should be 9 days)
- Computed percent complete of the task with assignments is incorrectly computed to be 99%.
- Actual duration of the task with assignment is incorrectly computed to be 9 days (it should be computed from the two assignment values)
- Actual finish of the completed assignment doesn’t work, it remains N/A even though I’m setting the actual finish date of the ResourceAssignment and the (computed) % work complete is 100%.

Could you please point at what I’m doing wrong in my Java code (attached), and how it should be corrected in order to get an MPP file that’s identical to the target work plan mpp file?

Note that I’ve noticed that the order in which the actuals fields of the assignments are set will impact the result; setting Asn.WORK last as in my java code is the way that’s working best for me, but it’s still not working as well as I hope it would.

Please advise,

Kind Regards,
Etienne.

Hi Etienne,

Thank you for contacting Aspose support team.

We have analyzed the code and observed few issues. The modified code is attached here for your reference. Only one requirement is not fulfilled where Actual Finish date is not calculated while assignment % complete work is 100% for the second assignment of third task. This causes errors in Actual duration and Task % complete. This issue is logged under Id: TASKSJAVA-217 for further investigation by the product team. You will be automatically notified once any update is received in this regard.

private static SimpleDateFormat formatter2 = new SimpleDateFormat(“MM/dd/yy hh:mm:ss”);

static private void Tasks_744770_Original() throws ParseException
{
    Project asProject = new Project("project_blank.mpp");
    // Task with No assignment
    Task task_no_assignment = asProject.getRootTask().getChildren().add("Task with no assignment");
    task_no_assignment.set(Tsk.START,"formatter2".parse("06 / 29 / 16 08:00:00" ));
    task_no_assignment.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));
    task_no_assignment.set(Tsk.WORK, asProject.getDuration(72, TimeUnitType.Hour));
    task_no_assignment.set(Tsk.PERCENT_COMPLETE, 50);
    task_no_assignment.set(Tsk.ACTUAL_START,"formatter2".parse("06 / 29 / 16 08:00:00" ));
    task_no_assignment.set(Tsk.ACTUAL_WORK, asProject.getDuration(36, TimeUnitType.Hour));
    task_no_assignment.set(Tsk.ACTUAL_DURATION, asProject.getDuration(4.5, TimeUnitType.Day));
    // Completed Task with No assignment
    Task task_completed_no_assignment = asProject.getRootTask().getChildren().add("Task Completed with no assignment" );
    task_completed_no_assignment.set(Tsk.START,"formatter2".parse("06 / 29 / 16 08:00:00" ));
    task_completed_no_assignment.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));
    task_completed_no_assignment.set(Tsk.WORK, asProject.getDuration(72, TimeUnitType.Hour));
    task_completed_no_assignment.set(Tsk.PERCENT_COMPLETE, 100);
    task_completed_no_assignment.set(Tsk.ACTUAL_START,"formatter2".parse("06 / 29 / 16 08:00:00" ));
    //task_completed_no_assignment.set(Tsk.ACTUAL_FINISH, formatter.parse("07/11/16"));
    task_completed_no_assignment.set(Tsk.ACTUAL_WORK, asProject.getDuration(72, TimeUnitType.Hour));
    task_completed_no_assignment.set(Tsk.ACTUAL_DURATION, asProject.getDuration(9, TimeUnitType.Day));
    // Task with assignments
    Task task_with_assignments = asProject.getRootTask().getChildren().add("Task with assignments" );
    task_with_assignments.set(Tsk.START,"formatter2".parse("06 / 29 / 16 08:00:00" ));
    task_with_assignments.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));
    // Assignment #1 (Resource in progress)
    Resource resource_in_progress = asProject.getResources().add("resource_in_progress" );
    ResourceAssignment ra_resource_in_progress =
        asProject.getResourceAssignments().add(task_with_assignments, resource_in_progress);
    // There’s no duration nor % complete on assignments
    ra_resource_in_progress.set(Asn.START,"formatter2".parse("06 / 29 / 16 08:00:00" ));
    ra_resource_in_progress.set(Asn.WORK, asProject.getDuration(72, TimeUnitType.Hour));
    ra_resource_in_progress.set(Asn.ACTUAL_START,"formatter2".parse("06 / 29 / 16 08:00:00" ));
    ra_resource_in_progress.set(Asn.ACTUAL_WORK, asProject.getDuration(18, TimeUnitType.Hour));
    // Assignment #2 (Resource completed)
    Resource resource_completed = asProject.getResources().add("resource_completed" );
    ResourceAssignment ra_completed =
        asProject.getResourceAssignments().add(task_with_assignments, resource_completed);
    // There’s no duration nor % complete on assignments
    ra_completed.set(Asn.START,"formatter2".parse("07 / 06 / 16 08:00:00" ));
    ra_completed.set(Asn.WORK, asProject.getDuration(32, TimeUnitType.Hour));
    ra_completed.set(Asn.ACTUAL_START,"formatter2".parse("07 / 06 / 16 08:00:00" ));
    ra_completed.set(Asn.ACTUAL_WORK, asProject.getDuration(32, TimeUnitType.Hour));
    // Recalculating doesn’t make a difference
    asProject.recalculate();
    // Save the Project
    asProject.save("task - resource - assignments.mpp" , SaveFileFormat.MPP );
    System.out .println("ok" );
}

Awesome, Thanks a lot for the quick reply as always!


Is there any to have access to issues status and see when a fix eventually gets scheduled? (We have a site OEM license).

Kind Regards,
Etienne.

Hi,

The issue has been logged too recently and it will be investigated upon its turn. We’ll update you here once there is some information or a fix version available in this regard.

The issues you have found earlier (filed as TASKSJAVA-217) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi,


It still has some issue, please see the picture in attachment, the data of third task is completely wrong, and below is the code:


private static SimpleDateFormat formatter2 = new SimpleDateFormat(“MM/dd/yy hh:mm:ss”);

public static void main(String[] args) throws ParseException {
Project asProject = new Project(“project_blank.mpp”);

// Task with No assignment

Task task_no_assignment = asProject.getRootTask().getChildren().add(“Task with no assignment”);

task_no_assignment.set(Tsk.START, formatter2.parse(“06/29/16 08:00:00”));

task_no_assignment.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));

task_no_assignment.set(Tsk.WORK, asProject.getDuration(72, TimeUnitType.Hour));

task_no_assignment.set(Tsk.PERCENT_COMPLETE, 50);

task_no_assignment.set(Tsk.ACTUAL_START, formatter2.parse(“06/29/16 08:00:00”));

task_no_assignment.set(Tsk.ACTUAL_WORK, asProject.getDuration(36, TimeUnitType.Hour));

task_no_assignment.set(Tsk.ACTUAL_DURATION, asProject.getDuration(4.5, TimeUnitType.Day));

// Completed Task with No assignment

Task task_completed_no_assignment = asProject.getRootTask().getChildren()
.add(“Task Completed with no assignment”);

task_completed_no_assignment.set(Tsk.START, formatter2.parse(“06/29/16 08:00:00”));

task_completed_no_assignment.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));

task_completed_no_assignment.set(Tsk.WORK, asProject.getDuration(72, TimeUnitType.Hour));

task_completed_no_assignment.set(Tsk.PERCENT_COMPLETE, 100);

task_completed_no_assignment.set(Tsk.ACTUAL_START, formatter2.parse(“06/29/16 08:00:00”));

// task_completed_no_assignment.set(Tsk.ACTUAL_FINISH,
// formatter.parse(“07/11/16”));

task_completed_no_assignment.set(Tsk.ACTUAL_WORK, asProject.getDuration(72, TimeUnitType.Hour));

task_completed_no_assignment.set(Tsk.ACTUAL_DURATION, asProject.getDuration(9, TimeUnitType.Day));

// Task with assignments

Task task_with_assignments = asProject.getRootTask().getChildren().add(“Task with assignments”);

task_with_assignments.set(Tsk.START, formatter2.parse(“06/29/16 08:00:00”));

task_with_assignments.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));

// Assignment #1 (Resource in progress)

Resource resource_in_progress = asProject.getResources().add(“resource_in_progress”);

ResourceAssignment ra_resource_in_progress =

asProject.getResourceAssignments().add(task_with_assignments, resource_in_progress);

// There’s no duration nor % complete on assignments

ra_resource_in_progress.set(Asn.START, formatter2.parse(“06/29/16 08:00:00”));

ra_resource_in_progress.set(Asn.WORK, asProject.getDuration(72, TimeUnitType.Hour));

ra_resource_in_progress.set(Asn.ACTUAL_START, formatter2.parse(“06/29/16 08:00:00”));

ra_resource_in_progress.set(Asn.ACTUAL_WORK, asProject.getDuration(18, TimeUnitType.Hour));

// Assignment #2 (Resource completed)

Resource resource_completed = asProject.getResources().add(“resource_completed”);

ResourceAssignment ra_completed =

asProject.getResourceAssignments().add(task_with_assignments, resource_completed);

// There’s no duration nor % complete on assignments

ra_completed.set(Asn.START, formatter2.parse(“07/06/16 08:00:00”));

ra_completed.set(Asn.WORK, asProject.getDuration(32, TimeUnitType.Hour));

ra_completed.set(Asn.ACTUAL_START, formatter2.parse(“07/06/16 08:00:00”));

ra_completed.set(Asn.ACTUAL_WORK, asProject.getDuration(32, TimeUnitType.Hour));

// Recalculating doesn’t make a difference

asProject.recalculate();

// Save the Project

asProject.save(“test_java_217.mpp”, SaveFileFormat.MPP);

System.out.println(“ok”);

}

Best Regards!
zhencheng.guo

Hi,


Sorry, I have not import the license, once I import it, the issue have fixed.


Best Regards!
zhencheng.guo

Hi Zhencheng,


Thank you for the feedback. It is nice to hear that your issue is resolved. Please feel free to write us back if you have any other query related to Aspose.Tasks.