Cursor C1 is select * from XXX_test;
V_outpath Varchar2(100);
V_header VARCHAR2(500);
V_line VARCHAR2(1000);
V_REQ_ID NUMBER DEFAULT (FND_GLOBAL.CONC_REQUEST_ID);
V_file_name VArchar2(100):='Test_file'||'.csv';
V_outfile UTL_file.file_type;
V_sql_code VARCHAR2(100);
V_err_msg VARCHAR2(100);
V_SUBJECT VARCHAR2 (100)
:= 'TEST_file--->' || TO_CHAR (SYSDATE, 'YYMMDDHHMISS');
V_USER_ID NUMBER DEFAULT (FND_GLOBAL.USER_ID);
V_USERNAME VArchar2(30);
V_EMAIL Varchar2(50);
begin
SELECT USER_NAME, EMAIL_ADDRESS
INTO V_USERNAME, V_EMAIL
FROM FND_USER
WHERE USER_ID = V_USER_ID;
fnd_profile.get('X_test',V_outpath);
V_outfile:= utl_file.fopen(V_outpath,V_file_name,'W');
V_header:='NAME'||','||'ID';
UTL_FILE.put_line(V_outfile,V_header);
for Cur in C1 loop
V_line:=Cur.NAME||','||Cur.id;
UTL_FILE.put_line(V_outfile,V_Line);
end loop;
UTL_FILE.fclose(V_outfile);
IF V_EMAIL IS NULL
THEN
CMG_UTILITY_PCK.WRITE_OUTPUT (
'EMAIL ADDRESS IS NOT SETUP FOR THIS USER. '
|| 'PLEASE CONTACT THE SETUP ADMINISTRATOR');
ELSE
CMG_UTILITY_PCK.WRITE_OUTPUT ('FILE CREATED SUCCESSFULLY');
-- EMAIL THE DETAIL FILE TO EMAIL ADDRESS FOR THIS USER.
CMG_ABC_SUBMIT_PCK.MAIN (V_REQ_ID,
V_OUTPATH || '/' || V_FILE_NAME,
V_FILE_NAME,
V_SUBJECT,
V_EMAIL);
CMG_UTILITY_PCK.WRITE_OUTPUT ('FILE EMAILED SUCCESSFULLY');
END IF;
Exception
When others then
V_sql_code:=SQLcode;
V_err_msg:=SQLERRm;
dbms_output.put_line('Follow the error code and error message'||V_SQL_CODE||','||V_err_msg);
end;
/
-------------------------------------------------------------------------------------------------
PROCEDURE MAIN(p_reqid IN NUMBER,
p_dir IN VARCHAR2,
p_file IN VARCHAR2,
p_subject IN VARCHAR2,
p_email IN VARCHAR2) AS
v_reqid NUMBER;
BEGIN
v_reqid := Fnd_Request.SUBMIT_REQUEST(
'CMGABC',
'CMGABC_EMAIL',
'Send E Mail from Server',
'',
FALSE,
p_dir,
p_file,
p_subject,
p_email
);
COMMIT;
cmg_abc_submit_pck.cmg_wait_req_prc(v_reqid);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;
END cmg_abc_submit_pck;
--------------------------------------------------------------------------------------------
function submit_request (
application IN varchar2 default NULL,
program IN varchar2 default NULL,
description IN varchar2 default NULL,
start_time IN varchar2 default NULL,
sub_request IN boolean default FALSE,
argument1 IN varchar2 default CHR(0),
argument2 IN varchar2 default CHR(0),
argument3 IN varchar2 default CHR(0),
argument4 IN varchar2 default CHR(0),
argument5 IN varchar2 default CHR(0),
argument6 IN varchar2 default CHR(0),
argument7 IN varchar2 default CHR(0),
argument8 IN varchar2 default CHR(0),
argument9 IN varchar2 default CHR(0),
argument10 IN varchar2 default CHR(0),
argument11 IN varchar2 default CHR(0),
argument12 IN varchar2 default CHR(0),
argument13 IN varchar2 default CHR(0),
argument14 IN varchar2 default CHR(0),
argument15 IN varchar2 default CHR(0),
argument16 IN varchar2 default CHR(0),
argument17 IN varchar2 default CHR(0),
argument18 IN varchar2 default CHR(0),
argument19 IN varchar2 default CHR(0),
argument20 IN varchar2 default CHR(0),
argument21 IN varchar2 default CHR(0),
argument22 IN varchar2 default CHR(0),
argument23 IN varchar2 default CHR(0),
argument24 IN varchar2 default CHR(0),
argument25 IN varchar2 default CHR(0),
argument26 IN varchar2 default CHR(0),
argument27 IN varchar2 default CHR(0),
argument28 IN varchar2 default CHR(0),
argument29 IN varchar2 default CHR(0),
argument30 IN varchar2 default CHR(0),
argument31 IN varchar2 default CHR(0),
argument32 IN varchar2 default CHR(0),
argument33 IN varchar2 default CHR(0),
argument34 IN varchar2 default CHR(0),
argument35 IN varchar2 default CHR(0),
argument36 IN varchar2 default CHR(0),
argument37 IN varchar2 default CHR(0),
argument38 IN varchar2 default CHR(0),
argument39 IN varchar2 default CHR(0),
argument40 IN varchar2 default CHR(0),
argument41 IN varchar2 default CHR(0),
argument42 IN varchar2 default CHR(0),
argument43 IN varchar2 default CHR(0),
argument44 IN varchar2 default CHR(0),
argument45 IN varchar2 default CHR(0),
argument46 IN varchar2 default CHR(0),
argument47 IN varchar2 default CHR(0),
argument48 IN varchar2 default CHR(0),
argument49 IN varchar2 default CHR(0),
argument50 IN varchar2 default CHR(0),
argument51 IN varchar2 default CHR(0),
argument52 IN varchar2 default CHR(0),
argument53 IN varchar2 default CHR(0),
argument54 IN varchar2 default CHR(0),
argument55 IN varchar2 default CHR(0),
argument56 IN varchar2 default CHR(0),
argument57 IN varchar2 default CHR(0),
argument58 IN varchar2 default CHR(0),
argument59 IN varchar2 default CHR(0),
argument60 IN varchar2 default CHR(0),
argument61 IN varchar2 default CHR(0),
argument62 IN varchar2 default CHR(0),
argument63 IN varchar2 default CHR(0),
argument64 IN varchar2 default CHR(0),
argument65 IN varchar2 default CHR(0),
argument66 IN varchar2 default CHR(0),
argument67 IN varchar2 default CHR(0),
argument68 IN varchar2 default CHR(0),
argument69 IN varchar2 default CHR(0),
argument70 IN varchar2 default CHR(0),
argument71 IN varchar2 default CHR(0),
argument72 IN varchar2 default CHR(0),
argument73 IN varchar2 default CHR(0),
argument74 IN varchar2 default CHR(0),
argument75 IN varchar2 default CHR(0),
argument76 IN varchar2 default CHR(0),
argument77 IN varchar2 default CHR(0),
argument78 IN varchar2 default CHR(0),
argument79 IN varchar2 default CHR(0),
argument80 IN varchar2 default CHR(0),
argument81 IN varchar2 default CHR(0),
argument82 IN varchar2 default CHR(0),
argument83 IN varchar2 default CHR(0),
argument84 IN varchar2 default CHR(0),
argument85 IN varchar2 default CHR(0),
argument86 IN varchar2 default CHR(0),
argument87 IN varchar2 default CHR(0),
argument88 IN varchar2 default CHR(0),
argument89 IN varchar2 default CHR(0),
argument90 IN varchar2 default CHR(0),
argument91 IN varchar2 default CHR(0),
argument92 IN varchar2 default CHR(0),
argument93 IN varchar2 default CHR(0),
argument94 IN varchar2 default CHR(0),
argument95 IN varchar2 default CHR(0),
argument96 IN varchar2 default CHR(0),
argument97 IN varchar2 default CHR(0),
argument98 IN varchar2 default CHR(0),
argument99 IN varchar2 default CHR(0),
argument100 IN varchar2 default CHR(0))
return number is
reqid number;
begin
-- If not in database trigger mode:
-- Rollback to start_of_submission if submit() function fails to
-- submit the request.
if (not (P_DB_TRIGGER_MODE)) then
savepoint start_of_submission;
end if;
reqid := submit (
application, program, description, start_time, sub_request,
Argument1, Argument2, Argument3, Argument4, Argument5,
Argument6, Argument7, Argument8, Argument9, Argument10,
Argument11, Argument12, Argument13, Argument14, Argument15,
Argument16, Argument17, Argument18, Argument19, Argument20,
Argument21, Argument22, Argument23, Argument24, Argument25,
Argument26, Argument27, Argument28, Argument29, Argument30,
Argument31, Argument32, Argument33, Argument34, Argument35,
Argument36, Argument37, Argument38, Argument39, Argument40,
Argument41, Argument42, Argument43, Argument44, Argument45,
Argument46, Argument47, Argument48, Argument49, Argument50,
Argument51, Argument52, Argument53, Argument54, Argument55,
Argument56, Argument57, Argument58, Argument59, Argument60,
Argument61, Argument62, Argument63, Argument64, Argument65,
Argument66, Argument67, Argument68, Argument69, Argument70,
Argument71, Argument72, Argument73, Argument74, Argument75,
Argument76, Argument77, Argument78, Argument79, Argument80,
Argument81, Argument82, Argument83, Argument84, Argument85,
Argument86, Argument87, Argument88, Argument89, Argument90,
Argument91, Argument92, Argument93, Argument94, Argument95,
Argument96, Argument97, Argument98, Argument99, Argument100);
if (not (P_DB_TRIGGER_MODE)) then
if (reqid = 0) then
rollback to start_of_submission;
end if;
end if;
init_pvt_vars;
return (reqid);
end submit_request;
-------------------------------------------------------------------------------------------------
PROCEDURE cmg_wait_req_prc(p_req_id IN VARCHAR2) AS
CURSOR get_status IS
SELECT status_code
FROM fnd_concurrent_requests
WHERE request_id = p_req_id;
v_call_status BOOLEAN;
v_comp_status BOOLEAN;
v_phase VARCHAR2(100);
v_status VARCHAR2(100);
v_dev_phase VARCHAR2(100);
v_dev_status VARCHAR2(100);
v_message VARCHAR2(100);
v_get_status VARCHAR2(100);
BEGIN
v_call_status := Fnd_Concurrent.WAIT_FOR_REQUEST(
p_req_id,
5,
0,
v_phase,
v_status,
v_dev_phase,
v_dev_status,
v_message);
COMMIT;
--
OPEN get_status;
FETCH get_status INTO v_get_status;
CLOSE get_status;
--
IF v_get_status ='E'THEN
v_comp_status := Fnd_Concurrent.SET_COMPLETION_STATUS('WARNING','');
END IF;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20004,'ERROR WHILE EXECUTING - '||SQLERRM);
END cmg_wait_req_prc;
No comments:
Post a Comment