package oracle.apps.pon.printing.cp;

import java.io.InputStream;
import java.io.FileOutputStream;
import oracle.jbo.domain.BlobDomain;
import oracle.apps.fnd.cp.request.CpContext;
import oracle.apps.fnd.cp.request.LogFile;
import oracle.apps.fnd.cp.request.OutFile;
import oracle.apps.fnd.cp.request.ReqCompletion;
import oracle.apps.fnd.util.ParameterList;
import oracle.apps.fnd.util.NameValueType;
import oracle.apps.fnd.framework.OAApplicationModuleFactory;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.pon.printing.server.SourcingPrintingAMImpl; /**
* This class is a JavaConcurrentProgram to generate a Sourcing Negotiation
* PDF event from the ConcurrentRequest utility rather than from the webpage.
*
* This tool allows sourcing events to be printed before they are published to
* the suppliers so they may be reviewed by the team without the need to create
* multiple revisions to the event before publishing.
*/
public class GenerateNegotiationPdfCp
implements oracle.apps.fnd.cp.request.JavaConcurrentProgram
{
//class level variables
public static String sourcingPrintingAmName =
"oracle.apps.pon.printing.server.SourcingPrintingAM";
private LogFile m_appsLogFile; /**
* Default Constructor, does nothing
*/
public GenerateNegotiationPdfCp()
{
}//End of constructor GenerateNegotiationPdfCp() /**
* Main entry point for the application. This will accept the conext
* and run the tools needed to generate a PDF of a sourcing negotiation
*/
public void runProgram(CpContext cpContext)
{
//Local variables
OutFile out = cpContext.getOutFile();
m_appsLogFile = cpContext.getLogFile();
ReqCompletion lRC = cpContext.getReqCompletion();
BlobDomain pdf = null;
Integer rfxId = null; //Grad the P_SOURCING_EVENT_ID catagory from the Concurrent context
ParameterList list = cpContext.getParameterList();
m_appsLogFile.writeln("Retrieving P_SOURCING_EVENT_ID parameter", LogFile.STATEMENT);
try
{
while(list.hasMoreElements())
{
NameValueType namevaluetype = list.nextParameter();
if(namevaluetype.getName().equalsIgnoreCase("P_SOUCING_EVENT_ID"))
{
String val = namevaluetype.getValue();
if(val != null)
{
rfxId = new Integer(Integer.parseInt(val));
}
}
}
}
catch(Exception ex)
{
m_appsLogFile.writeln("The following error occured while retrieving "
+ "the P_SOURCING_EVENT_ID parameter " + ex.getMessage(), LogFile.ERROR);
lRC.setCompletion(ReqCompletion.ERROR,
"Failed to get P_SOURCING_EVENT_ID parameter");
return;
} //Call getNegotiationPdf(string, string, string, string, Boolean)
m_appsLogFile.writeln("Retrieving PDF file", LogFile.STATEMENT);
try
{
/**
* Get the BlobDomain so we can write it to the output file
*/
SourcingPrintingAMImpl pdflib = (SourcingPrintingAMImpl)getSourcingAppModule(cpContext);
OADBTransaction trans = pdflib.getOADBTransaction();
String clientTimeZone = trans.getProfile("CLIENT_TIMEZONE_ID");
String serverTimeZone = trans.getProfile("SERVER_TIMEZONE_ID");
String dateFormat = trans.getProfile("ICX_DATE_FORMAT_MASK");
pdf = pdflib.getNegotiationPdf(rfxId.toString(), clientTimeZone, serverTimeZone, dateFormat, new Boolean(true));
}
catch(Exception ex)
{
m_appsLogFile.writeln("The following error occured while retrieving the "
+ "PDF from BI Publisher: " + ex.getMessage(), LogFile.ERROR);
lRC.setCompletion(ReqCompletion.ERROR,
"Failed to get PDF from BI Publisher parameter");
return;
} //Write the PDF to the output file 2k at a time
m_appsLogFile.writeln("Writting the PDF to the output file", LogFile.STATEMENT);
try
{
InputStream iStream = pdf.getBinaryStream();
FileOutputStream oStream = new FileOutputStream(out.getFileName(), false);
byte[] buff = new byte[2048];
int count;
while((count = iStream.read(buff)) >= 0)
{
oStream.write(buff, 0, count);
}
iStream.close();
oStream.flush();
oStream.close();
lRC.setCompletion(ReqCompletion.NORMAL, "SUCCESS!");
}
catch(Exception ex)
{
m_appsLogFile.writeln("Failed to write PDF to output file ["
+ out.getFileName()
+ "] with the following error: " + ex.getMessage(), LogFile.ERROR);
lRC.setCompletion(ReqCompletion.ERROR,
"Failed writing to the output file");
return;
} }//End of method runProgram(CpConext) /**
* This method uses the OAApplicationModuleFactory to create an instance of
* an Oracle Application Implimentation Module factory. The current context
* of the ConcurrentRequest program is sent along so the Application Module
* can initialize properly.
*/
protected OAApplicationModuleImpl getSourcingAppModule(CpContext cpcontext)
{
OAApplicationModuleImpl oaapplicationmoduleimpl =
(OAApplicationModuleImpl)
OAApplicationModuleFactory.createRootOAApplicationModule(
cpcontext, sourcingPrintingAmName);
return oaapplicationmoduleimpl;
}//End of getSourcingAppModule(CpContext) }//End of class GenerateNegotiationPdfCp

其中最重要的方法便是在请求中调用AM。

SourcingPrintingAMImpl pdflib = (SourcingPrintingAMImpl)getSourcingAppModule(cpContext);
protected OAApplicationModuleImpl getSourcingAppModule(CpContext cpcontext)
{
OAApplicationModuleImpl oaapplicationmoduleimpl =
(OAApplicationModuleImpl)
OAApplicationModuleFactory.createRootOAApplicationModule(
cpcontext, sourcingPrintingAmName);
return oaapplicationmoduleimpl;
}//End of getSourcingAppModule(CpContext)

参考资料:

Generate PDF in Sourcing through concurrent request

Generate PDF in Sourcing through concurrent request,在EBS java并发中调用指定am的方法的更多相关文章

  1. How To Get Log, Trace Files In OA Framework Pages And Concurrent Request Programs

    Goal   Solution   References APPLIES TO: Oracle Supplier Lifecycle Management - Version 12.1.2 and l ...

  2. (转)How To Kill runaway processes After Terminating Concurrent Request

    终止EBS并发请求后,解锁相关的进程. 还有种方法可以在PLSQL->tools->session 中找到并且kill Every concurrent Request uses some ...

  3. Oracle EBS Concurrent Request:Gather Schema Statistics[Z]

    Oracle EBS 的Concurrent Request"Gather Schema Statistics"是一个和性能相关的Concurrent Program,它会对表,列 ...

  4. Oracle E-Business Suite并发请求的优先级(Concurrent Request Priority)

    不少用户抱怨自己的Oracle E-Business Suite并发请求(Concurrent Request)提交了好久,但还是一直在排队,等了好久还没有执行.用户希望对于一些重要性程度高.响应要求 ...

  5. Concurrent Request:Inactive phase,No Manager status

    Symptom 随便submit一个request,发现几乎所有的Concurrent Manager都为No Manager状态,Phase为Inactive. Solution 一个Concurr ...

  6. django执行mysql恢复的时候出现“The request's session was deleted before the request completed. The user may have logged out in a concurrent request, for example.”

    版本: django:2.1.7 python:3.7 mysql:5.7.25 今天在用django做mysql备份和恢复的时候,备份没问题,恢复时出现如下错误提示: The request's s ...

  7. at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)

    at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333) 原因: null request

  8. 《Java并发编程实战》/童云兰译【PDF】下载

    <Java并发编程实战>/童云兰译[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230062521 内容简介 本书深入浅出地介绍了Jav ...

  9. 学习笔记:java并发编程学习之初识Concurrent

    一.初识Concurrent 第一次看见concurrent的使用是在同事写的一个抽取系统代码里,当时这部分代码没有完成,有许多的问题,另一个同事接手了这部分代码的功能开发,由于他没有多线程开发的经验 ...

随机推荐

  1. python之路----模块与序列化模块

    认识模块 什么是模块 什么是模块? 常见的场景:一个模块就是一个包含了python定义和声明的文件,文件名就是模块名字加上.py的后缀. 但其实import加载的模块分为四个通用类别: 1 使用pyt ...

  2. ACM题目————中位数

    题目描述 长为L的升序序列S,S[L / 2]为其中位数. 给出两个等长升序序列S1和S2,求两序列合并并排序后的中位数. 输入 多组数据,每组第一行为n,表示两个等长升序序列的长度. 接下来n行为升 ...

  3. python的时间处理-time模块

    time模块 时间的表示方法有三种: 时间戳:表示的是从1970年1月1日0点至今的秒数 格式化字符串表示:这种表示更习惯我们通常的读法,如2018-04-24 00:00:00 格式化元祖表示:是一 ...

  4. SNMP学习笔记之Centos7配置SNMP服务

    0x00 安装yum源安装SNMP软件包 1.yum源安装SNMP服务: yum -y install net-snmp net-snmp-utils 2.查看SNMP版本号: snmpd -v 0x ...

  5. C++ Compress Floder

    第三方函数.头文件.测试工程下载地址:http://download.csdn.net/detail/u012958937/8361733

  6. spring与spring-data-redis整合redis

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  7. javaweb 实战_1

    购物车项目 Primary SQL语句 product create table product ( id ) default null, name varchar() default null, p ...

  8. triggerHandler不执行事件默认值

    <input type="text" /> $('input').triggerHandler('focus');

  9. NS-3 MyFirstScriptExample

    安装好了NS-3之后,我根据一些教程学习了NS-3的几个关键的概念,然后照着例子和自己对它的一些理解,尝试的打了我自己的第一个脚本程序:MyFirstScriptExample 具体代码如下: #in ...

  10. Linux——帮助命令简单学习笔记

    Linux帮助命令简单学习笔记: 一: 命令名称:man 命令英文原意:manual 命令所在路径:/usr/bin/man 执行权限:所有用户 语法:man [命令或配置文件] 功能描述:获得帮助信 ...