2010年4月14日 星期三

提交處理事務處理介面請求


--- 提交處理事務處理介面請求
l_request_id := FND_REQUEST.SUBMIT_REQUEST(
APPLICATION => 'INV',
xyz資訊工坊 PROGRAM => 'INCTCM'
);
IF ( l_request_id = 0 ) THEN
RAISE E_SUBMIT_FAILED;
RETURN;
ELSE
COMMIT;
L_REQUEST_FLAG := FND_CONCURRENT.WAIT_FOR_REQUEST(
REQUEST_ID => L_REQUEST_ID,
INTERVAL => 5,
MAX_WAIT => 0,
PHASE => L_PHASE,
STATUS => L_STATUS,
DEV_PHASE => L_DEV_PHASE,
xyz DEV_STATUS => L_DEV_STATUS,
MESSAGE => L_MESSAGE
);
END IF;
COMMIT;
xyz軟體補給站 EXCEPTION
WHEN E_SUBMIT_FAILED THEN
ERRCODE := '1';
ERRMSG := '提交處理事務處理介面請求失敗!'||SUBSTR(SQLERRM,1,100);
FND_FILE.PUT_LINE(FND_FILE.LOG,ERRMSG);
ROLLBACK;
RETURN;
END;
今天關注到這個問題,將找到的資料收集在這裏:
1、關於fnd_request.submit_request的用法
fnd_request.submit_request的用法:
FND_REQUEST.SUBMIT_REQUEST 函數是用來提交一個請求的,它返回一個NUMBER值.具體調用如下
:result := fnd_request.submit_request(application CHAR, --AP模快
program CHAR, --應用程式
description CHAR, --請求說明(可選)
start_time CHAR, --RUN 時間(可選)
sub_request BOOLEAN, --立刻提交請求
argument1 CHAR, --參數1
argument2 CHAR, --參數2
argument3 CHAR, --參數3
argument4 CHAR, --參數4
argument5 CHAR, --參數5.......
argument100 CHAR);
英文說明(zt oracle) :
Parameters are as follows:
application - Short name of the application associated with the concurrent
request to be submitted.
program - Short name of the concurrent program (not the executable) for which
xyz軟體補給站 the request should be submitted.
description - Description of the request that is displayed in the Concurrent
Requests form (Optional.)
start_time - Time at which the request should start running, formatted as HH24:
MI or HH24:MI:SS (Optional.)
sub_request - Set to TRUE if the request is submitted from another request and
should be treated as a sub-request.
argument1...100 - Arguments for the concurrent request; up to 100
arguments are permitted. If submitted from Oracle Forms, you must specify all
100 arguments.
補充說明:
在用fnd_request.submit_request的時候,第五個參數用false,不要被參數名稱誤導;
這個函數有105個參數,前面五個定義請求本身,後面100個是傳遞給請求的具體參數,都是Char類型,
我們需要轉換,預設值是chr(0),代表這個參數不用傳遞給調用的請求;
在Package裏面調用只需要傳遞需要的參數個數,因為它有預設值指示結束;
在form裏面則不行,要寫滿105個,而且我們參數結束之後要用一個chr(0)來表示結束

fnd_request.submit_request('AR',
'SVAINEX_P',
'',
'',
FALSE,
:parameter.invoice_store,
chr(0),
'','','',
'','','','','','','','','','','','','','','','','','','','',
'','','','','','','','','','','','','','','','','','','','',
'','','','','','','','','','','','','','','','','','','','',
'','','','','','','','','','','','','','','','','','','','',
'','','','','','','','','','','','','','','');
2、Oracle Erp等待報表運行機制
主要是用到了Fnd_concurrent.wait_for_ruqest這個function.
Fnd_concurrent.wait_for_request返回Boolean值,主要參數如下:
function FND_CONCURRENT.WAIT_FOR_REQUEST
(request_id IN number default NULL, --請求ID
interval IN number default 60, --檢查時間間隔
max_wait IN number default 0, --最大等待時間
phase OUT varchar2,
status OUT varchar2,
dev_phase OUT varchar2, --請求運行階段
dev_status OUT varchar2, --各個階段狀態
message OUT varchar2 --運行完成後輸出資訊)
return boolean;
dev_phase有Pending,Running,Complete,Inactive等幾種,每種對應不同的Dev-Status,比如Complete階段後就有Normal,Error,Warning,Cancelled,Terminated等幾種狀態。
例如: l_request_status := Fnd_Concurrent.Wait_For_Request(l_request_id,
5,
0,
l_phase,
l_status,
l_dev_phase,
l_dev_status,
l_message);
IF l_request_status THEN
IF l_dev_status = 'NORMAL' THEN
NULL;
ELSE
Fnd_Message.Debug('請求運行不成功:'||l_dev_status);
RETURN;
END IF;
ELSE
Fnd_Message.Debug('請求未完成,無法查看報表內容!');
RETURN;
END IF;
Editor_Pkg.Report(l_request_id,'Y');
總結:FND_REQUEST.SUBMIT_REQUEST是一種通過後臺方式提交請教的方法,可以在pkg和form中使用,在form中使用要將參數寫全。 FND_CONCURRENT.WAIT_FOR_REQUEST是一個等待當前請求運行完畢的程式,可以利用這個等待當前的請求程式運行完畢再運行下面的程式。


 


沒有留言:

張貼留言