This article illustrates the steps to be followed to Email a concurrent program’s output.

  1. 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.
  2. 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:

  1. 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;

  1. Register the above written procedure as a concurrent program
  • Define Executable:

  • Define Concurrent program with 2 parameters: Concurrent Program Name and Program short Name.

Email the output of a concurrent program as Attachment的更多相关文章

  1. IGS_学习笔记05_IREP开发Concurrent Program为客户化集合接口(案例)

    20150819 Created By BaoXinjian

  2. How to Create a Java Concurrent Program

    In this Document   Goal   Solution   Overview   Steps in writing Java Concurrent Program   Template ...

  3. Dependent Parameters in Concurrent Program using Special Value Set

    Dependent Parameters in Oracle Applications Requirement: Say there is a concurrent program that lets ...

  4. [转]oracle EBS 基础100问

    from:http://www.cnblogs.com/xiaoL/p/3593691.html  http://f.dataguru.cn/thread-51057-1-1.html 1001 OR ...

  5. [笔记]学习EBS建议有的知识

    http://f.dataguru.cn/thread-51057-1-1.html ORACLE EBS学习的其他资源有哪四个? ORACLE OPEN WORLD大会是不是一个市场营销活动? Or ...

  6. 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 ...

  7. Output of C++ Program | Set 14

    Predict the output of following C++ program. Difficulty Level: Rookie Question 1 1 #include <iost ...

  8. Output of C++ Program | Set 13

    Predict the output of following C++ program. 1 #include<iostream> 2 using namespace std; 3 4 c ...

  9. 《Oracle Applications DBA 基础》- 9 - Concurrent Processing[Z]

    <Oracle Applications DBA 基础>- 9 - Concurrent Processing================================== 参考资料 ...

随机推荐

  1. 微信小程序滚动条返回顶部

    scroll-view(可滚动视图区域): 使用竖向滚动时,需要给<scroll-view/>一个固定高度,通过 WXSS 设置 height,将scroll-y属性设置为true,将en ...

  2. C++11——Use auto keyword in C++11

    版权声明:本文系原创,转载请注明来源. Compile your program with: g++ -std=c++ -o target_name filen_ame.cpp or: g++ -st ...

  3. 获取分组后的TOP 1和TOP N记录

    MySQL获取分组后的TOP 1和TOP N记录 有时会碰到一些需求,查询分组后的最大值,最小值所在的整行记录或者分组后的top n行的记录,在一些别的数据库可能有窗口函数可以方面的查出来,但是MyS ...

  4. iOS---弹出提示对话框

    一.就一个选项的对话框 代码块 #pragma mark - 封装弹出对话框方法 // 提示错误信息 - (void)showError:(NSString *)errorMsg { // 1.弹框提 ...

  5. Java中的原子操作类

    转载: <ava并发编程的艺术>第7章 当程序更新一个变量时,如果多线程同时更新这个变量,可能得到期望之外的值,比如变量i=1,A线程更新i+1,B线程也更新i+1,经过两个线程操作之后可 ...

  6. Jmeter----读取excel表中的数据

    Jmeter 读取excel数据使用的方法是使用CSV Data Set Config参数化,之后使用BeanShell Sampler来读取excel表中的数据 第一步.查看所需的接口都要哪些字段和 ...

  7. Java学习笔记(十三一)——Xml 常用知识总结

    [前面的话] 在学习spring框架,发现很多地方都用到了Xml的知识,所以会过头来再学习学习Xml. 本章学习的是Xml的基础,所以基础性文章,选择性阅读. [Xml] 一.Xml初步了解 XML ...

  8. CentOS 6.4 系统上如何安装 tomcat 8

    CentOS 6.4 系统上如何安装 tomcat 8 本文将详细讲解在Linux系统上如何安装tomcat,tomcat是没有32位和64位之分的. 1.下载tomcat 首先我们肯定要先下载tom ...

  9. vmware漏洞之三——Vmware虚拟机逃逸漏洞(CVE-2017-4901)Exploit代码分析与利用

    本文简单分析了代码的结构.有助于理解. 转:http://www.freebuf.com/news/141442.html 0×01 事件分析 2017年7月19 unamer在其github上发布了 ...

  10. Eclipse generate javadoc

    注:若遇到导出文档乱码,则点击上图的[next]按钮,在vm options的输入框输入 -J-Xmx180m        —- 设置内存大小 (若遇到内存溢出时) -encoding utf-8 ...