關於FND_REQUEST.SUBMIT_REQUEST和 FND_CONCURRENT.WAIT_FOR_REQUEST

longwansheng發表於2008-11-04

關於FND_REQUEST.SUBMIT_REQUEST和 FND_CONCURRENT.WAIT_FOR_REQUEST

===========================================================

作者: slim119(http://slim119.itpub.net)

發表於: 2007.05.16 12:11

分類: Oracle EBS

出處: http://slim119.itpub.net/post/2106/288064

---------------------------------------------------------------

[@more@]

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

l_request_id := FND_REQUEST.SUBMIT_REQUEST(

APPLICATION => 'INV',

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,

DEV_STATUS => L_DEV_STATUS,

MESSAGE => L_MESSAGE

);

END IF;

COMMIT;

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

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是一個等待當前請求執行完畢的程式,可以利用這個等待當前的請求程式執行完畢再執行下面的程式。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/92289/viewspace-1012940/,如需轉載,請註明出處,否則將追究法律責任。

相關文章