因為要開發在另一套BPM系統,所以這次借用API方式更新,網路上常用有兩種API:
ego_item_pub.process_items 和 inv_item_grp.update_item
目前測試兩種都可行,ego_item_pub也可以處理eng item,inv_item_grp我沒試過行不行。
錯誤的話Status會Return:E,基本上若是Return:U 就要debug了,一般只有S:成功或失敗,
偏偏我家的環境出現一個U,抓了半天才發現有人寫的db trigger object失效了@@"。
限制更新欄位跟interface一樣:
PRIMARY_UNIT_OF_MEASURE
...
TEST:
1. EGO_ITEM_PUB
DECLARE
L_ITEM_TABLE EGO_ITEM_PUB.ITEM_TBL_TYPE;
X_ITEM_TABLE EGO_ITEM_PUB.ITEM_TBL_TYPE;
V_MSG_CNT NUMBER(20);
V_RETURN VARCHAR2(1);
V_MSG_LIST ERROR_HANDLER.ERROR_TBL_TYPE;
BEGIN
FND_GLOBAL.APPS_INITIALIZE(123, 50200, 401);
L_ITEM_TABLE(1).TRANSACTION_TYPE := 'UPDATE';
L_ITEM_TABLE(1).INVENTORY_ITEM_ID := 18000; -- INVENTORY_ITEM_ID;
L_ITEM_TABLE(1).ORGANIZATION_ID := 80; -- ORGANIZATION_ID;
L_ITEM_TABLE(1).ATTRIBUTE1 := 'TEST1';
EGO_ITEM_PUB.PROCESS_ITEMS (P_API_VERSION => 1.0,
P_INIT_MSG_LIST => FND_API.G_TRUE,
P_COMMIT => FND_API.G_TRUE,
P_ITEM_TBL => L_ITEM_TABLE,
X_ITEM_TBL => X_ITEM_TABLE,
--P_ROLE_GRANT_TBL => EGO_ITEM_PUB.G_MISS_ROLE_GRANT_TBL,
X_RETURN_STATUS => V_RETURN,
X_MSG_COUNT => V_MSG_CNT
);
DBMS_OUTPUT.PUT_LINE ('RETURN STATUS: ' || V_RETURN);
DBMS_OUTPUT.PUT_LINE ('ERROR MESSAGES: ');
ERROR_HANDLER.GET_MESSAGE_LIST (X_MESSAGE_LIST => V_MSG_LIST);
FOR I IN 1 .. V_MSG_LIST.COUNT
LOOP
DBMS_OUTPUT.PUT_LINE (V_MSG_LIST(I).MESSAGE_TEXT);
END LOOP;
END;
2. INV_ITEM_GRP
DECLARE
L_ITEM_REC INV_ITEM_GRP.ITEM_REC_TYPE;
L_ERROR_TBL INV_ITEM_GRP.ERROR_TBL_TYPE;
X_ITEM_REC INV_ITEM_GRP.ITEM_REC_TYPE;
L_RETURN_STATUS VARCHAR2(40);
BEGIN
L_ITEM_REC.INVENTORY_ITEM_ID := 18000;
L_ITEM_REC.ORGANIZATION_ID := 80;
L_ITEM_REC.PLANNER_CODE := 'EAD';
INV_ITEM_GRP.UPDATE_ITEM(P_COMMIT => FND_API.G_TRUE,
P_LOCK_ROWS => FND_API.G_TRUE,
P_VALIDATION_LEVEL => FND_API.G_VALID_LEVEL_FULL,
P_ITEM_REC => L_ITEM_REC,
X_ITEM_REC => X_ITEM_REC,
X_RETURN_STATUS => L_RETURN_STATUS,
X_ERROR_TBL => L_ERROR_TBL);
IF L_ERROR_TBL.COUNT() > 0 THEN
FOR I IN 1 .. L_ERROR_TBL.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(L_ERROR_TBL(I).MESSAGE_TEXT);
DBMS_OUTPUT.PUT_LINE(L_ERROR_TBL(I).MESSAGE_NAME);
END LOOP;
END IF;
END;