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. 解决window.open被拦截问题

    最近在项目中有一个在浏览器中新开一个窗口的需求,如果不需要做任何的判断,只是直接新开窗口的话,用a标签即可. 但是如果需要做一些判断再新开一个窗口的话,就不能使用a标签了.window.open确实可 ...

  2. c++第十六天

    p99~p101: 1.迭代器的指向:容器内的元素或者尾元素的下一位. 2.迭代器与整数相加减返回值为移动了若干位置的迭代器. 3.迭代器间相加减返回值则是类型为 difference_type 的带 ...

  3. Sony/索尼 NW-ZX300A ZX300 无损音乐播放器4.4口

    https://item.taobao.com/item.htm?spm=a1z0d.7625083.1998302264.6.5c5f4e69ELHOcm&id=557859816402 ( ...

  4. 03: shell简单监控脚本

    1.1 监控apache web server #! /bin/bash # apache netstat -anpt | grep 80 &> /dev/null if [ $? -e ...

  5. 05: jQuery

    目录: jQuery参考网站 W3school 1.1 JQuery作用 1.2 jQuery与DOM比较 与 相互转换 1.3 jQuery选择器 1.4 jQuery筛选与过滤 1.5 jQuer ...

  6. hash-补做

    题目 利用除留余数法为下列关键字集合的存储设计hash函数,并画出分别用开放寻址法和拉链法解决冲突得到的空间存储状态(散列因子取0.75) 关键字集合:85,75,57,60,65,(你的8位学号相加 ...

  7. Problem F: 等式

    Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 104  Solved: 22[Submit][Status][Web Board] Descriptio ...

  8. spring boot 使用@ConfigurationProperties

    有时候有这样子的情景,我们想把配置文件的信息,读取并自动封装成实体类,这样子,我们在代码里面使用就轻松方便多了,这时候,我们就可以使用@ConfigurationProperties,它可以把同类的配 ...

  9. Planar Shadow

    Unity上平面阴影的计算与实现 //如何求顶点投影到平面上的点(阴影点) //当平面上取不相等的任意两个点组成一个向量,与平面的法线总是垂直的,向量垂直点乘为0,因此可以通过一个点和一个法线来定义, ...

  10. C# 读取txt文件内容

    if (!System.IO.File.Exists(@"E:\\111.txt")) { Console.Write("没有找到文件!"); } System ...