我创建了一个链接到APEX以关闭PO的程序。当我尝试关闭PO时,我的消息日志表中出现错误消息。错误似乎与初始化有关。
以下是程序
CREATE OR REPLACE PROCEDURE APEX_EBS_EXTENSION.CLOSE_PO (P_FILE_NAME IN
VARCHAR2)
as
x_action constant varchar2(20) := 'CLOSE';
x_calling_mode constant varchar2(2) := 'PO';
x_conc_flag constant varchar2(1) := 'N';
x_return_code_h varchar2(100);
x_auto_close constant varchar2(1) := 'N';
vn_user_id NUMBER ;
vn_resp_id NUMBER :=51058 ;
vn_app_id NUMBER :=201;
x_origin_doc_id number;
x_returned boolean;
--PRAGMA AUTONOMOUS_TRANSACTION;
vr_message_detail MESSAGE_LOG%rowtype ;
vc_message varchar2(4000);
CURSOR c_po_details IS
SELECT XPTS.ORGANISATION_ID, XPTS.PO_HEADER_ID,XPTS.PO_NUMBER, XPTDS.PO_LINE_ID, XPTS.SHIP_ORGANISATION_ID, XPTS.ITEM_ID
,XPTS.DOCUMENT_SUBTYPE, XPTS.DOC_TYPE_CODE, XPTS.TYPE_LOOKUP_CODE,XPTS.ID , XPTS.ITEM_NUMBER,XPTS.USER_ID
FROM xx_po_toclose_stg1 XPTS,
XX_PO_TOCLOSE_DET_STG XPTDS
WHERE XPTS.SEQ = XPTDS.SEQ_NO
AND XPTS.USER_ID = V('APP_USER')
and XPTS.filename = P_FILE_NAME ;
--where po_number = '1000327';
begin
/*
select fnd.user_id ,
fresp.responsibility_id,
fresp.application_id into user_id, resp_id ,resp_appl_id
from fnd_user@BI_APPS fnd , fnd_responsibility_tl@BI_APPS fresp
where fnd.user_name = 'SYSADMIN'
and fresp.responsibility_name = 'System Administrator'
and fresp.language='US' ;
select fnd.user_id ,
fresp.responsibility_id,
fresp.application_id into l_user_id, l_resp_id ,l_resp_appl_id
from fnd_user@BI_APPS fnd , fnd_responsibility_tl@BI_APPS fresp
where fnd.user_name ='APEX_IR_USER'
AND SYSDATE BETWEEN start_date and NVL(end_date,'31-dec-4712');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Exception');
l_user_id := -1;
l_resp_id := -1;
l_resp_appl_id := -1;
fnd_global.apps_initialize@BI_APPS (user_id => -1,
resp_id => 20866,
resp_appl_id => 101);
*/
vc_message := 'CALLING THE USER ID' ;
SELECT FND.USER_ID
INTO vn_user_id
FROM FND_USER@BI_APPS FND
WHERE FND.USER_NAME = 'CLOSEPO_USER' ;
/*
--working
fnd_global.apps_initialize@BI_APPS (user_id => 5930,
resp_id => 50295,
resp_appl_id => 201);
*/
vc_message := 'PASSING PARAMETERS IN THE VARIABLES' ;
fnd_global.apps_initialize@BI_APPS(user_id =>2452 ,
resp_id => 50771,
resp_appl_id => 201);
vc_message := 'LOOPING' ;
for po_head in c_po_details LOOP
--mo_global.init@BI_APPS (po_head.doc_type_code);
--mo_global.set_policy_context@BI_APPS ('S', po_head.org_id_po);
DBMS_OUTPUT.PUT_LINE ('Calling PO_Actions.close_po for Closing/Finally Closing po number =>'|| po_head.PO_NUMBER);
x_returned :=
po_actions.close_po@BI_APPS (
p_docid => po_head.po_header_id,
p_doctyp =>po_head.doc_type_code,
p_docsubtyp =>po_head.document_subtype,
p_lineid => po_head.PO_LINE_ID,
p_shipid => NULL,
p_action => x_action,
p_reason => 'Close Purchase Order On'||SYSDATE,
p_calling_mode => x_calling_mode,
p_conc_flag => x_conc_flag,
p_return_code => x_return_code_h,
p_auto_close => x_auto_close,
p_action_date => SYSDATE,
p_origin_doc_id => NULL);
IF x_returned = TRUE THEN
DBMS_OUTPUT.PUT_LINE ('Item Number which just got Closed/Finally Closed is '||po_head.PO_NUMBER);
commit;
vr_message_detail.message_type := 'E' ;
vc_message := vc_message || ' -SqlCode- ' || sqlcode || ' -SqlErrMsg- ' || sqlerrm ;
vr_message_detail.message_descr_long := vc_message ;
vr_message_detail.message_descr := substr(vc_message, 1, 4000) ;
LOG_MESSAGE(vr_message_detail);
vc_message := 'Updating the Remarks Column in xx_po_toclose_stg1 if success' ;
UPDATE xx_po_toclose_stg1 A
SET A.REMARKS = 'PO Number' ||' '||po_head.PO_NUMBER||' '|| 'with item number '||' '||po_head.ITEM_NUMBER||' ' ||'has been closed by'||' '||po_head.USER_ID||' '||'on'||' '||sysdate
WHERE A.ID = po_head.ID;
COMMIT;
vc_message := 'Updating the STATUS Column in xx_po_toclose_stg1 if success' ;
--UPDATE STATUS ON FINAL TABLE
vc_message := 'Updating the Status Column in xx_po_toclose_stg1 ' ;
UPDATE xx_po_toclose_stg1 A
SET A.STATUS = x_action
WHERE A.ID = po_head.ID;
COMMIT;
ELSE
DBMS_OUTPUT.PUT_LINE ('API Failed to Close/Finally Close line ');
vc_message := 'Updating the Remarks Column in xx_po_toclose_stg1 if failure' ;
UPDATE xx_po_toclose_stg1 A
SET A.REMARKS = 'API Failed to Close/Finally Close the Item number'
WHERE A.ID = po_head.ID;
COMMIT;
vc_message := 'Updating the STATUS Column in xx_po_toclose_stg1 if failure' ;
--UPDATE STATUS ON FINAL TABLE
vc_message := 'Updating the Status Column in xx_po_toclose_stg1 ' ;
UPDATE xx_po_toclose_stg1 A
SET A.STATUS = 'FAILED'
WHERE A.ID = po_head.ID;
END IF;
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
vr_message_detail.message_type := 'E' ;
vc_message := vc_message || ' -SqlCode- ' || sqlcode || ' -SqlErrMsg- ' || sqlerrm ;
vr_message_detail.message_descr_long := vc_message ;
vr_message_detail.message_descr := substr(vc_message, 1, 4000) ;
LOG_MESSAGE(vr_message_detail);
END CLOSE_PO;
/
错误消息是"调用用户ID -SqlCode- 100 -SqlErrMsg-ORA-01403:未找到数据"
以下是应触发此消息的过程部分
vc_message := 'CALLING THE USER ID' ;
SELECT FND.USER_ID
INTO vn_user_id
FROM FND_USER@BI_APPS FND
WHERE FND.USER_NAME = 'CLOSEPO_USER' ;
以下是初始化部分
vc_message := 'PASSING PARAMETERS IN THE VARIABLES' ;
fnd_global.apps_initialize@BI_APPS(user_id =>2452 ,
resp_id => 50771,
resp_appl_id => 201);
我正在为实例上创建的用户(CLOSEPO_USER)使用用户ID。使用的责任ID是PO。
如果有人能指导我解决这个问题,我将感激不尽,以便我可以调试并解决这个问题。
答案 0 :(得分:0)
ORA-01403表示查询不返回任何结果。
在sqlplus或IDE中运行查询(作为Apex应用程序的解析模式):
SELECT FND.USER_ID
FROM FND_USER@BI_APPS FND
WHERE FND.USER_NAME = 'CLOSEPO_USER' ;
它可能不会返回任何行。解决这个问题,你应该没问题。