Group Team

Below code can be used to get the cost of an Item.

The function returns the item cost for a given item and the organization.

All the parameter used in the Api are IN Parameter. Cost_group_id and Cost_type_id have the default value as NULL.

We can pass cost_group_id or cost_type_id, if you desire most specific cost Information. Do not pass both the cost group and cost type at the same time.

API can fail for the below scenario

  • Invalid item/organization combination.
  • Item is not cost enabled.
  • Item has no cost in the specified cost group or cost type.


 

DECLARE

v_inventory_item_id NUMBER := 832215;
v_organization_id NUMBER := 209;
v_api_version NUMBER := 1.1;
v_cost_type_id NUMBER;
v_item_cost NUMBER := 0;
v_cost_group_id NUMBER;
BEGIN


dbms_output.put_line('API CST_COST_API to get the Item Cost);
v_item_cost := CST_COST_API.get_item_cost
(p_api_version => v_api_version,
p_inventory_item_id => v_inventory_item_id,
p_organization_id => v_organization_id,
p_cost_group_id => v_cost_group_id,
p_cost_type_id => v_cost_type_id
);

IF v_item_cost is NULL THEN

dbms_output.put_line('Issue in getting the Item Cost and Issue can be any one specified in the error scenario of the post');

ELSE

dbms_output.put_line('Item Cost is ' || v_item_cost);

END IF;

EXCEPTION

WHEN
OTHERS
THEN


dbms_output.put_line('Error in calling api and the error is ' ||
substr(SQLERRM,
1,
200));
END;

0 Responses

Post a Comment