CREATE OR REPLACE PACKAGE BODY APPS.xx_create_acct
AS
PROCEDURE submit_request(
errbuf OUT VARCHAR2,
retcode OUT VARCHAR2,
param1 varchar2
param2 varchar2
)
IS
l_senderemail VARCHAR2 (2000) := 'xyz@erp.com';
l_request_id NUMBER;
errmsg VARCHAR2 (1000);
req_id NUMBER;
phase VARCHAR2 (200);
status VARCHAR2 (200);
dphase VARCHAR2 (200);
dstatus VARCHAR2 (200);
MESSAGE VARCHAR2 (200);
wait_stat BOOLEAN;
l_file_name VARCHAR2 (200);
l_file_path VARCHAR2 (2000);
crlf VARCHAR2 (4) := CHR (13) || CHR (10);
v_set_layout_option BOOLEAN;
dir_name varchar2(100);
/* CURSOR req_status
IS
SELECT SUBSTR (outfile_name, 55, 23) filename,
SUBSTR (outfile_name, 1, 64) outfilepath
FROM applsys.fnd_concurrent_requests
WHERE request_id = l_request_id
AND phase_code = 'C'
AND status_code = 'C';*/
directory_path VARCHAR2 (2000);
lv_subject VARCHAR2 (100);
lv_msg VARCHAR2 (700);
lv_msghdr VARCHAR2 (100);
lv_pdf_filename VARCHAR2 (200);
BEGIN
apps.fnd_global.apps_initialize
(user_id => apps.fnd_global.user_id,
resp_id =>apps.fnd_global.resp_id,
resp_appl_id => apps.fnd_global.resp_appl_id
);
l_request_id :=
apps.fnd_request.submit_request
( 'BOM',
'CSTCRACCRCV', --appl short name
NULL,
NULL,
FALSE,
param1,
param2
);
COMMIT;
IF (l_request_id <= 0)
THEN
errmsg := apps.fnd_message.get ();
ELSE
wait_stat :=
apps.fnd_concurrent.wait_for_request (l_request_id,
10,
360,
phase,
status,
dphase,
dstatus,
MESSAGE
);
IF dphase = 'COMPLETE'
THEN
dir_name :='XX_CREATE_ACCT_LOG';
l_file_name := 'l' || l_request_id || '.REQ';
lv_subject := NULL;
lv_msg := NULL;
lv_msghdr := NULL;
lv_pdf_filename := NULL;
lv_subject := 'testing mail :Request for Create Accounting not completed';
lv_msg :=
'Please find attachement here with the Status Of Create Accounting Reciving from cost management'
|| crlf;
lv_msghdr := 'Dear Sir' ;
lv_pdf_filename := l_file_name;
send_mail (l_senderemail,
'abc@erp.com',
lv_subject,
lv_msghdr,
lv_msg,
lv_pdf_filename,
'text/application',
dir_name
);
END IF;
END IF;
END submit_request;
PROCEDURE send_mail (
p_sender IN VARCHAR2,
p_recipient IN VARCHAR2,
p_subject IN VARCHAR2,
p_mailbodyhdr IN VARCHAR2,
p_mailbody IN VARCHAR2,
p_filename IN VARCHAR2,
p_filetype IN VARCHAR2,
dir_name in VARCHAR2
)
AS
v_msg VARCHAR2 (32000);
src_file BFILE;
i INTEGER := 1;
v_raw RAW (500);
v_length INTEGER := 0;
v_buffer_size INTEGER := 57;
v_mailconn UTL_SMTP.connection;
gc_crlf VARCHAR2 (4) := CHR (13)
|| CHR (10);
gc_lf VARCHAR2 (4) := CHR (10);
crlf VARCHAR2 (2) := CHR (13)
|| CHR (10);
gc_mailhost VARCHAR2 (255) := '172.16.11.2';
-- gc_maildomain VARCHAR2 (255) := 'pune.com';
msg VARCHAR2 (32767);
boundary CONSTANT VARCHAR2 (256)
:= '-----7D81B75CCC90D2974F7A1CBD';
first_boundary CONSTANT VARCHAR2 (256)
:= '--' || boundary || UTL_TCP.crlf;
last_boundary CONSTANT VARCHAR2 (256)
:= '--' || boundary || '--' || UTL_TCP.crlf;
-- A MIME type that denotes multi-part email (MIME) messages.
multipart_mime_type CONSTANT VARCHAR2 (256)
:= 'multipart/mixed; boundary="' || boundary || '"';
BEGIN
DBMS_OUTPUT.ENABLE (100000);
--fnd_file.put_line (fnd_file.output, '------------------------------------------------------' );
v_mailconn := UTL_SMTP.open_connection (gc_mailhost, 26);
UTL_SMTP.helo (v_mailconn, gc_mailhost);
UTL_SMTP.mail (v_mailconn, p_sender);
UTL_SMTP.rcpt (v_mailconn, p_recipient);
UTL_SMTP.open_data (v_mailconn);
msg :=
'Date: '
|| TO_CHAR (SYSDATE, 'Dy, DD Mon YYYY hh24:mi:ss')
|| crlf
|| 'From:xyz@erp.com '
-- || p_sender
|| crlf
|| 'Subject: '
|| p_subject
|| crlf
|| 'To: abc@erp.com'
-- || p_recipient
|| crlf
|| 'MIME-Version: 3.1'
|| crlf
|| -- Use MIME mail standard
'Content-Type: multipart/mixed;'
|| crlf
|| ' boundary="-----SECBOUND"'
|| crlf
|| crlf
|| '-------SECBOUND'
|| crlf
|| 'Content-Type: text/plain;'
|| crlf
|| 'Content-Transfer_Encoding: 7bit'
|| crlf
|| crlf
|| p_mailbodyhdr
|| crlf
|| crlf
|| p_mailbody
|| crlf
|| crlf
|| crlf
|| crlf
|| -- Message body
'Regards'
|| crlf
|| 'HR and Payroll Team'
|| crlf
|| crlf
|| ' Note- Please ignore the leave status and number of days.'
|| crlf
|| crlf
|| '-------SECBOUND'
|| crlf
|| 'Content-Type'
|| ': '
|| p_filetype
|| crlf
|| 'Content-Disposition: attachment; filename="'
-- || 'Create Accounting'
-- || '.REQ'
||p_filename -- p_filename
|| '"'
|| crlf
|| 'Content-Transfer-Encoding: base64'
|| crlf
|| crlf;
UTL_SMTP.write_data (v_mailconn, msg);
src_file := BFILENAME (dir_name, p_filename);
DBMS_LOB.fileopen (src_file, DBMS_LOB.file_readonly);
v_length := DBMS_LOB.getlength (src_file);
WHILE i < v_length
LOOP
DBMS_LOB.READ (src_file, v_buffer_size, i, v_raw);
UTL_SMTP.write_raw_data (v_mailconn,
UTL_ENCODE.base64_encode (v_raw)
);
UTL_SMTP.write_data (v_mailconn, UTL_TCP.crlf);
i := i + v_buffer_size;
END LOOP while_loop;
UTL_SMTP.write_data (v_mailconn, last_boundary);
UTL_SMTP.write_data (v_mailconn, UTL_TCP.crlf);
DBMS_LOB.fileclose (src_file);
UTL_SMTP.close_data (v_mailconn);
UTL_SMTP.quit (v_mailconn);
EXCEPTION
WHEN OTHERS
THEN
UTL_SMTP.quit (v_mailconn);
DBMS_OUTPUT.put_line (SQLCODE || SQLERRM);
-- FND_FILE.PUT_LINE (FND_FILE.LOG,'error while fetching values from CO_CODE'|| SQLERRM );
END send_mail;
END xx_create_acct;
AS
PROCEDURE submit_request(
errbuf OUT VARCHAR2,
retcode OUT VARCHAR2,
param1 varchar2
param2 varchar2
)
IS
l_senderemail VARCHAR2 (2000) := 'xyz@erp.com';
l_request_id NUMBER;
errmsg VARCHAR2 (1000);
req_id NUMBER;
phase VARCHAR2 (200);
status VARCHAR2 (200);
dphase VARCHAR2 (200);
dstatus VARCHAR2 (200);
MESSAGE VARCHAR2 (200);
wait_stat BOOLEAN;
l_file_name VARCHAR2 (200);
l_file_path VARCHAR2 (2000);
crlf VARCHAR2 (4) := CHR (13) || CHR (10);
v_set_layout_option BOOLEAN;
dir_name varchar2(100);
/* CURSOR req_status
IS
SELECT SUBSTR (outfile_name, 55, 23) filename,
SUBSTR (outfile_name, 1, 64) outfilepath
FROM applsys.fnd_concurrent_requests
WHERE request_id = l_request_id
AND phase_code = 'C'
AND status_code = 'C';*/
directory_path VARCHAR2 (2000);
lv_subject VARCHAR2 (100);
lv_msg VARCHAR2 (700);
lv_msghdr VARCHAR2 (100);
lv_pdf_filename VARCHAR2 (200);
BEGIN
apps.fnd_global.apps_initialize
(user_id => apps.fnd_global.user_id,
resp_id =>apps.fnd_global.resp_id,
resp_appl_id => apps.fnd_global.resp_appl_id
);
l_request_id :=
apps.fnd_request.submit_request
( 'BOM',
'CSTCRACCRCV', --appl short name
NULL,
NULL,
FALSE,
param1,
param2
);
COMMIT;
IF (l_request_id <= 0)
THEN
errmsg := apps.fnd_message.get ();
ELSE
wait_stat :=
apps.fnd_concurrent.wait_for_request (l_request_id,
10,
360,
phase,
status,
dphase,
dstatus,
MESSAGE
);
IF dphase = 'COMPLETE'
THEN
dir_name :='XX_CREATE_ACCT_LOG';
l_file_name := 'l' || l_request_id || '.REQ';
lv_subject := NULL;
lv_msg := NULL;
lv_msghdr := NULL;
lv_pdf_filename := NULL;
lv_subject := 'testing mail :Request for Create Accounting not completed';
lv_msg :=
'Please find attachement here with the Status Of Create Accounting Reciving from cost management'
|| crlf;
lv_msghdr := 'Dear Sir' ;
lv_pdf_filename := l_file_name;
send_mail (l_senderemail,
'abc@erp.com',
lv_subject,
lv_msghdr,
lv_msg,
lv_pdf_filename,
'text/application',
dir_name
);
END IF;
END IF;
END submit_request;
PROCEDURE send_mail (
p_sender IN VARCHAR2,
p_recipient IN VARCHAR2,
p_subject IN VARCHAR2,
p_mailbodyhdr IN VARCHAR2,
p_mailbody IN VARCHAR2,
p_filename IN VARCHAR2,
p_filetype IN VARCHAR2,
dir_name in VARCHAR2
)
AS
v_msg VARCHAR2 (32000);
src_file BFILE;
i INTEGER := 1;
v_raw RAW (500);
v_length INTEGER := 0;
v_buffer_size INTEGER := 57;
v_mailconn UTL_SMTP.connection;
gc_crlf VARCHAR2 (4) := CHR (13)
|| CHR (10);
gc_lf VARCHAR2 (4) := CHR (10);
crlf VARCHAR2 (2) := CHR (13)
|| CHR (10);
gc_mailhost VARCHAR2 (255) := '172.16.11.2';
-- gc_maildomain VARCHAR2 (255) := 'pune.com';
msg VARCHAR2 (32767);
boundary CONSTANT VARCHAR2 (256)
:= '-----7D81B75CCC90D2974F7A1CBD';
first_boundary CONSTANT VARCHAR2 (256)
:= '--' || boundary || UTL_TCP.crlf;
last_boundary CONSTANT VARCHAR2 (256)
:= '--' || boundary || '--' || UTL_TCP.crlf;
-- A MIME type that denotes multi-part email (MIME) messages.
multipart_mime_type CONSTANT VARCHAR2 (256)
:= 'multipart/mixed; boundary="' || boundary || '"';
BEGIN
DBMS_OUTPUT.ENABLE (100000);
--fnd_file.put_line (fnd_file.output, '------------------------------------------------------' );
v_mailconn := UTL_SMTP.open_connection (gc_mailhost, 26);
UTL_SMTP.helo (v_mailconn, gc_mailhost);
UTL_SMTP.mail (v_mailconn, p_sender);
UTL_SMTP.rcpt (v_mailconn, p_recipient);
UTL_SMTP.open_data (v_mailconn);
msg :=
'Date: '
|| TO_CHAR (SYSDATE, 'Dy, DD Mon YYYY hh24:mi:ss')
|| crlf
|| 'From:xyz@erp.com '
-- || p_sender
|| crlf
|| 'Subject: '
|| p_subject
|| crlf
|| 'To: abc@erp.com'
-- || p_recipient
|| crlf
|| 'MIME-Version: 3.1'
|| crlf
|| -- Use MIME mail standard
'Content-Type: multipart/mixed;'
|| crlf
|| ' boundary="-----SECBOUND"'
|| crlf
|| crlf
|| '-------SECBOUND'
|| crlf
|| 'Content-Type: text/plain;'
|| crlf
|| 'Content-Transfer_Encoding: 7bit'
|| crlf
|| crlf
|| p_mailbodyhdr
|| crlf
|| crlf
|| p_mailbody
|| crlf
|| crlf
|| crlf
|| crlf
|| -- Message body
'Regards'
|| crlf
|| 'HR and Payroll Team'
|| crlf
|| crlf
|| ' Note- Please ignore the leave status and number of days.'
|| crlf
|| crlf
|| '-------SECBOUND'
|| crlf
|| 'Content-Type'
|| ': '
|| p_filetype
|| crlf
|| 'Content-Disposition: attachment; filename="'
-- || 'Create Accounting'
-- || '.REQ'
||p_filename -- p_filename
|| '"'
|| crlf
|| 'Content-Transfer-Encoding: base64'
|| crlf
|| crlf;
UTL_SMTP.write_data (v_mailconn, msg);
src_file := BFILENAME (dir_name, p_filename);
DBMS_LOB.fileopen (src_file, DBMS_LOB.file_readonly);
v_length := DBMS_LOB.getlength (src_file);
WHILE i < v_length
LOOP
DBMS_LOB.READ (src_file, v_buffer_size, i, v_raw);
UTL_SMTP.write_raw_data (v_mailconn,
UTL_ENCODE.base64_encode (v_raw)
);
UTL_SMTP.write_data (v_mailconn, UTL_TCP.crlf);
i := i + v_buffer_size;
END LOOP while_loop;
UTL_SMTP.write_data (v_mailconn, last_boundary);
UTL_SMTP.write_data (v_mailconn, UTL_TCP.crlf);
DBMS_LOB.fileclose (src_file);
UTL_SMTP.close_data (v_mailconn);
UTL_SMTP.quit (v_mailconn);
EXCEPTION
WHEN OTHERS
THEN
UTL_SMTP.quit (v_mailconn);
DBMS_OUTPUT.put_line (SQLCODE || SQLERRM);
-- FND_FILE.PUT_LINE (FND_FILE.LOG,'error while fetching values from CO_CODE'|| SQLERRM );
END send_mail;
END xx_create_acct;
No comments:
Post a Comment