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. Kali连接不上ssh

    1.修改sshd_config文件 vim /etc/ssh/sshd_config 将#PasswordAuthentication yes的注释去掉 将#PermitRootLogin prohi ...

  2. c++性能之map实现性能比较

    http://www.cnblogs.com/zhjh256/p/6346501.html讲述了基本的map操作,在测试的时候,发现map的性能极为低下,与java相比相差了接近200倍.测试的逻辑如 ...

  3. 03: vuejs 事件、模板、过滤器

    目录:Vue其他篇 01: vue.js安装 02: vue.js常用指令 03: vuejs 事件.模板.过滤器 目录: 1.1 事件 1.2 模板 1.3 自定义过滤器 1.4 过度 1.5 支付 ...

  4. 02: 安装epel 解决centos7无法使用yum安装nginx

    参考网址: http://www.mamicode.com/info-detail-1671603.html 1.yum命令安装 yum install epel-release -y 2.更新数据 ...

  5. 20145304 Exp9 Web安全基础实践

    20145304 Exp9 Web安全基础实践 实验后回答问题 (1)SQL注入攻击原理,如何防御 SQL注入是将查询语句当做查询内容输入到查询的框中,以此来使服务器执行攻击者想让它执行的语句,而不是 ...

  6. 20165310 java_blog_week2

    2165310 <Java程序设计>第2周学习总结 教材学习内容总结 了解Java变量 重点学习Boolean变量和类型转换规则 学习数组定义.使用方式 区别: int [] a,b [] ...

  7. 20145208 蔡野 《网络对抗》Exp4 恶意代码分析

    20145208 蔡野 <网络对抗>Exp4 恶意代码分析 问题回答 总结一下监控一个系统通常需要监控什么.用什么来监控. 监控一个系统通常需要监控这个系统的注册表,进程,端口,服务还有文 ...

  8. C#调用非托管dll

    以C#开发周立功CAN举例,在官网下载了周立功的demo 一.C++头文件样子 //接口卡类型定义#define VCI_PCI5121 1 //一些结构体定义 typedef struct tagR ...

  9. extgcd 扩展欧几里得算法模板

    #include <bits/stdc++.h> using namespace std; int extgcd (int a,int b,int &x,int &y){ ...

  10. left join联查提高执行性能

    本文为博主原创,未经允许不得转载: 在项目应用中,很多功能需要多张数据库表联查,甚至跨数据库查询获取数据.sql的执行性能很能影响 服务的体验感,今天就遇到了这样问题,原来的sql是这样的: sele ...