Wait for request in Oracle Apps
After submitting a concurrent program, you have to wait for the program to complete. You have to perform certain operations based on the output of the request.
Here is the code to wait for the request:
BEGIN
fnd_file.put_line (fnd_file.output,
'*** Call The XXXX Import Program ***');
fnd_global.apps_initialize (
user_id => fnd_profile.VALUE ('USER_ID'),
resp_id => fnd_profile.VALUE ('RESP_ID'),
resp_appl_id => fnd_profile.VALUE ('RESP_APPL_ID'),
security_group_id => 0);
fnd_file.put_line (fnd_file.LOG, 'Batch ID:' || ln_group_id);
ln_req_id :=
fnd_request.submit_request ('XX', -- Application short name
'XXXX',---Provide the conc prog short name
NULL,
SYSDATE,
FALSE,
'BATCH',
ln_group_id);
COMMIT;
IF ln_req_id = 0
THEN
fnd_file.put_line (
fnd_file.LOG,
'Request Not Submitted due to "' || fnd_message.get || '".');
ELSE
fnd_file.put_line (
fnd_file.LOG,
'The XXXX Import Program submitted - Request id :' || ln_req_id);
END IF;
IF ln_req_id > 0
THEN
LOOP
lv_req_return_status :=
fnd_concurrent.wait_for_request (ln_req_id,
60,
0,
lv_req_phase,
lv_req_status,
lv_req_dev_phase,
lv_req_dev_status,
lv_req_message);
EXIT WHEN UPPER (lv_req_phase) = 'COMPLETED'
OR UPPER (lv_req_status) IN
('CANCELLED', 'ERROR', 'TERMINATED');
END LOOP;
IF UPPER (lv_req_phase) = 'COMPLETED'
AND UPPER (lv_req_status) = 'ERROR'
THEN
fnd_file.put_line (
fnd_file.LOG,
'The XXXX prog completed in error. See log for request id');
fnd_file.put_line (fnd_file.LOG, SQLERRM);
ELSIF UPPER (lv_req_phase) = 'COMPLETED'
AND UPPER (lv_req_status) = 'NORMAL'
THEN
Fnd_File.PUT_LINE (
Fnd_File.LOG,
'The XXXX Import successfully completed for request id: '
|| ln_req_id);
ELSE
Fnd_File.PUT_LINE (
Fnd_File.LOG,
'The XXXX Import request failed.Review log for Oracle request id ');
Fnd_File.PUT_LINE (Fnd_File.LOG, SQLERRM);
END IF;
END IF;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (
fnd_file.LOG,
'OTHERS exception while submitting The XXXX Import Program: '
|| SQLERRM);
END;
============
============
FND_CONCURRENT.GET_REQUEST_STATUS
This API Returns the Status of a concurrent request. It also returns the completion text if the request is already completed. The return type is Boolean (Returns TRUE on successful retrieval of the information, FALSE otherwise).
1
2
3
4
5
6
7
8
| function get_request_status(request_id IN OUT NOCOPY number, appl_shortname IN varchar2 default NULL , program IN varchar2 default NULL , phase OUT NOCOPY varchar2, status OUT NOCOPY varchar2, dev_phase OUT NOCOPY varchar2, dev_status OUT NOCOPY varchar2, message OUT NOCOPY varchar2) return boolean; |
The parameters are:
- REQUEST_ID: Request ID of the program to be checked.
- APPL_SHORTNAME: Short name of the application associated with the program. The default is NULL.
- PROGRAM: Short name of the concurrent program. The default is NULL.
- PHASE: Request phase.
- STATUS: Request status.
- DEV_PHASE: Request phase as a string constant.
- DEV_STATUS: Request status as a string constant.
- MESSAGE: Request completion message.
FND_CONCURRENT.WAIT_FOR_REQUEST
This API waits for the request completion, then returns the request phase/status and completion message to the caller. It goes to sleep between checks for the request completion. The return type is Boolean (Returns TRUE on successful retrieval of the information, FALSE otherwise).
1
2
3
4
5
6
7
8
| function wait_for_request(request_id IN number default NULL , interval IN number default 60, max_wait IN number default 0, phase OUT NOCOPY varchar2, status OUT NOCOPY varchar2, dev_phase OUT NOCOPY varchar2, dev_status OUT NOCOPY varchar2, message OUT NOCOPY varchar2) return boolean; |
The parameters are:
- REQUEST_ID: Request ID of the request to wait on. The default is NULL.
- INTERVAL: Number of seconds to wait between checks. The default is 60 seconds.
- MAX_WAIT: Maximum number of seconds to wait for the request completion. The default is 00 seconds.
- PHASE: User-friendly Request phase.
- STATUS: User-friendly Request status.
- DEV_PHASE: Request phase as a constant string.
- DEV_STATUS: Request status as a constant string.
- MESSAGE: Request completion message.
There are few other useful apis too.
- FND_CONCURRENT.SET_COMPLETION_STATUS: Called from a concurrent request to set its completion status and message.
- FND_CONCURRENT.GET_REQUEST_PRINT_OPTIONS: Returns the print options for a concurrent request.
- FND_CONCURRENT.GET_SUB_REQUESTS: Get all sub-requests for a given request id. For each sub-request it provides request_id, phase,status, developer phase , developer status and completion text.
- FND_CONCURRENT.Cancel_Request: It cancels a given Concurrent Request.
No comments:
Post a Comment