form submit request with result without open concurrent manager
有時候,需求於畫面結果產出報表時,我們可透過以下方式提交請求,並使用EDITOR_PKG開啟請求的輸出結果
PROCEDURE PRINT_REPORT IS
L_REQUEST_ID NUMBER;
L_BL_RESULT BOOLEAN;
V_LAYOUT BOOLEAN;
X_PHASE VARCHAR2 (100);
X_STATUS VARCHAR2 (100);
X_DEV_PHASE VARCHAR2 (100);
X_DEV_STATUS VARCHAR2 (100);
X_MESSAGE VARCHAR2 (100);
V_APPL_SHORT_NAME VARCHAR2 (30);
V_CC_PROGRAM_NAME VARCHAR2 (30) := 'XXXXXXX';
V_OUTPUT_FORMAT VARCHAR2 (30) := 'PDF';
V_FALSE BOOLEAN;
e_application_error EXCEPTION;
BEGIN
BEGIN
SELECT fa.application_short_name
INTO v_appl_short_name
FROM fnd_concurrent_programs_vl fcpv, fnd_application fa
WHERE 1 = 1 AND fcpv.concurrent_program_Name = v_cc_program_name AND fcpv.application_id = fa.application_id;
EXCEPTION
WHEN OTHERS THEN
RAISE e_application_error;
END;
V_LAYOUT :=
FND_REQUEST.ADD_LAYOUT (V_APPL_SHORT_NAME, --template_appl_name
V_CC_PROGRAM_NAME, --template_code
NULL, --template_language
NULL, --template_terrirtory
V_OUTPUT_FORMAT --output_format
); --return boolean
L_REQUEST_ID :=
FND_REQUEST.SUBMIT_REQUEST (V_APPL_SHORT_NAME, --application
V_CC_PROGRAM_NAME, --program
'', --description
'', --start_Time
FALSE, --sub_request
:MAIN.XX_ID, --argument1
CHR (0), --argument2
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'');
COMMIT;
IF L_REQUEST_ID IS NULL OR L_REQUEST_ID = 0 THEN
RETURN;
END IF;
L_BL_RESULT :=
FND_CONCURRENT.WAIT_FOR_REQUEST (L_REQUEST_ID, --request_id
1, --interval
0, --max_wait
X_PHASE, --OUT phase
X_STATUS, --OUT status
X_DEV_PHASE, --out dev_phase
X_DEV_STATUS, --out dev_status
X_MESSAGE --out message
); --return boolean
IF X_DEV_PHASE = 'COMPLETE' AND X_DEV_STATUS = 'NORMAL' THEN
FND_MESSAGE.SET_STRING ('Request Normal Complete!');
FND_MESSAGE.SHOW;
EDITOR_PKG.REPORT (L_REQUEST_ID, 'Y'); --Show document in browser
ELSE
FND_FILE.PUT_LINE (FND_FILE.LOG, RPAD ('x_phase', 20, ' ') || '=' || X_PHASE);
FND_FILE.PUT_LINE (FND_FILE.LOG, RPAD ('x_status=', 20, ' ') || '=' || X_STATUS);
FND_FILE.PUT_LINE (FND_FILE.LOG, RPAD ('x_dev_phase=', 20, ' ') || '=' || X_DEV_PHASE);
FND_FILE.PUT_LINE (FND_FILE.LOG, RPAD ('x_dev_status=', 20, ' ') || '=' || X_DEV_STATUS);
FND_FILE.PUT_LINE (FND_FILE.LOG, RPAD ('x_message=', 20, ' ') || '=' || X_MESSAGE);
FND_FILE.PUT_LINE (
FND_FILE.LOG,
'Warning - Print report failure('
|| x_dev_phase
|| '/'
|| x_dev_status
|| ') ! Request ID : '
|| TO_CHAR (L_REQUEST_ID)
|| ' contact with system administrator with Request ID.');
fnd_message.set_string ('Request(' || L_request_id || ' with Error!');
fnd_message.error;
RAISE form_trigger_failure;
END IF;
EXCEPTION
WHEN e_application_error THEN
fnd_message.set_string (v_cc_program_name || ' with application error. Please contact system administrator!');
fnd_message.error;
RAISE form_trigger_failure;
WHEN OTHERS THEN
fnd_message.set_string (SQLERRM);
fnd_message.error;
RAISE form_trigger_failure;
END PRINT_REPORT;