setCostFactors

Purpose

Sets the cost factors in PPM to be used by cost rules.

Function

Sets the cost factors for the system. The precedence of cost factors is determined by their ordering in the list, the most significant cost factor is the first element in the list and the least significant factor is the last.

Caution: Setting of cost factors does not mean adding cost factors to an already existing list. This operation removes the existing list of cost factors and creates an entirely new list.

Changing the order of cost factors necessitates that costs be recalculated for all entities in the system that are not in a "frozen" state. This is done asynchronously by the Cost Rate Rule Update service. Costs do not need to be recalculated when cost factors are added or deleted. Adding new cost factors does not affect costing because no rule in the system has a value for the new factor. If a rule is created with a non-null value for the new factor, a CostRuleUpdate is created for it by PPM automatically. Deleting cost factors also does not require cost recalculation because only unused cost factors may be removed.

Related Information

getCostFactors gets the cost factors in PPM.

Input

An object with an array of WSCostFactorBean.

Return

None

Java Interface

SetCostFactorsResponseDocument
setCostFactors(SetCostFactorsDocument in)

Parameters

Description

SetCostFactorsDocument

Wrapper for the array of cost factor beans (WSCostFactorBean) that the caller obtains by performing this operation.


Java Examples

Example: Set the cost factors in PPM.

CostFactor[] setCostFactors() throws Exception {
    SetCostFactorsDocument setCostFactorsDoc =
SetCostFactorsDocument.Factory.newInstance();
    SetCostFactors setCostFactors =
setCostFactorsDoc.addNewSetCostFactors();
    List newFactors = shuffleCostFactors();
    populate(setCostFactors, newFactors);
    if (VERBOSE) print(setCostFactors);
    FM.setCostFactors(setCostFactorsDoc);
    }
    List shuffleCostFactors() {
    List factors = new ArrayList();
    Random r = new Random();
    for (int i = 0; i < COST_FACTORS.length; i++) {
    if (r.nextFloat() > .2) { // more likeley to keep it then
not
    factors.add(COST_FACTORS[i]);
    }
    }
    Collections.shuffle(factors);
    return factors;
    }
    void populate(SetCostFactors setCostFactors, List factors)
{
    for (int i = 0; i < factors.size(); i++ ) {
    CostFactor f = setCostFactors.addNewCostFactor();
    f.setFactor((String) factors.get(i));
    f.setSortOrder(BigInteger.valueOf(i));
    }
    }

Errors and Exceptions

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

Exception in thread "main" org.apache.axis2.AxisFault:
<exception:exceptionDetails xmlns:exception="http://
www.mercury.com/ppm/ws/exception">
<exception:detail>[root cause description] </exception:detail>
</exception:exceptionDetails>

Root Cause Descriptions

Possible root cause descriptions:

Message Code

Message

Cause(s)

Possible Corrective Action

ex.Authorization

You do not have the privilege to take this action. Consult your PPM Administrator.

User is not authorized to read the cost factors.

Check the user licenses and privileges (access grants).

ex.CostFactorInUse

You are removing a cost factor - Request Type - that is still in use by cost rules in the system. Please remove these rules before proceeding.

An attempt is made to deactivate a cost factor that is being used by one or more cost rules. In other words, a CostFactorInUseException is thrown if one or more rules exist in the system with a non-null value for this factor.

Do NOT deactivate or remove the cost factors that are being used by cost rules.

Identify the cost rule associated with this cost factor. Then, determine if the cost rule should be removed. If the cost rule can be removed, do so, and then remove the cost factor.

Note that when you are trying to set the cost factors, it is as though you are deleting the existing list and setting a whole new set of factors.