In this example, a Calculate Activity Planned Cost custom step is being added to P6 project data flows which calculates the activity planned cost of P6 projects with different statuses.
Note: InProgressTotalCost, NotStartedTotalCost
, and CompletedTotalCost
are UDFs in P6.
To add the custom step:
- Sign in to Primavera Gateway as an administrator or developer.
- In the sidebar, select Configuration.
- Select the Custom Steps tab.
- Select the Add... button.
- In the Custom Step wizard, enter the following information:
- In the Name field, enter Calculate Activity Planned Cost.
- Select P6 from the Provider list.
- Select Source from the Flow Side list.
- Select Project Data from the Flow Type list.
- In the Sequence Number field, enter 11.
- Select the Enable check box.
- Select Save.
- In the Formula section, enter the following code using Gateway scripting language:
double inprogress = 0.0;
double notstarted = 0.0;
double completed = 0.0;
for (activity : <Activity>)
{
if (activity.PlannedTotalCost != null)
{
if (activity.Status == "In Progress")
{
inprogress = inprogress + activity.PlannedTotalCost;
}
else if (activity.Status == "Not Started")
{
notstarted = notstarted + activity.PlannedTotalCost;
}
else if (activity.Status == "Completed")
{
completed = completed + activity.PlannedTotalCost;
}
}
}
for (project : <Project>)
{
project.InProgressTotalCost = inprogress;
project.NotStartedTotalCost = notstarted;
project.CompletedTotalCost = completed;
}
- Select Validate.
- Select Save.