Email the output of a concurrent program as Attachment
This article illustrates the steps to be followed to Email a concurrent program’s output.
- Write a procedure that will submit the concurrent program whose output has to be sent as an Email and once the program completes, send the output as Email using UTL_MAIL.send_attach_varchar2.
Register this procedure as a concurrent program so that this program can be run from Oracle Applications which will email a concurrent program’s output.
Detailed explanation with sample code:
Write the below procedure which submits the desired concurrent program and waits until it completes and then sends the output of that program to the specified Email address using the utility UTL_MAIL.send_attach_varchar2
CREATE OR REPLACE PROCEDURE apps.erp_send_email
(
errbuf VARCHAR2,
retode NUMBER,
p_concurrent_program_name VARCHAR2,
p_parameter1 NUMBER
)
IS
/*Variable declaration*/
fhandle UTL_FILE.file_type;
vtextout VARCHAR2 (32000);
text VARCHAR2 (32000);
v_request_id NUMBER := NULL;
v_request_status BOOLEAN;
v_phase VARCHAR2 (2000);
v_wait_status VARCHAR2 (2000);
v_dev_phase VARCHAR2 (2000);
v_dev_status VARCHAR2 (2000);
v_message VARCHAR2 (2000);
v_application_id NUMBER;
v_concurrent_program_id NUMBER;
v_conc_prog_short_name VARCHAR2 (100);
v_conc_prog_appl_short_name VARCHAR2 (100);
v_output_file_path VARCHAR2 (200);
BEGIN
fnd_file.put_line (fnd_file.output, '------------------------------------------------------);
fnd_file.put_line (fnd_file.output, 'Conc Prog: ' || p_concurrent_program_name);
fnd_file.put_line (fnd_file.output, 'Parameter 1:' ||p_parameter1);
/* Get Concurrent_program_id of the desired program and application_id */
BEGIN
SELECT concurrent_program_id, application_id
INTO v_concurrent_program_id, v_application_id
FROM fnd_concurrent_programs_tl
WHERE user_concurrent_program_name = p_concurrent_program_name;
fnd_file.put_line (fnd_file.LOG,'Conc Prog ID:' || v_concurrent_program_id);
fnd_file.put_line (fnd_file.LOG, 'Application ID: ' || v_application_id );
/* Get the program's Short name */
SELECT concurrent_program_name
INTO v_conc_prog_short_name
FROM fnd_concurrent_programs
WHERE concurrent_program_id = v_concurrent_program_id;
fnd_file.put_line (fnd_file.LOG,'Conc Prog Short Name: ' || v_conc_prog_short_name);
/* Get the Application Short name */
SELECT application_short_name
INTO v_conc_prog_appl_short_name
FROM fnd_application
WHERE application_id = v_application_id;
fnd_file.put_line (fnd_file.LOG,'Application Short Name:' || v_conc_prog_appl_short_name);
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line (fnd_file.LOG, 'Error: ' || SQLERRM);
END;
/* Calling fnd_request.submit_request to submit the desired the concurrent program*/
v_request_id:=
fnd_request.submit_request(v_conc_prog_appl_short_name,
v_conc_prog_short_name,
NULL, --Description
NULL, --Time to start the program
FALSE, -- sub program
p_parameter1
);
fnd_file.put_line (fnd_file.LOG,'Concurrent Request Submitted Successfully: ' || v_request_id);
COMMIT;
IF v_request_id IS NOT NULL
THEN
/*Calling fnd_concurrent.wait_for_request to wait for the program to complete */
v_request_status:=
fnd_concurrent.wait_for_request
(
request_id => v_request_id,
INTERVAL => 10,
max_wait => 0,
phase => v_phase,
status => v_wait_status,
dev_phase => v_dev_phase,
dev_status => v_dev_status,
MESSAGE => v_message
);
v_dev_phase := NULL;
v_dev_status := NULL;
END IF;
/* Getting the path where output file of the program is created */
SELECT outfile_name
INTO v_output_file_path
FROM fnd_concurrent_requests
WHERE request_id = v_request_id;
/* Open the output file in Read mode */
fhandle := UTL_FILE.fopen ('/opt/oracle/ERPS/common/admin/out/ERPSchools','o' || v_request_id || '.out', 'r');
IF UTL_FILE.is_open (fhandle)
THEN
DBMS_OUTPUT.put_line ('File read open');
ELSE
DBMS_OUTPUT.put_line ('File read not open');
END IF;
/* Get the contents of the file into variable "text"*/
LOOP
BEGIN
UTL_FILE.get_line (fhandle, vtextout);
text := text || vtextout || UTL_TCP.crlf;
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
END LOOP;
UTL_FILE.fclose (fhandle);
/*Calling UTL_MAIL.send_attach_varchar2 to send the output as
Email attachment */
UTL_MAIL.send_attach_varchar2
(
sender => 'prudhvi@erpschools.com',
recipients => 'training@erpschools.com',
subject => 'Testmail',
MESSAGE => 'Hello',
attachment => text,
att_inline => FALSE
);
END;
- Register the above written procedure as a concurrent program
Define Executable:
Define Concurrent program with 2 parameters: Concurrent Program Name and Program short Name.
Assign this concurrent program to the desired responsibility.
For a more detailed explanation on how to register a concurrent program refer to the below article:
http://erpschools.com/articles/concurrent-program-registration-and-add-it-to-request-group
When this registered concurrent program is run, this program in turn submits the desired concurrent program and emails its output as an attachment to the required.
Email the output of a concurrent program as Attachment的更多相关文章
- IGS_学习笔记05_IREP开发Concurrent Program为客户化集合接口(案例)
20150819 Created By BaoXinjian
- How to Create a Java Concurrent Program
In this Document Goal Solution Overview Steps in writing Java Concurrent Program Template ...
- Dependent Parameters in Concurrent Program using Special Value Set
Dependent Parameters in Oracle Applications Requirement: Say there is a concurrent program that lets ...
- [转]oracle EBS 基础100问
from:http://www.cnblogs.com/xiaoL/p/3593691.html http://f.dataguru.cn/thread-51057-1-1.html 1001 OR ...
- [笔记]学习EBS建议有的知识
http://f.dataguru.cn/thread-51057-1-1.html ORACLE EBS学习的其他资源有哪四个? ORACLE OPEN WORLD大会是不是一个市场营销活动? Or ...
- Credit Summaries & Importing External Credit Exposure
In this Document Goal Solution APPLIES TO: Oracle Order Management - Version 11.5.10.2 to 12.1.3 ...
- Output of C++ Program | Set 14
Predict the output of following C++ program. Difficulty Level: Rookie Question 1 1 #include <iost ...
- Output of C++ Program | Set 13
Predict the output of following C++ program. 1 #include<iostream> 2 using namespace std; 3 4 c ...
- 《Oracle Applications DBA 基础》- 9 - Concurrent Processing[Z]
<Oracle Applications DBA 基础>- 9 - Concurrent Processing================================== 参考资料 ...
随机推荐
- hadoop环境搭建编译
安装: JDK1.7+ maven 3.0 or later findbugs 1.3.9 protocolBuffer 2.5.0 cmake 2.6 zlib-devel openssl-deve ...
- ado中dispose和close的区别,摘自网络
Close() and Dispose() are basically the same thing on an ADO.NET connection object for providers shi ...
- 关于HTML,css3自适应屏幕,自适应宽度
设置了在不同分辨率下,显示的css样式: @media screen and (min-width:1080px){ .box{ width: 1080px;}.content{width: 1040 ...
- python_day3学习笔记
set集合 python的set是一个无序不重复元素集,基本功能包括关系测试和消除重复元素. 集合对象还支持并.交.差.对称差等. sets 支持 x in set. len(set).和 for x ...
- 树莓派与windows互传文件
这是 meelo 原创的 玩转树莓派 系列文章 安装WinSCP 登录即可在左右两侧分别显示windows和树莓派中的文件 只需将文件从一侧拖到另一侧即可开始文件的传送
- gulp之压缩css,less转css,浏览器实时刷新【原创】
gulp入门 gulp浏览器实时同步 首先要下载对应的插件包: gulp-less包:cnpm install gulp-less --save-dev gulp-connect包:cnpm inst ...
- JavaSwing 版本的简单扫雷游戏
JavaSwing 版本的简单扫雷游戏 一.扫雷游戏的基本规则 1.扫雷游戏分为初级.中级.高级和自定义四个级别. 单击游戏模式可以选择"初级"."中级".&q ...
- npoi的用法,动态的判断单元格的大小,设置列的宽度
public MemoryStream GridToExcelByNPOI(DataTable dt, string strExcelFileName) { HSSFWorkbook wk = new ...
- vue-music 关于playlist (底部播放列表组件)
建立playlist.vue 组件,在player.vue 组件中引用,点击迷你播放器的播放列表按钮由下至上弹出这个层,所以在player.vue 播放器组件中引用 在playlist.vue 组件中 ...
- summernote图片上传功能保存到服务器指定文件夹+php代码+java方法
1.summernote富文本编辑器 summernote是一款基于bootstrap的富文本编辑器,是一款十分好用的文本编辑器,还附带有图片和文件上传功能. 那么在我们网站中想吧这个图片上传到服务器 ...