1 Reply Latest reply: May 23, 2012 5:05 PM by rkamuni RSS

    "Preview and Print " report extension in Order Management

    user3738775
      Looking for help on how to add extra information to this report.. I did setup the profile to implement the how to implement PrintExtensionObject interface with method getPrintExtensionXMLFragment.... and created the class file and compiled on Java_top. ( Am very new to java)

      -- enabled the logs
      -selected an order in OM and via action button (preview and print)
      --Shows error message "An error occured during the PDF document generation. Please contact your system Administrator."
      --

      As per the fnd logs table (SELECT * FROM fnd_log_messages WHERE message_text LIKE '%PrintAM:writeBusinessDoc%';)

      shows the following ..
      PrintAM:writeBusinessDoc: Checking for Customer Extension Class
      PrintAM:writeBusinessDoc: Custom Extension Class Found
      PrintAM:writeBusinessDoc:Successfully instantiated the Custom Extension Class
      PrintAM:writeBusinessDoc: Retrieving Custom Extension XML failed

      So I am sure that the issue is on the class which I made.. but not sure what is the cause (Again as mentioned I am new to java) and can anyone help me on this..
      ( I did check the PrintAMImpl.java which calls this profile (Custom class) and can see the above message.

      (Oracle PrintAMImp.java related codes are this
      s29 = ((OADBTransaction)getDBTransaction()).getProfile("ONT_PRINT_CUSTOMER_EXTN_OBJECT");
      if(s29 != null || s29 == "")
      {
      if(flag3)
      {
      logfile.writeln("PrintAM:writeBusinessDoc: Custom Extension Class Found", 1);
      logfile.writeln("PrintAM:writeBusinessDoc: Instantiating the Custom extension class", 1);
      }
      if(flag6)
      {
      oadbtransaction.writeDiagnostics(s6, "PrintAM:writeBusinessDoc: Custom Extension Class Found", 1);
      oadbtransaction.writeDiagnostics(s6, "PrintAM:writeBusinessDoc: Instantiating the Custom extension class", 1);
      }
      PrintExtensionObject printextensionobject = (PrintExtensionObject)Class.forName(s29).newInstance();
      if(flag6)
      oadbtransaction.writeDiagnostics(s6, "PrintAM:writeBusinessDoc:Successfully instantiated the Custom Extension Class", 1);
      if(flag3)
      logfile.writeln("PrintAM:writeBusinessDoc: Successfully instantiated the Custom Extension Class", 1);
      byte abyte0[] = printextensionobject.getPrintExtensionXMLFragment(s, s1).toByteArray();
      if(flag6)
      oadbtransaction.writeDiagnostics(s6, "PrintAM:writeBusinessDoc:Getting the data from the user impl class", 1);
      if(flag3)
      logfile.writeln("PrintAM:writeBusinessDoc: Getting the data from the user impl class", 1);
      bytearrayoutputstream.write(abyte0);
      if(flag6)
      oadbtransaction.writeDiagnostics(s6, "PrintAM:writeBusinessDoc:Writing the data to the main xml", 1);
      if(flag3)
      logfile.writeln("PrintAM:writeBusinessDoc: Writing the data to the main xml", 1);
      } else
      {
      if(flag3)
      logfile.writeln("PrintAM:writeBusinessDoc: No Custom Extension Class Found", 1);
      if(flag6)
      oadbtransaction.writeDiagnostics(s6, "PrintAM:writeBusinessDoc: No Custom Extension Class Found", 1);
      }
      }
      catch(Exception exception1)
      {
      if(flag2)
      logfile.writeln((new StringBuilder()).append("PrintAM:writeBusinessDoc: Retrieving Custom Extension XML failed for ").append(s29).append(" with Exception \n").append(exception1.toString()).toString(), 1);
      if(flag6)
      oadbtransaction.writeDiagnostics(s6, "PrintAM:writeBusinessDoc: Retrieving Custom Extension XML failed", 1);


      **********************THIS IS CUSTOM CLASS I WAS TRYING TO DO ********************************(not a java person)
      package oracle.apps.ont.print.server;

      import com.sun.java.util.collections.HashMap;
      import java.io.*;
      import java.sql.SQLException;
      import java.util.Hashtable;
      import java.util.Properties;
      import oracle.apps.fnd.common.AppsContext;
      import oracle.apps.fnd.common.MessageToken;
      import oracle.apps.fnd.common.EnvironmentStore;
      import oracle.apps.fnd.common.VersionInfo;
      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.JavaConcurrentProgram;
      import oracle.apps.fnd.framework.OAException;
      import oracle.apps.fnd.framework.OAFwkConstants;
      import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
      import oracle.apps.fnd.framework.server.OADBTransaction;
      import oracle.apps.fnd.framework.server.OADBTransactionImpl;
      import oracle.apps.fnd.framework.*;
      import oracle.apps.okc.printing.server.ContractTermsXMLGenerator;
      import oracle.apps.okc.util.server.TermsConstants;
      import oracle.apps.okc.util.server.TermsUtil;
      import oracle.apps.ont.print.blanket.server.HeaderVOImpl;
      import oracle.apps.ont.print.blanket.server.HeaderVORowImpl;
      import oracle.apps.ont.print.blanket.server.LinesVOImpl;
      import oracle.apps.ont.print.order.server.EndCustomerVOImpl;
      import oracle.apps.ont.print.server.PrintExtensionObject;
      import oracle.apps.qp.print.blanket.server.ModAtrbsVOImpl;
      import oracle.apps.qp.print.blanket.server.ModHdrVOImpl;
      import oracle.apps.qp.print.blanket.server.ModLinesVOImpl;
      import oracle.apps.qp.print.blanket.server.ModPrBrkVOImpl;
      import oracle.apps.qp.print.blanket.server.PrlAtrbsVOImpl;
      import oracle.apps.qp.print.blanket.server.PrlHdrVOImpl;
      import oracle.apps.qp.print.blanket.server.PrlLinesVOImpl;
      import oracle.apps.qp.print.blanket.server.PrlPrBrkVOImpl;
      import oracle.apps.xdo.XDOException;
      import oracle.apps.xdo.oa.schema.server.Template;
      import oracle.apps.xdo.oa.schema.server.TemplateHelper;
      import oracle.apps.xdo.template.FOProcessor;
      import oracle.apps.xdo.template.RTFProcessor;
      import oracle.jbo.RowIterator;
      import oracle.jbo.RowSet;
      import oracle.jbo.XMLInterface;
      import oracle.jbo.domain.BaseLobDomain;
      import oracle.jbo.domain.BlobDomain;
      import oracle.jbo.domain.Number;
      import oracle.jbo.server.ApplicationModuleImpl;
      import oracle.jbo.server.DBTransaction;
      import oracle.jbo.server.ViewLinkImpl;
      import oracle.jdbc.OracleTypes;
      import oracle.jdbc.driver.OracleCallableStatement;
      import oracle.jdbc.driver.OraclePreparedStatement;
      import oracle.jdbc.driver.OracleResultSet;
      import oracle.jdbc.driver.OracleConnection;
      import oracle.xml.parser.v2.XMLNode;
      import java.lang.*;
      import java.sql.*;

      public class KciSoPrintClass implements PrintExtensionObject
      {
      KciSoPrintClass()
      {
      }
      public ByteArrayOutputStream getPrintExtensionXMLFragment(String s, String s1)
      {
      ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
      String s2 = null;
      String s3 = null;
      String s40 ="KciCustomClass";
      byte abyte0[] = null;
      byte abyte1[] = null;
      OAApplicationModuleImpl a1=new OAApplicationModuleImpl();
      OADBTransaction dbtransaction = (OADBTransaction)a1.getTransaction();
      dbtransaction.writeDiagnostics(s40, "Sujo John"+ s,1);
      try
      {

      //OAApplicationModuleImpl a1=new OAApplicationModuleImpl();
      //OADBTransaction dbtransaction = (OADBTransaction)a1.getTransaction();
      Statement stmt = dbtransaction.createStatement(1);
      System.out.println("Testline1");
      String str = "select attribute7, attribute8 from oe_order_headers_all where header_id = " + s + " and 'O' = " + s1;
      System.out.println("Testline2");
      ResultSet resultset = stmt.executeQuery(str);
      dbtransaction.writeDiagnostics(s40, "nessDoc method"+ s,1);
      dbtransaction.writeDiagnostics(s40, "START:Prinoc method"+ s1,1);
      //OAApplicationModule am = pageContext.getApplicationModule(webBean);
      //OracleConnection conn = (OracleConnection)dbtransaction.getJdbcConnection();
      //OracleConnection conn = (OracleConnection)dbtransaction.getLocalJDBCConnection();
      //Connection conn = (Connection)am.getOADBTransaction();
      //DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
      //Connection conn = new oracle.jdbc.driver.OracleDriver().defaultConnection ();
      //Class.forName("oracle.jdbc.driver.OracleDriver");
      System.out.println("Sujo");
      //Connection conn = DriverManager.getConnection("jdbc:oracle:thin:APPS/APPDEV2@amxddb05.kci.com:1533");
      //System.out.println("Sujo2");
      //String s41 = "select shipping_instructions,attribute8 from OE_ORDER_HEADERS_ALL where header_id = " + s + " and 'O' = " + s1;
      //System.out.println("Sujo3");
      //Statement statement = conn.createStatement();
      //dbtransaction.createStatement();
      //ResultSet resultset = statement.executeQuery(s41);
      if(resultset.next())
      {
      s2 = resultset.getString("attribute7");
      s3 = resultset.getString("attribute8");
      }
      }
      catch(SQLException sqlexception)
      {
      sqlexception.printStackTrace();
      }
      catch (Exception e)
      {
      System.err.println("Got an exception! ");
      System.err.println(e.getMessage());
      }
      try
      {
      //s2 = "abc";
      if(s2 != null)
      {
      abyte0 = s2.getBytes("UTF-8");
      }
      //s3 = "abc1";
      if(s3 != null)
      {
      abyte1 = s3.getBytes("UTF-8");
      }
      bytearrayoutputstream.write("<attribute7>".getBytes("UTF-8"));
      bytearrayoutputstream.write(abyte0);
      bytearrayoutputstream.write("</attribute7>".getBytes("UTF-8"));
      bytearrayoutputstream.write("<Attribute8>".getBytes("UTF-8"));
      bytearrayoutputstream.write(abyte1);
      bytearrayoutputstream.write("</Attribute8>".getBytes("UTF-8"));
      }
      catch(IOException ioexception)
      {
      ioexception.printStackTrace();
      }
      // dbtransaction.writeDiagnostics(s40, "START:PrintAM:writeBusinessDoc method"+ abyte0[0]);
      // dbtransaction.writeDiagnostics(s40, "START:PrintAM:writeBusinessDoc method"+ abyte1);
      return bytearrayoutputstream;
      }
      }

      Any help will be appreciated
        • 1. Re: "Preview and Print " report extension in Order Management
          rkamuni
          There is a custom extension class available for this "Print and Priview" report. You can implement that and return the SQL Query in the class so that it gets executed and adds the custom attribute information at the end of XML file and you can modify the layout to add the information. The extended java class can return "select statement" or XML data. If it returns select statement code executes the query and adds the xml data at the end or returned XML data will be added. Look for Profile "OM: Printed Document Extension Class Name"