GMF_ITEMCOST_PUB.CREATE_ITEM_COST API is used to create item cost in Oracle Process Manufacturing.
This API creates a new item cost in the Cost Details table. [ Table = CM_CMPT_DTL]
The GMF_ITEMCOST_PUB package defines and uses the following custom PL/SQL
Record Types and INDEX BY table Types:
TYPE header_rec_type IS RECORD
(
period_id cm_cmpt_dtl.period_id%TYPE,
calendar_code cm_cldr_hdr_b.calendar_code%TYPE,
period_code cm_cldr_dtl.period_code%TYPE,
cost_type_id cm_cmpt_dtl.cost_type_id%TYPE,
cost_mthd_code cm_mthd_mst.cost_mthd_code%TYPE,
organization_id cm_cmpt_dtl.organization_id%TYPE,
organization_code mtl_parameters.organization_code%TYPE,
inventory_item_id cm_cmpt_dtl.inventory_item_id%TYPE,
item_number mtl_item_flexfields.item_number%TYPE,
user_name fnd_user.user_name%TYPE
);
TYPE this_level_dtl_rec_type IS RECORD
(
cmpntcost_id NUMBER,
cost_cmpntcls_id NUMBER,
cost_cmpntcls_code cm_cmpt_mst.cost_cmpntcls_code%TYPE,
cost_analysis_code cm_cmpt_dtl.cost_analysis_code%TYPE,
cmpnt_cost NUMBER,
burden_ind NUMBER,
total_qty NUMBER,
costcalc_orig NUMBER,
rmcalc_type NUMBER,
delete_mark NUMBER,
attribute1 cm_cmpt_dtl.attribute1%TYPE,
attribute2 cm_cmpt_dtl.attribute2%TYPE,
attribute3 cm_cmpt_dtl.attribute3%TYPE,
attribute4 cm_cmpt_dtl.attribute4%TYPE,
attribute5 cm_cmpt_dtl.attribute5%TYPE,
attribute6 cm_cmpt_dtl.attribute6%TYPE,
attribute7 cm_cmpt_dtl.attribute7%TYPE,
attribute8 cm_cmpt_dtl.attribute8%TYPE,
attribute9 cm_cmpt_dtl.attribute9%TYPE,
attribute10 cm_cmpt_dtl.attribute10%TYPE,
attribute11 cm_cmpt_dtl.attribute11%TYPE,
attribute12 cm_cmpt_dtl.attribute12%TYPE,
attribute13 cm_cmpt_dtl.attribute13%TYPE,
attribute14 cm_cmpt_dtl.attribute14%TYPE,
attribute15 cm_cmpt_dtl.attribute15%TYPE,
attribute16 cm_cmpt_dtl.attribute16%TYPE,
attribute17 cm_cmpt_dtl.attribute17%TYPE,
attribute18 cm_cmpt_dtl.attribute18%TYPE,
attribute19 cm_cmpt_dtl.attribute19%TYPE,
attribute20 cm_cmpt_dtl.attribute20%TYPE,
attribute21 cm_cmpt_dtl.attribute21%TYPE,
attribute22 cm_cmpt_dtl.attribute22%TYPE,
attribute23 cm_cmpt_dtl.attribute23%TYPE,
attribute24 cm_cmpt_dtl.attribute24%TYPE,
attribute25 cm_cmpt_dtl.attribute25%TYPE,
attribute26 cm_cmpt_dtl.attribute26%TYPE,
attribute27 cm_cmpt_dtl.attribute27%TYPE,
attribute28 cm_cmpt_dtl.attribute28%TYPE,
attribute29 cm_cmpt_dtl.attribute29%TYPE,
attribute30 cm_cmpt_dtl.attribute30%TYPE,
attribute_category cm_cmpt_dtl.attribute_category%TYPE
);
TYPE this_level_dtl_tbl_type IS TABLE OF this_level_dtl_rec_type INDEX
BY BINARY_INTEGER;
TYPE lower_level_dtl_rec_type IS RECORD
(
cmpntcost_id NUMBER,
cost_cmpntcls_id NUMBER,
cost_cmpntcls_code cm_cmpt_mst.cost_cmpntcls_code%TYPE,
cost_analysis_code cm_cmpt_dtl.cost_analysis_code%TYPE,
cmpnt_cost NUMBER,
delete_mark NUMBER
);
TYPE lower_level_dtl_tbl_type IS TABLE OF lower_level_dtl_rec_type
INDEX BY BINARY_INTEGER;
TYPE costcmpnt_ids_rec_type IS RECORD
(
cost_cmpntcls_id NUMBER,
cost_analysis_code cm_cmpt_dtl.cost_analysis_code%TYPE,
cost_level NUMBER,
cmpntcost_id NUMBER
);
TYPE costcmpnt_ids_tbl_type IS TABLE OF costcmpnt_ids_rec_type INDEX
BY BINARY_INTEGER;
PL - SQL Code for API:-
ALTER SESSION SET NLS_LANGUAGE=AMERICAN;
DECLARE
L_STATUS VARCHAR2 (11);
L_RETURN_STATUS VARCHAR2 (11) := FND_API.G_RET_STS_SUCCESS;
L_COUNT NUMBER (10);
L_RECORD_COUNT NUMBER (10) := 0;
L_LOOP_CNT NUMBER (10) := 0;
L_DUMMY_CNT NUMBER (10) := 0;
L_DATA VARCHAR2 (3000);
L_MSG_INDEX_OUT NUMBER;
L_HEADER_REC GMF_ITEMCOST_PUB.HEADER_REC_TYPE;
L_THIS_LVL_TBL GMF_ITEMCOST_PUB.THIS_LEVEL_DTL_TBL_TYPE;
L_LOWER_LVL_TBL GMF_ITEMCOST_PUB.LOWER_LEVEL_DTL_TBL_TYPE;
L_COSTCMPNT_IDS GMF_ITEMCOST_PUB.COSTCMPNT_IDS_TBL_TYPE;
BEGIN
FND_GLOBAL.APPS_INITIALIZE (USER_ID => 1110,
RESP_ID => 50687,
RESP_APPL_ID => 555
);
L_HEADER_REC.PERIOD_ID := 141;
L_HEADER_REC.CALENDAR_CODE := 'CST_CAL';
L_HEADER_REC.PERIOD_CODE := 'JUN 2012'; --NULL;
L_HEADER_REC.COST_TYPE_ID := 1000;
L_HEADER_REC.COST_MTHD_CODE := 'PMAC'; -- NULL;
L_HEADER_REC.ORGANIZATION_ID := 229;
L_HEADER_REC.ORGANIZATION_CODE := 'R02'; --NULL;
L_HEADER_REC.INVENTORY_ITEM_ID := 2005;
--L_HEADER_REC.ITEM_NUMBER := NULL;
L_HEADER_REC.USER_NAME := 'USER1';
L_THIS_LVL_TBL (1).CMPNTCOST_ID := 21188;
L_THIS_LVL_TBL (1).COST_CMPNTCLS_ID := 1;
L_THIS_LVL_TBL (1).COST_CMPNTCLS_CODE := 'MATERIAL';
L_THIS_LVL_TBL (1).COST_ANALYSIS_CODE := 'DIR';
L_THIS_LVL_TBL (1).CMPNT_COST := 60;
L_THIS_LVL_TBL (1).BURDEN_IND := 0;
L_THIS_LVL_TBL (1).TOTAL_QTY := 0;
L_THIS_LVL_TBL (1).COSTCALC_ORIG := 1;
L_THIS_LVL_TBL (1).RMCALC_TYPE := 1;
L_THIS_LVL_TBL (1).DELETE_MARK := 0;
DBMS_OUTPUT.PUT_LINE ('Start');
GMF_ITEMCOST_PUB.CREATE_ITEM_COST
(P_API_VERSION => 3.0,
P_INIT_MSG_LIST => FND_API.G_FALSE,
P_COMMIT => FND_API.G_FALSE,
X_RETURN_STATUS => L_STATUS,
X_MSG_COUNT => L_COUNT,
X_MSG_DATA => L_DATA,
P_HEADER_REC => L_HEADER_REC,
P_THIS_LEVEL_DTL_TBL => L_THIS_LVL_TBL,
P_LOWER_LEVEL_DTL_TBL => L_LOWER_LVL_TBL,
X_COSTCMPNT_IDS => L_COSTCMPNT_IDS
);
DBMS_OUTPUT.PUT_LINE ('Status:' || L_STATUS);
DBMS_OUTPUT.PUT_LINE ('Debug:' || L_COUNT);
IF L_STATUS = 'S'
THEN
COMMIT;
DBMS_OUTPUT.PUT_LINE ('success!!');
ELSE
IF L_COUNT = 1
THEN
DBMS_OUTPUT.PUT_LINE ('Error 11111 ' || L_DATA);
ELSE
DBMS_OUTPUT.PUT_LINE ( 'status: '
|| L_STATUS
|| ' Error Count '
|| L_COUNT
);
FOR I IN 1 .. L_COUNT
LOOP
FND_MSG_PUB.GET (P_MSG_INDEX => I,
P_DATA => L_DATA,
P_ENCODED => FND_API.G_FALSE,
P_MSG_INDEX_OUT => L_MSG_INDEX_OUT
);
DBMS_OUTPUT.PUT_LINE ('Error 2222: ' || SUBSTR (L_DATA, 1, 255));
END LOOP;
END IF;
END IF;
DBMS_OUTPUT.PUT_LINE ('end of procedure');
END;