[Script]如何获取物料的成本

For Discrete Manufacturing

Query Like:
SELECT SEGMENT1 ITEM,
CST_COST_API.GET_ITEM_COST(1,INVENTORY_ITEM_ID, ORGANIZATION_ID,NULL,NULL) COST
FROM MTL_SYSTEM_ITEMS_B
WHERE INVENTORY_ITEM_ID = &ITEM_ID AND ORGANIZATION_ID = &ORG_ID;

For OPM organization

对于OPM组织,上边的Query不适用,需要使用下边的Query
SELECT MSI.SEGMENT1 ITEM,
GMF_CMCOMMON.GET_CMPT_COST( INVENTORY_ITEM_ID, ORGANIZATION_ID, SYSDATE, CMM.COST_TYPE_ID ,0) COST
FROM MTL_SYSTEM_ITEMS_B MSI, CM_MTHD_MST CMM
WHERE CMM.COST_MTHD_DESC='Standard Cost';


Function CST_COST_API.get_item_cost


Synopsis:

  This function returns the item cost for a given item and organization.
  This function accepts only IN parameters, and returns a single value.
  This makes the API simple to call as part of SQL statements.

  You may also pass either the cost group ID or the cost type ID,
  if you desire more specific cost information.  Do not pass both the
  cost group and the cost type at the same time.

  For now, pass p_api_version = 1.

  This API currently does not support the retrieval of specific layer
  costs within a FIFO/LIFO organization.


Code Details:

  The output of this function is dependent on the primary cost method
  of the organization, and which of the parameters were specified.
  Note that you should never specify both the cost_type_id and
  the cost_group_id together; to not pass a parameter, use NULL.

  For FIFO/LIFO, the cost group average from CQL is returned.

  Parameters             | Standard              | Average/FIFO/LIFO
  -----------------------+-----------------------+----------------------
  item, org              | Frozen from CIC       | Default CG from CQL
  item, org, cost_group  | Frozen from CIC       | Specified CG from CQL
  item, org, cost_type   | Specified CT from CIC | Specified CT from CIC

  The precision parameter is used to determinate what type of rounding
  should be applied to the item cost value that is returned. The number
  specified for this parameter represents the number of decimal digits
  that the output will be rounded to and its defaulted as NULL.

Error Conditions:

  For all errors, the returned value is NULL.

  The possible error conditions are:
    Invalid item/organization combination.
    Item is not cost enabled.
    Item has no cost in the specified cost group or cost type.



你可能感兴趣的:([Script]如何获取物料的成本)