Sample Code :
CREATE PROCEDURE XXX_UPDATE_PO_PRICE(I_PO_NO VARCHAR2,
I_PO_LINE NUMBER,
I_SHIPMENT NUMBER,
I_NEW_PRICE NUMBER,
I_REVISION NUMBER DEFAULT NULL,
I_RELEASE NUMBER DEFAULT NULL)
IS
T_RESUTL NUMBER;
T_API_ERRORS PO_API_ERRORS_REC_TYPE;
BEGIN
--INITIALIZE
FND_GLOBAL.APPS_INITIALIZE(USER_ID => I_USERID,
RESP_ID => 50649, --Modify it.
RESP_APPL_ID => 201); --Modify it.
--
T_RESULT := PO_CHANGE_API1_S.UPDATE_PO(X_PO_NUMBER => I_PO_NO,
X_RELEASE_NUMBER => I_RELEASE,
X_REVISION_NUMBER => I_REVISION,
X_LINE_NUMBER => I_PO_LINE,
X_SHIPMENT_NUMBER => I_SHIPMENT,
NEW_QUANTITY => NULL,
NEW_PRICE => I_NEW_PRICE,
NEW_PROMISED_DATE => NULL,
LAUNCH_APPROVALS_FLAG => 'Y',
UPDATE_SOURCE => 'UPDATE BY API', --Modify it.
VERSION => '1.0',
X_API_ERRORS => T_API_ERRORS,
p_secondary_quantity => NULL,
p_preferred_grade => NULL);
--
COMMIT;
END;
1. 這是個初學農友的農友日誌~ 2. Oracle ERP 分享 3. Oracle DBA 心得 4. Android 開發心得 5. MoJo寵物手作粉絲成員 6. 程式客製及外包專案接案
2012年12月26日 星期三
Oracle ERP R12. - Inactive Price List by API
Sample Code :
CREATE OR REPLACE PROCEDURE XXX_INACTIVE_PRICE_LIST(I_ORG_ID IN NUMBER,
I_LIST_HEADER_ID IN NUMBER,
I_PURGE_LINE IN VARCHAR2 DEFAULT 'N')
IS
/*L_USER_ID NUMBER;
L_RESP_ID NUMBER;
L_APPL_ID NUMBER;*/
gpr_return_status varchar2(1) := NULL;
gpr_msg_count number := 0;
gpr_msg_data varchar2(2000);
gpr_price_list_rec QP_PRICE_LIST_PUB.Price_List_Rec_Type;
gpr_price_list_val_rec QP_PRICE_LIST_PUB.Price_List_Val_Rec_Type;
gpr_price_list_line_tbl QP_PRICE_LIST_PUB.Price_List_Line_Tbl_Type;
gpr_price_list_line_val_tbl QP_PRICE_LIST_PUB.Price_List_Line_Val_Tbl_Type;
gpr_qualifiers_tbl QP_Qualifier_Rules_Pub.Qualifiers_Tbl_Type;
gpr_qualifiers_val_tbl QP_Qualifier_Rules_Pub.Qualifiers_Val_Tbl_Type;
gpr_pricing_attr_tbl QP_PRICE_LIST_PUB.Pricing_Attr_Tbl_Type;
gpr_pricing_attr_val_tbl QP_PRICE_LIST_PUB.Pricing_Attr_Val_Tbl_Type;
ppr_price_list_rec QP_PRICE_LIST_PUB.Price_List_Rec_Type;
ppr_price_list_val_rec QP_PRICE_LIST_PUB.Price_List_Val_Rec_Type;
ppr_price_list_line_tbl QP_PRICE_LIST_PUB.Price_List_Line_Tbl_Type;
ppr_price_list_line_val_tbl QP_PRICE_LIST_PUB.Price_List_Line_Val_Tbl_Type;
ppr_qualifiers_tbl QP_Qualifier_Rules_Pub.Qualifiers_Tbl_Type;
ppr_qualifiers_val_tbl QP_Qualifier_Rules_Pub.Qualifiers_Val_Tbl_Type;
ppr_pricing_attr_tbl QP_PRICE_LIST_PUB.Pricing_Attr_Tbl_Type;
ppr_pricing_attr_val_tbl QP_PRICE_LIST_PUB.Pricing_Attr_Val_Tbl_Type;
--
CURSOR C_LINES IS
SELECT DISTINCT QLL.LIST_LINE_ID
FROM QP_LIST_LINES QLL
WHERE QLL.LIST_HEADER_ID = I_LIST_HEADER_ID;
BEGIN
/*SELECT USER_ID
INTO L_USER_ID
FROM FND_USER WHERE USER_NAME = 'A0964';
--
SELECT RESPONSIBILITY_ID, APPLICATION_ID
INTO L_RESP_ID, L_APPL_ID
FROM FND_RESPONSIBILITY_VL
WHERE UPPER(RESPONSIBILITY_NAME) LIKE 'OM FOR SUPERUSER(TSN)';
--
FND_GLOBAL.APPS_INITIALIZE(L_USER_ID, L_RESP_ID, L_APPL_ID);*/
gpr_price_list_rec.list_type_code := 'PRL';
gpr_price_list_rec.operation := QP_GLOBALS.G_OPR_UPDATE;
gpr_price_list_rec.active_flag := 'N';
gpr_price_list_rec.list_header_id := I_LIST_HEADER_ID;
gpr_price_list_rec.comments := 'Inactive by SYSADMIN';
--
QP_PRICE_LIST_PUB.Process_Price_List(p_api_version_number => 1,
p_init_msg_list => FND_API.G_FALSE,
p_return_values => FND_API.G_FALSE,
p_commit => FND_API.G_FALSE,
x_return_status => gpr_return_status,
x_msg_count => gpr_msg_count,
x_msg_data => gpr_msg_data,
p_PRICE_LIST_rec => gpr_price_list_rec,
p_PRICE_LIST_LINE_tbl => gpr_price_list_line_tbl,
p_PRICING_ATTR_tbl => gpr_pricing_attr_tbl,
x_PRICE_LIST_rec => ppr_price_list_rec,
x_PRICE_LIST_val_rec => ppr_price_list_val_rec,
x_PRICE_LIST_LINE_tbl => ppr_price_list_line_tbl,
x_PRICE_LIST_LINE_val_tbl => ppr_price_list_line_val_tbl,
x_QUALIFIERS_tbl => ppr_qualifiers_tbl,
x_QUALIFIERS_val_tbl => ppr_qualifiers_val_tbl,
x_PRICING_ATTR_tbl => ppr_pricing_attr_tbl,
x_PRICING_ATTR_val_tbl => ppr_pricing_attr_val_tbl);
--
COMMIT;
--
IF I_PURGE_LINE = 'Y' THEN
FOR C1 IN C_LINES LOOP
gpr_price_list_line_tbl(1).list_line_id := C1.LIST_LINE_ID;
gpr_price_list_line_tbl(1).list_line_type_code := 'PLL';
gpr_price_list_line_tbl(1).operation := QP_GLOBALS.G_OPR_DELETE;
QP_PRICE_LIST_PUB.Process_Price_List(p_api_version_number => 1,
p_init_msg_list => FND_API.G_FALSE,
p_return_values => FND_API.G_FALSE,
p_commit => FND_API.G_FALSE,
x_return_status => gpr_return_status,
x_msg_count => gpr_msg_count,
x_msg_data => gpr_msg_data,
p_PRICE_LIST_rec => gpr_price_list_rec,
p_PRICE_LIST_LINE_tbl => gpr_price_list_line_tbl,
p_PRICING_ATTR_tbl => gpr_pricing_attr_tbl,
x_PRICE_LIST_rec => ppr_price_list_rec,
x_PRICE_LIST_val_rec => ppr_price_list_val_rec,
x_PRICE_LIST_LINE_tbl => ppr_price_list_line_tbl,
x_PRICE_LIST_LINE_val_tbl => ppr_price_list_line_val_tbl,
x_QUALIFIERS_tbl => ppr_qualifiers_tbl,
x_QUALIFIERS_val_tbl => ppr_qualifiers_val_tbl,
x_PRICING_ATTR_tbl => ppr_pricing_attr_tbl,
x_PRICING_ATTR_val_tbl => ppr_pricing_attr_val_tbl);
COMMIT;
END LOOP;
END IF;
END;
CREATE OR REPLACE PROCEDURE XXX_INACTIVE_PRICE_LIST(I_ORG_ID IN NUMBER,
I_LIST_HEADER_ID IN NUMBER,
I_PURGE_LINE IN VARCHAR2 DEFAULT 'N')
IS
/*L_USER_ID NUMBER;
L_RESP_ID NUMBER;
L_APPL_ID NUMBER;*/
gpr_return_status varchar2(1) := NULL;
gpr_msg_count number := 0;
gpr_msg_data varchar2(2000);
gpr_price_list_rec QP_PRICE_LIST_PUB.Price_List_Rec_Type;
gpr_price_list_val_rec QP_PRICE_LIST_PUB.Price_List_Val_Rec_Type;
gpr_price_list_line_tbl QP_PRICE_LIST_PUB.Price_List_Line_Tbl_Type;
gpr_price_list_line_val_tbl QP_PRICE_LIST_PUB.Price_List_Line_Val_Tbl_Type;
gpr_qualifiers_tbl QP_Qualifier_Rules_Pub.Qualifiers_Tbl_Type;
gpr_qualifiers_val_tbl QP_Qualifier_Rules_Pub.Qualifiers_Val_Tbl_Type;
gpr_pricing_attr_tbl QP_PRICE_LIST_PUB.Pricing_Attr_Tbl_Type;
gpr_pricing_attr_val_tbl QP_PRICE_LIST_PUB.Pricing_Attr_Val_Tbl_Type;
ppr_price_list_rec QP_PRICE_LIST_PUB.Price_List_Rec_Type;
ppr_price_list_val_rec QP_PRICE_LIST_PUB.Price_List_Val_Rec_Type;
ppr_price_list_line_tbl QP_PRICE_LIST_PUB.Price_List_Line_Tbl_Type;
ppr_price_list_line_val_tbl QP_PRICE_LIST_PUB.Price_List_Line_Val_Tbl_Type;
ppr_qualifiers_tbl QP_Qualifier_Rules_Pub.Qualifiers_Tbl_Type;
ppr_qualifiers_val_tbl QP_Qualifier_Rules_Pub.Qualifiers_Val_Tbl_Type;
ppr_pricing_attr_tbl QP_PRICE_LIST_PUB.Pricing_Attr_Tbl_Type;
ppr_pricing_attr_val_tbl QP_PRICE_LIST_PUB.Pricing_Attr_Val_Tbl_Type;
--
CURSOR C_LINES IS
SELECT DISTINCT QLL.LIST_LINE_ID
FROM QP_LIST_LINES QLL
WHERE QLL.LIST_HEADER_ID = I_LIST_HEADER_ID;
BEGIN
/*SELECT USER_ID
INTO L_USER_ID
FROM FND_USER WHERE USER_NAME = 'A0964';
--
SELECT RESPONSIBILITY_ID, APPLICATION_ID
INTO L_RESP_ID, L_APPL_ID
FROM FND_RESPONSIBILITY_VL
WHERE UPPER(RESPONSIBILITY_NAME) LIKE 'OM FOR SUPERUSER(TSN)';
--
FND_GLOBAL.APPS_INITIALIZE(L_USER_ID, L_RESP_ID, L_APPL_ID);*/
gpr_price_list_rec.list_type_code := 'PRL';
gpr_price_list_rec.operation := QP_GLOBALS.G_OPR_UPDATE;
gpr_price_list_rec.active_flag := 'N';
gpr_price_list_rec.list_header_id := I_LIST_HEADER_ID;
gpr_price_list_rec.comments := 'Inactive by SYSADMIN';
--
QP_PRICE_LIST_PUB.Process_Price_List(p_api_version_number => 1,
p_init_msg_list => FND_API.G_FALSE,
p_return_values => FND_API.G_FALSE,
p_commit => FND_API.G_FALSE,
x_return_status => gpr_return_status,
x_msg_count => gpr_msg_count,
x_msg_data => gpr_msg_data,
p_PRICE_LIST_rec => gpr_price_list_rec,
p_PRICE_LIST_LINE_tbl => gpr_price_list_line_tbl,
p_PRICING_ATTR_tbl => gpr_pricing_attr_tbl,
x_PRICE_LIST_rec => ppr_price_list_rec,
x_PRICE_LIST_val_rec => ppr_price_list_val_rec,
x_PRICE_LIST_LINE_tbl => ppr_price_list_line_tbl,
x_PRICE_LIST_LINE_val_tbl => ppr_price_list_line_val_tbl,
x_QUALIFIERS_tbl => ppr_qualifiers_tbl,
x_QUALIFIERS_val_tbl => ppr_qualifiers_val_tbl,
x_PRICING_ATTR_tbl => ppr_pricing_attr_tbl,
x_PRICING_ATTR_val_tbl => ppr_pricing_attr_val_tbl);
--
COMMIT;
--
IF I_PURGE_LINE = 'Y' THEN
FOR C1 IN C_LINES LOOP
gpr_price_list_line_tbl(1).list_line_id := C1.LIST_LINE_ID;
gpr_price_list_line_tbl(1).list_line_type_code := 'PLL';
gpr_price_list_line_tbl(1).operation := QP_GLOBALS.G_OPR_DELETE;
QP_PRICE_LIST_PUB.Process_Price_List(p_api_version_number => 1,
p_init_msg_list => FND_API.G_FALSE,
p_return_values => FND_API.G_FALSE,
p_commit => FND_API.G_FALSE,
x_return_status => gpr_return_status,
x_msg_count => gpr_msg_count,
x_msg_data => gpr_msg_data,
p_PRICE_LIST_rec => gpr_price_list_rec,
p_PRICE_LIST_LINE_tbl => gpr_price_list_line_tbl,
p_PRICING_ATTR_tbl => gpr_pricing_attr_tbl,
x_PRICE_LIST_rec => ppr_price_list_rec,
x_PRICE_LIST_val_rec => ppr_price_list_val_rec,
x_PRICE_LIST_LINE_tbl => ppr_price_list_line_tbl,
x_PRICE_LIST_LINE_val_tbl => ppr_price_list_line_val_tbl,
x_QUALIFIERS_tbl => ppr_qualifiers_tbl,
x_QUALIFIERS_val_tbl => ppr_qualifiers_val_tbl,
x_PRICING_ATTR_tbl => ppr_pricing_attr_tbl,
x_PRICING_ATTR_val_tbl => ppr_pricing_attr_val_tbl);
COMMIT;
END LOOP;
END IF;
END;
Oracle ERP R12. - Update Sales Order promise date / request date / explosion date by API
Sample code :
PROCEDURE XXX_UPDATE_SO_DATE(I_HEADER_ID IN NUMBER,
I_LINE_ID IN NUMBER,
I_REQUEST_DATE IN DATE,
I_EXPLOSION_DATE IN DATE,
I_PROMISE_DATE IN DATE,
O_RESULT OUT VARCHAR2) IS
/*L_USER_ID NUMBER;
L_RESP_ID NUMBER;
L_APPL_ID NUMBER;*/
L_LINE_TBL_IN OE_ORDER_PUB.LINE_TBL_TYPE;
L_HEADER_REC_OUT OE_ORDER_PUB.HEADER_REC_TYPE;
L_LINE_TBL_OUT OE_ORDER_PUB.LINE_TBL_TYPE;
L_HEADER_VAL_REC_OUT OE_ORDER_PUB.HEADER_VAL_REC_TYPE;
L_HEADER_ADJ_TBL_OUT OE_ORDER_PUB.HEADER_ADJ_TBL_TYPE;
L_HEADER_ADJ_VAL_TBL_OUT OE_ORDER_PUB.HEADER_ADJ_VAL_TBL_TYPE;
L_HEADER_PRICE_ATT_TBL_OUT OE_ORDER_PUB.HEADER_PRICE_ATT_TBL_TYPE;
L_HEADER_ADJ_ATT_TBL_OUT OE_ORDER_PUB.HEADER_ADJ_ATT_TBL_TYPE;
L_HEADER_ADJ_ASSOC_TBL_OUT OE_ORDER_PUB.HEADER_ADJ_ASSOC_TBL_TYPE;
L_HEADER_SCREDIT_TBL_OUT OE_ORDER_PUB.HEADER_SCREDIT_TBL_TYPE;
L_HEADER_SCREDIT_VAL_TBL_OUT OE_ORDER_PUB.HEADER_SCREDIT_VAL_TBL_TYPE;
L_LINE_VAL_TBL_OUT OE_ORDER_PUB.LINE_VAL_TBL_TYPE;
L_LINE_ADJ_TBL_OUT OE_ORDER_PUB.LINE_ADJ_TBL_TYPE;
L_LINE_ADJ_VAL_TBL_OUT OE_ORDER_PUB.LINE_ADJ_VAL_TBL_TYPE;
L_LINE_PRICE_ATT_TBL_OUT OE_ORDER_PUB.LINE_PRICE_ATT_TBL_TYPE;
L_LINE_ADJ_ATT_TBL_OUT OE_ORDER_PUB.LINE_ADJ_ATT_TBL_TYPE;
L_LINE_ADJ_ASSOC_TBL_OUT OE_ORDER_PUB.LINE_ADJ_ASSOC_TBL_TYPE;
L_LINE_SCREDIT_TBL_OUT OE_ORDER_PUB.LINE_SCREDIT_TBL_TYPE;
L_LINE_SCREDIT_VAL_TBL_OUT OE_ORDER_PUB.LINE_SCREDIT_VAL_TBL_TYPE;
L_LOT_SERIAL_TBL_OUT OE_ORDER_PUB.LOT_SERIAL_TBL_TYPE;
L_LOT_SERIAL_VAL_TBL_OUT OE_ORDER_PUB.LOT_SERIAL_VAL_TBL_TYPE;
L_ACTION_REQUEST_TBL_OUT OE_ORDER_PUB.REQUEST_TBL_TYPE;
L_MSG_COUNT NUMBER := 0;
L_MSG_DATA VARCHAR2(2000);
L_NUM_API_VERSION NUMBER := 1.0;
BEGIN
/*
SELECT USER_ID
INTO L_USER_ID
FROM FND_USER WHERE USER_NAME = 'A0964';
--
SELECT RESPONSIBILITY_ID, APPLICATION_ID
INTO L_RESP_ID, L_APPL_ID
FROM FND_RESPONSIBILITY_VL
WHERE UPPER(RESPONSIBILITY_NAME) LIKE 'OM FOR SUPERUSER';
--
FND_GLOBAL.APPS_INITIALIZE(L_USER_ID, L_RESP_ID, L_APPL_ID);*/
--
L_LINE_TBL_IN(1) := OE_ORDER_PUB.G_MISS_LINE_REC;
L_LINE_TBL_IN(1).HEADER_ID := I_HEADER_ID;
L_LINE_TBL_IN(1).LINE_ID := I_LINE_ID;
L_LINE_TBL_IN(1).OPERATION := OE_GLOBALS.G_OPR_UPDATE;
--
IF I_EXPLOSION_DATE IS NOT NULL THEN
L_LINE_TBL_IN(1).EXPLOSION_DATE := TO_DATE(TO_CHAR(I_EXPLOSION_DATE,
'YYYY/MM/DD HH24:MI:SS'),
'YYYY/MM/DD HH24:MI:SS');
END IF;
--
IF I_PROMISE_DATE IS NOT NULL THEN
L_LINE_TBL_IN(1).PROMISE_DATE := TO_DATE(TO_CHAR(I_PROMISE_DATE,
'YYYY/MM/DD HH24:MI:SS'),
'YYYY/MM/DD HH24:MI:SS');
END IF;
--
IF I_REQUEST_DATE IS NOT NULL THEN
L_LINE_TBL_IN(1).REQUEST_DATE := TO_DATE(TO_CHAR(I_REQUEST_DATE,
'YYYY/MM/DD HH24:MI:SS'),
'YYYY/MM/DD HH24:MI:SS');
END IF;
--
OE_MSG_PUB.DELETE_MSG;
--CALL API
OE_ORDER_PUB.PROCESS_ORDER(P_API_VERSION_NUMBER => L_NUM_API_VERSION,
P_INIT_MSG_LIST => FND_API.G_FALSE,
P_RETURN_VALUES => FND_API.G_FALSE,
P_ACTION_COMMIT => FND_API.G_FALSE,
P_LINE_TBL => L_LINE_TBL_IN,
X_HEADER_REC => L_HEADER_REC_OUT,
X_HEADER_VAL_REC => L_HEADER_VAL_REC_OUT,
X_HEADER_ADJ_TBL => L_HEADER_ADJ_TBL_OUT,
X_HEADER_ADJ_VAL_TBL => L_HEADER_ADJ_VAL_TBL_OUT,
X_HEADER_PRICE_ATT_TBL => L_HEADER_PRICE_ATT_TBL_OUT,
X_HEADER_ADJ_ATT_TBL => L_HEADER_ADJ_ATT_TBL_OUT,
X_HEADER_ADJ_ASSOC_TBL => L_HEADER_ADJ_ASSOC_TBL_OUT,
X_HEADER_SCREDIT_TBL => L_HEADER_SCREDIT_TBL_OUT,
X_HEADER_SCREDIT_VAL_TBL => L_HEADER_SCREDIT_VAL_TBL_OUT,
X_LINE_TBL => L_LINE_TBL_OUT,
X_LINE_VAL_TBL => L_LINE_VAL_TBL_OUT,
X_LINE_ADJ_TBL => L_LINE_ADJ_TBL_OUT,
X_LINE_ADJ_VAL_TBL => L_LINE_ADJ_VAL_TBL_OUT,
X_LINE_PRICE_ATT_TBL => L_LINE_PRICE_ATT_TBL_OUT,
X_LINE_ADJ_ATT_TBL => L_LINE_ADJ_ATT_TBL_OUT,
X_LINE_ADJ_ASSOC_TBL => L_LINE_ADJ_ASSOC_TBL_OUT,
X_LINE_SCREDIT_TBL => L_LINE_SCREDIT_TBL_OUT,
X_LINE_SCREDIT_VAL_TBL => L_LINE_SCREDIT_VAL_TBL_OUT,
X_LOT_SERIAL_TBL => L_LOT_SERIAL_TBL_OUT,
X_LOT_SERIAL_VAL_TBL => L_LOT_SERIAL_VAL_TBL_OUT,
X_ACTION_REQUEST_TBL => L_ACTION_REQUEST_TBL_OUT,
X_RETURN_STATUS => O_RESULT,
X_MSG_COUNT => L_MSG_COUNT,
X_MSG_DATA => L_MSG_DATA);
--
IF L_MSG_COUNT > 0 THEN
FOR L_INDEX IN 1 .. L_MSG_COUNT LOOP
L_MSG_DATA := OE_MSG_PUB.GET(P_MSG_INDEX => L_INDEX, P_ENCODED => 'F');
END LOOP;
END IF;
--
IF O_RESULT = FND_API.G_RET_STS_SUCCESS THEN
COMMIT;
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
PROCEDURE XXX_UPDATE_SO_DATE(I_HEADER_ID IN NUMBER,
I_LINE_ID IN NUMBER,
I_REQUEST_DATE IN DATE,
I_EXPLOSION_DATE IN DATE,
I_PROMISE_DATE IN DATE,
O_RESULT OUT VARCHAR2) IS
/*L_USER_ID NUMBER;
L_RESP_ID NUMBER;
L_APPL_ID NUMBER;*/
L_LINE_TBL_IN OE_ORDER_PUB.LINE_TBL_TYPE;
L_HEADER_REC_OUT OE_ORDER_PUB.HEADER_REC_TYPE;
L_LINE_TBL_OUT OE_ORDER_PUB.LINE_TBL_TYPE;
L_HEADER_VAL_REC_OUT OE_ORDER_PUB.HEADER_VAL_REC_TYPE;
L_HEADER_ADJ_TBL_OUT OE_ORDER_PUB.HEADER_ADJ_TBL_TYPE;
L_HEADER_ADJ_VAL_TBL_OUT OE_ORDER_PUB.HEADER_ADJ_VAL_TBL_TYPE;
L_HEADER_PRICE_ATT_TBL_OUT OE_ORDER_PUB.HEADER_PRICE_ATT_TBL_TYPE;
L_HEADER_ADJ_ATT_TBL_OUT OE_ORDER_PUB.HEADER_ADJ_ATT_TBL_TYPE;
L_HEADER_ADJ_ASSOC_TBL_OUT OE_ORDER_PUB.HEADER_ADJ_ASSOC_TBL_TYPE;
L_HEADER_SCREDIT_TBL_OUT OE_ORDER_PUB.HEADER_SCREDIT_TBL_TYPE;
L_HEADER_SCREDIT_VAL_TBL_OUT OE_ORDER_PUB.HEADER_SCREDIT_VAL_TBL_TYPE;
L_LINE_VAL_TBL_OUT OE_ORDER_PUB.LINE_VAL_TBL_TYPE;
L_LINE_ADJ_TBL_OUT OE_ORDER_PUB.LINE_ADJ_TBL_TYPE;
L_LINE_ADJ_VAL_TBL_OUT OE_ORDER_PUB.LINE_ADJ_VAL_TBL_TYPE;
L_LINE_PRICE_ATT_TBL_OUT OE_ORDER_PUB.LINE_PRICE_ATT_TBL_TYPE;
L_LINE_ADJ_ATT_TBL_OUT OE_ORDER_PUB.LINE_ADJ_ATT_TBL_TYPE;
L_LINE_ADJ_ASSOC_TBL_OUT OE_ORDER_PUB.LINE_ADJ_ASSOC_TBL_TYPE;
L_LINE_SCREDIT_TBL_OUT OE_ORDER_PUB.LINE_SCREDIT_TBL_TYPE;
L_LINE_SCREDIT_VAL_TBL_OUT OE_ORDER_PUB.LINE_SCREDIT_VAL_TBL_TYPE;
L_LOT_SERIAL_TBL_OUT OE_ORDER_PUB.LOT_SERIAL_TBL_TYPE;
L_LOT_SERIAL_VAL_TBL_OUT OE_ORDER_PUB.LOT_SERIAL_VAL_TBL_TYPE;
L_ACTION_REQUEST_TBL_OUT OE_ORDER_PUB.REQUEST_TBL_TYPE;
L_MSG_COUNT NUMBER := 0;
L_MSG_DATA VARCHAR2(2000);
L_NUM_API_VERSION NUMBER := 1.0;
BEGIN
/*
SELECT USER_ID
INTO L_USER_ID
FROM FND_USER WHERE USER_NAME = 'A0964';
--
SELECT RESPONSIBILITY_ID, APPLICATION_ID
INTO L_RESP_ID, L_APPL_ID
FROM FND_RESPONSIBILITY_VL
WHERE UPPER(RESPONSIBILITY_NAME) LIKE 'OM FOR SUPERUSER';
--
FND_GLOBAL.APPS_INITIALIZE(L_USER_ID, L_RESP_ID, L_APPL_ID);*/
--
L_LINE_TBL_IN(1) := OE_ORDER_PUB.G_MISS_LINE_REC;
L_LINE_TBL_IN(1).HEADER_ID := I_HEADER_ID;
L_LINE_TBL_IN(1).LINE_ID := I_LINE_ID;
L_LINE_TBL_IN(1).OPERATION := OE_GLOBALS.G_OPR_UPDATE;
--
IF I_EXPLOSION_DATE IS NOT NULL THEN
L_LINE_TBL_IN(1).EXPLOSION_DATE := TO_DATE(TO_CHAR(I_EXPLOSION_DATE,
'YYYY/MM/DD HH24:MI:SS'),
'YYYY/MM/DD HH24:MI:SS');
END IF;
--
IF I_PROMISE_DATE IS NOT NULL THEN
L_LINE_TBL_IN(1).PROMISE_DATE := TO_DATE(TO_CHAR(I_PROMISE_DATE,
'YYYY/MM/DD HH24:MI:SS'),
'YYYY/MM/DD HH24:MI:SS');
END IF;
--
IF I_REQUEST_DATE IS NOT NULL THEN
L_LINE_TBL_IN(1).REQUEST_DATE := TO_DATE(TO_CHAR(I_REQUEST_DATE,
'YYYY/MM/DD HH24:MI:SS'),
'YYYY/MM/DD HH24:MI:SS');
END IF;
--
OE_MSG_PUB.DELETE_MSG;
--CALL API
OE_ORDER_PUB.PROCESS_ORDER(P_API_VERSION_NUMBER => L_NUM_API_VERSION,
P_INIT_MSG_LIST => FND_API.G_FALSE,
P_RETURN_VALUES => FND_API.G_FALSE,
P_ACTION_COMMIT => FND_API.G_FALSE,
P_LINE_TBL => L_LINE_TBL_IN,
X_HEADER_REC => L_HEADER_REC_OUT,
X_HEADER_VAL_REC => L_HEADER_VAL_REC_OUT,
X_HEADER_ADJ_TBL => L_HEADER_ADJ_TBL_OUT,
X_HEADER_ADJ_VAL_TBL => L_HEADER_ADJ_VAL_TBL_OUT,
X_HEADER_PRICE_ATT_TBL => L_HEADER_PRICE_ATT_TBL_OUT,
X_HEADER_ADJ_ATT_TBL => L_HEADER_ADJ_ATT_TBL_OUT,
X_HEADER_ADJ_ASSOC_TBL => L_HEADER_ADJ_ASSOC_TBL_OUT,
X_HEADER_SCREDIT_TBL => L_HEADER_SCREDIT_TBL_OUT,
X_HEADER_SCREDIT_VAL_TBL => L_HEADER_SCREDIT_VAL_TBL_OUT,
X_LINE_TBL => L_LINE_TBL_OUT,
X_LINE_VAL_TBL => L_LINE_VAL_TBL_OUT,
X_LINE_ADJ_TBL => L_LINE_ADJ_TBL_OUT,
X_LINE_ADJ_VAL_TBL => L_LINE_ADJ_VAL_TBL_OUT,
X_LINE_PRICE_ATT_TBL => L_LINE_PRICE_ATT_TBL_OUT,
X_LINE_ADJ_ATT_TBL => L_LINE_ADJ_ATT_TBL_OUT,
X_LINE_ADJ_ASSOC_TBL => L_LINE_ADJ_ASSOC_TBL_OUT,
X_LINE_SCREDIT_TBL => L_LINE_SCREDIT_TBL_OUT,
X_LINE_SCREDIT_VAL_TBL => L_LINE_SCREDIT_VAL_TBL_OUT,
X_LOT_SERIAL_TBL => L_LOT_SERIAL_TBL_OUT,
X_LOT_SERIAL_VAL_TBL => L_LOT_SERIAL_VAL_TBL_OUT,
X_ACTION_REQUEST_TBL => L_ACTION_REQUEST_TBL_OUT,
X_RETURN_STATUS => O_RESULT,
X_MSG_COUNT => L_MSG_COUNT,
X_MSG_DATA => L_MSG_DATA);
--
IF L_MSG_COUNT > 0 THEN
FOR L_INDEX IN 1 .. L_MSG_COUNT LOOP
L_MSG_DATA := OE_MSG_PUB.GET(P_MSG_INDEX => L_INDEX, P_ENCODED => 'F');
END LOOP;
END IF;
--
IF O_RESULT = FND_API.G_RET_STS_SUCCESS THEN
COMMIT;
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
2012年12月25日 星期二
Oracle ERP R12. - Close PO by API
Sample code for close PO by API.
CREATE PROCEDURE XXX_CLOSE_PO_LINE(I_PO_HEADER_ID IN NUMBER,
I_PO_LINE_ID IN NUMBER,
I_ACTION IN VARCHAR2,
I_REASON IN VARCHAR2,
I_USER_ID IN NUMBER,
O_RESULT OUT BOOLEAN,
O_RETURN_CODE OUT VARCHAR2)
IS
BEGIN
FND_GLOBAL.APPS_INITIALIZE (USER_ID => I_USER_ID,
RESP_ID => 20707, --Modify it.
RESP_APPL_ID => 201); --Modify it.
--
O_RESULT := PO_ACTIONS.CLOSE_PO(P_DOCID => I_PO_HEADER_ID,
P_DOCTYP => 'PO',
P_DOCSUBTYP => 'STANDARD',
P_LINEID => I_PO_LINE_ID,
P_SHIPID => NULL,
P_ACTION => 'CLOSE',
P_REASON => I_REASON,
P_CALLING_MODE => 'PO',
P_CONC_FLAG => 'N',
P_RETURN_CODE => O_RETURN_CODE,
P_AUTO_CLOSE => 'N',
P_ACTION_DATE => SYSDATE,
P_ORIGIN_DOC_ID => NULL);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END XXX_CLOSE_PO_LINE;
CREATE PROCEDURE XXX_CLOSE_PO_LINE(I_PO_HEADER_ID IN NUMBER,
I_PO_LINE_ID IN NUMBER,
I_ACTION IN VARCHAR2,
I_REASON IN VARCHAR2,
I_USER_ID IN NUMBER,
O_RESULT OUT BOOLEAN,
O_RETURN_CODE OUT VARCHAR2)
IS
BEGIN
FND_GLOBAL.APPS_INITIALIZE (USER_ID => I_USER_ID,
RESP_ID => 20707, --Modify it.
RESP_APPL_ID => 201); --Modify it.
--
O_RESULT := PO_ACTIONS.CLOSE_PO(P_DOCID => I_PO_HEADER_ID,
P_DOCTYP => 'PO',
P_DOCSUBTYP => 'STANDARD',
P_LINEID => I_PO_LINE_ID,
P_SHIPID => NULL,
P_ACTION => 'CLOSE',
P_REASON => I_REASON,
P_CALLING_MODE => 'PO',
P_CONC_FLAG => 'N',
P_RETURN_CODE => O_RETURN_CODE,
P_AUTO_CLOSE => 'N',
P_ACTION_DATE => SYSDATE,
P_ORIGIN_DOC_ID => NULL);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END XXX_CLOSE_PO_LINE;
Oracle ERP R12. - Approval PO By API
Sample code for approval PO by API.
CREATE OR REPLACE PROCEDURE XX_PO_APPROVE_ACTION(I_HEADER_ID IN NUMBER,
X_RET_CODE OUT VARCHAR2, --S : Success / E : Error
X_RET_MSG OUT VARCHAR2 --Error message
)
IS
/**********************************************************************
I_ACTION ==>
*********************************************************************/
V_STATUS VARCHAR2(100); --For check this HEADER_ID Status. (Is 'INCOMPLETE' ?)
V_RETURN_CODE VARCHAR2(1) := 'S'; --Process status code ==> S : Success / E : Error
V_RETURN_MSG VARCHAR2(2000); --Error message
V_ITEM_KEY VARCHAR2(200); --For API
V_ITEM_TYPE VARCHAR2(20);
V_SEGMENT1 PO_HEADERS_ALL.SEGMENT1%TYPE; --For API
V_PREPARER_ID PO_HEADERS_ALL.AGENT_ID%TYPE; --For API
V_DOCUMENT_TYPE_CODE PO_DOCUMENT_TYPES_ALL.DOCUMENT_TYPE_CODE%TYPE; --For API
V_DOCUMENT_SUBTYPE PO_DOCUMENT_TYPES_ALL.DOCUMENT_SUBTYPE%TYPE; --For API
BEGIN
--Check PO HEADER_ID is exists ?
BEGIN
SELECT AUTHORIZATION_STATUS
INTO V_STATUS
FROM PO_HEADERS_ALL A
WHERE A.PO_HEADER_ID = I_HEADER_ID;
EXCEPTION
WHEN NO_DATA_FOUND THEN
V_STATUS := NULL;
V_RETURN_MSG := 'No data found : PO_HEADER_ID ==> '||I_HEADER_ID;
V_RETURN_CODE := 'E';
END;
IF V_RETURN_CODE = 'S' THEN
BEGIN
--Find API parameters
SELECT pha.org_id,
pha.agent_id,
pha.segment1,
pha.wf_item_type,
pha.wf_item_key,
pdt.document_subtype,
pdt.document_type_code
INTO V_ORG_ID,
V_PREPARER_ID,
V_SEGMENT1,
v_ITEM_TYPE,
V_ITEM_KEY,
V_DOCUMENT_SUBTYPE,
V_DOCUMENT_TYPE_CODE
FROM apps.po_headers_all pha, apps.po_document_types_all pdt
WHERE pha.type_lookup_code = pdt.document_subtype
AND pha.org_id = pdt.org_id
AND pdt.document_type_code = 'PO'
AND pha.PO_HEADER_ID = I_HEADER_ID;
EXCEPTION
WHEN OTHERS THEN
V_RETURN_MSG := 'No data found : po_document_types_all - ' || sqlerrm;
V_RETURN_CODE := 'E';
END;
END IF;
IF V_RETURN_CODE = 'S' THEN
mo_global.init('PO');
mo_global.set_policy_context('S', V_ORG_ID);
SELECT I_HEADER_ID /*P_EP_PO_HEADER_ID*/
|| '-' || TO_CHAR(PO_WF_ITEMKEY_S.NEXTVAL)
INTO V_ITEM_KEY
FROM DUAL;
--ORACLE API
BEGIN
--Restart WorkFlow
PO_REQAPPROVAL_INIT1.START_WF_PROCESS(ItemType => V_ITEM_TYPE, --'POAPPRV',
ItemKey => V_ITEM_KEY,
WorkflowProcess => 'POAPPRV_TOP',
ActionOriginatedFrom => 'PO_FORM',
DocumentID => I_HEADER_ID,
DocumentNumber => V_SEGMENT1, -- Purchase Order Number
PreparerID => V_PREPARER_ID, -- Buyer/Preparer_id
DocumentTypeCode => V_DOCUMENT_TYPE_CODE,
DocumentSubtype => V_DOCUMENT_SUBTYPE,
SubmitterAction => 'APPROVE',
forwardToID => NULL,
forwardFromID => NULL,
DefaultApprovalPathID => NULL,
Note => NULL,
PrintFlag => 'N',
FaxFlag => 'N',
FaxNumber => NULL,
EmailFlag => 'N',
EmailAddress => NULL,
CreateSourcingRule => 'N',
ReleaseGenMethod => 'N',
UpdateSourcingRule => 'N',
MassUpdateReleases => 'N',
RetroactivePriceChange => 'N',
OrgAssignChange => 'N',
CommunicatePriceChange => 'N',
p_Background_Flag => 'N', --N:標準API會COMMIT
p_Initiator => NULL,
p_xml_flag => NULL,
FpdsngFlag => 'N',
p_source_type_code => NULL);
--API
PO_REQAPPROVAL_ACTION.APPROVE_DOC(V_ITEM_TYPE,
V_ITEM_KEY,
NULL,
'RUN',
X_RET_MSG); --20120303
END;
IF NVL(V_RETURN_CODE, 'S') <> 'E' THEN
V_RETURN_CODE := 'S';
END IF;
END IF;
FND_FILE.PUT_LINE(FND_FILE.LOG, 'V_RETURN_CODE=' || V_RETURN_CODE);
FND_FILE.PUT_LINE(FND_FILE.LOG, 'V_RETURN_MSG=' || V_RETURN_MSG);
X_RET_CODE := V_RETURN_CODE;
X_RET_MSG := V_RETURN_MSG;
END XX_PO_APPROVE_ACTION;
CREATE OR REPLACE PROCEDURE XX_PO_APPROVE_ACTION(I_HEADER_ID IN NUMBER,
X_RET_CODE OUT VARCHAR2, --S : Success / E : Error
X_RET_MSG OUT VARCHAR2 --Error message
)
IS
/**********************************************************************
I_ACTION ==>
*********************************************************************/
V_STATUS VARCHAR2(100); --For check this HEADER_ID Status. (Is 'INCOMPLETE' ?)
V_RETURN_CODE VARCHAR2(1) := 'S'; --Process status code ==> S : Success / E : Error
V_RETURN_MSG VARCHAR2(2000); --Error message
V_ITEM_KEY VARCHAR2(200); --For API
V_ITEM_TYPE VARCHAR2(20);
V_SEGMENT1 PO_HEADERS_ALL.SEGMENT1%TYPE; --For API
V_PREPARER_ID PO_HEADERS_ALL.AGENT_ID%TYPE; --For API
V_DOCUMENT_TYPE_CODE PO_DOCUMENT_TYPES_ALL.DOCUMENT_TYPE_CODE%TYPE; --For API
V_DOCUMENT_SUBTYPE PO_DOCUMENT_TYPES_ALL.DOCUMENT_SUBTYPE%TYPE; --For API
BEGIN
--Check PO HEADER_ID is exists ?
BEGIN
SELECT AUTHORIZATION_STATUS
INTO V_STATUS
FROM PO_HEADERS_ALL A
WHERE A.PO_HEADER_ID = I_HEADER_ID;
EXCEPTION
WHEN NO_DATA_FOUND THEN
V_STATUS := NULL;
V_RETURN_MSG := 'No data found : PO_HEADER_ID ==> '||I_HEADER_ID;
V_RETURN_CODE := 'E';
END;
IF V_RETURN_CODE = 'S' THEN
BEGIN
--Find API parameters
SELECT pha.org_id,
pha.agent_id,
pha.segment1,
pha.wf_item_type,
pha.wf_item_key,
pdt.document_subtype,
pdt.document_type_code
INTO V_ORG_ID,
V_PREPARER_ID,
V_SEGMENT1,
v_ITEM_TYPE,
V_ITEM_KEY,
V_DOCUMENT_SUBTYPE,
V_DOCUMENT_TYPE_CODE
FROM apps.po_headers_all pha, apps.po_document_types_all pdt
WHERE pha.type_lookup_code = pdt.document_subtype
AND pha.org_id = pdt.org_id
AND pdt.document_type_code = 'PO'
AND pha.PO_HEADER_ID = I_HEADER_ID;
EXCEPTION
WHEN OTHERS THEN
V_RETURN_MSG := 'No data found : po_document_types_all - ' || sqlerrm;
V_RETURN_CODE := 'E';
END;
END IF;
IF V_RETURN_CODE = 'S' THEN
mo_global.init('PO');
mo_global.set_policy_context('S', V_ORG_ID);
SELECT I_HEADER_ID /*P_EP_PO_HEADER_ID*/
|| '-' || TO_CHAR(PO_WF_ITEMKEY_S.NEXTVAL)
INTO V_ITEM_KEY
FROM DUAL;
--ORACLE API
BEGIN
--Restart WorkFlow
PO_REQAPPROVAL_INIT1.START_WF_PROCESS(ItemType => V_ITEM_TYPE, --'POAPPRV',
ItemKey => V_ITEM_KEY,
WorkflowProcess => 'POAPPRV_TOP',
ActionOriginatedFrom => 'PO_FORM',
DocumentID => I_HEADER_ID,
DocumentNumber => V_SEGMENT1, -- Purchase Order Number
PreparerID => V_PREPARER_ID, -- Buyer/Preparer_id
DocumentTypeCode => V_DOCUMENT_TYPE_CODE,
DocumentSubtype => V_DOCUMENT_SUBTYPE,
SubmitterAction => 'APPROVE',
forwardToID => NULL,
forwardFromID => NULL,
DefaultApprovalPathID => NULL,
Note => NULL,
PrintFlag => 'N',
FaxFlag => 'N',
FaxNumber => NULL,
EmailFlag => 'N',
EmailAddress => NULL,
CreateSourcingRule => 'N',
ReleaseGenMethod => 'N',
UpdateSourcingRule => 'N',
MassUpdateReleases => 'N',
RetroactivePriceChange => 'N',
OrgAssignChange => 'N',
CommunicatePriceChange => 'N',
p_Background_Flag => 'N', --N:標準API會COMMIT
p_Initiator => NULL,
p_xml_flag => NULL,
FpdsngFlag => 'N',
p_source_type_code => NULL);
--API
PO_REQAPPROVAL_ACTION.APPROVE_DOC(V_ITEM_TYPE,
V_ITEM_KEY,
NULL,
'RUN',
X_RET_MSG); --20120303
END;
IF NVL(V_RETURN_CODE, 'S') <> 'E' THEN
V_RETURN_CODE := 'S';
END IF;
END IF;
FND_FILE.PUT_LINE(FND_FILE.LOG, 'V_RETURN_CODE=' || V_RETURN_CODE);
FND_FILE.PUT_LINE(FND_FILE.LOG, 'V_RETURN_MSG=' || V_RETURN_MSG);
X_RET_CODE := V_RETURN_CODE;
X_RET_MSG := V_RETURN_MSG;
END XX_PO_APPROVE_ACTION;
2012年12月24日 星期一
Oracle DBA - Query locked database objects
SELECT a.username, a.sid, a.objname1,objname2, SYSDATE current_time, TYPE lock_type, LMODE,
A.LOGON_TIME
FROM (SELECT sn.sql_address,
sn.sql_hash_value,
sn.username,
m.sid,
DECODE(m.type,
'TM','TM-DML enqueue',
'TX','TX-Transaction enqueue',
'UL','User supplied') type,
DECODE(m.lmode,
0,'None',
1,'Null(NULL)',
2,'Row Share(SS)',
3,'Row Excl.(SX)',
4,'Share(S)',
5,'S/Row Excl.(SSX)',
6,'Exclusive(X)',
lmode,ltrim(to_char(lmode, '990'))) lmode,
DECODE(m.request,
0,'None',
1,'Null(NULL)',
2,'Row Share(SS)',
3,'Row Excl.(SX)',
4,'Share(S)',
5,'S/Row Excl.(SSX)',
6,'Exclusive(X)',
request,ltrim(to_char(request, '990'))) request,
obj1.owner || '.' || obj1.object_name objname1,
obj2.owner || '.' || obj2.object_name objname2,
SN.LOGON_TIME
FROM v$session sn, V$lock m, dba_objects obj1, dba_objects obj2
WHERE sn.sid = m.sid
AND m.id1 = obj1.object_id(+)
AND m.id2 = obj2.object_id(+)
AND m.lmode != 4) a
WHERE username is not null
and a.objname1 <> '.'
ORDER BY 3, 1;
訂閱:
文章 (Atom)