Tuesday, July 5, 2016

Integrating XML Publisher and OAF To get Output In PDF file

To generate the output in PDF formats we need the following:

1 Design the OAF BC4J Object.
2) Design the OAF Page and generate the Data XML
3) Design the RTF Template using Data XML
4) Register the Template with Oracle Applications.
5) Integrating the OAF page With XML Publisher.
6) Invoking the report from OAF

Expected Error:-
if TemplateHelper gives error then we need to TemplateHelper class file in "xdo" folder in apps folder in class.



//In AMImpl.java

    public XMLNode  getPrintDataXML()

    {
    
       

     try

     {

       ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

              // Below Created Object For VO
          OAViewObject vo = getPodetailVO(); 
          
          //Below Code To print xml code in jdevloper

       ((XMLNode) vo.writeXML(4, XMLInterface.XML_OPT_ALL_ROWS)).print(outputStream);

       System.out.println(outputStream.toString());
       
       // below to return xml code for this method.
       
          XMLNode xmlNode = (XMLNode) vo.writeXML(4, XMLInterface.XML_OPT_ALL_ROWS);
          return xmlNode;

      }

     catch(Exception e)

     {

      throw new OAException (e.getMessage());

     }


    } 


// In Controller 

              if(pageContext.getParameter("Print") != null)
              {
              
              
              // Get the HttpServletResponse object from the PageContext. The report output is written to HttpServletResponse.
              DataObject sessionDictionary = (DataObject)pageContext.getNamedDataObject("_SessionParameters");
              HttpServletResponse response = (HttpServletResponse)sessionDictionary.selectValue(null,"HttpServletResponse");
              
              
              try {
              
              ServletOutputStream os = response.getOutputStream();

              // Set the Output Report File Name and Content Type
              String contentDisposition = "attachment;filename=krishna.pdf";
              response.setHeader("Content-Disposition",contentDisposition);
              response.setContentType("application/pdf");
              

              // Get the Data XML File as the XMLNode

              XMLNode xmlNode = (XMLNode) am.invokeMethod("getPrintDataXML");


              ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
              xmlNode.print(outputStream);
              ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
              ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();
              

              //Generate the PDF Report.
              TemplateHelper.processTemplate(
              ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
              "FND",// Application Short Name
              "PO_Search_OAF", // Data Template Short Name
              ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
              ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
              inputStream,TemplateHelper.OUTPUT_TYPE_PDF,null,pdfFile);
              

              // Write the PDF Report to the HttpServletResponse object and flush.
              byte[] b = pdfFile.toByteArray();
              response.setContentLength(b.length);
              os.write(b, 0, b.length);
              os.flush();
              os.close();
              
              
              }
              catch(Exception e)
              {
              response.setContentType("text/html");
              throw new OAException(e.getMessage(), OAException.ERROR);
              } 
              pageContext.setDocumentRendered(true);


              }

Monday, July 4, 2016

How To Call PL/SQL Procedures and Functions In OAF


Create Method In AM Java Code:-

  
 public String AddNumber(String item1,String item2)
        {
       
            OADBTransaction oadbtransaction = (OADBTransaction)getTransaction();
                  OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)getTransaction();
                 String retValues;
               
        // Below I hava created Strring to Call Pl/sql procedure in Begin and end block        
        String str = "Begin proc_in_oaf.addition(:1,:2,:3); End;";

        OracleCallableStatement oraclecallablestatement =
                  (OracleCallableStatement)oadbtransaction.createCallableStatement(str.toString(), 1);
               
                 try{
                  oraclecallablestatement.setFloat(1,  Float.parseFloat(item1)  );
                  oraclecallablestatement.setFloat(2,  Float.parseFloat(item2) );
                  oraclecallablestatement.registerOutParameter(3,Types.VARCHAR);
                  oraclecallablestatement.execute();
                                 
                  retValues = oraclecallablestatement.getString(3);
                 }
                 catch(Exception e)
                 {
                  throw OAException.wrapperException(e);
                 }
               
               
               
                 return retValues;
               
        }


Call Method In Controller:-


//CalculationAMImpl it is AM name


 CalculationAMImpl am1 = (CalculationAMImpl)pageContext.getApplicationModule(webBean);


    OAMessageTextInputBean xx = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("item2");
   
    OAMessageTextInputBean xx1 = (OAMessageTextInputBean)webBean.findChildRecursive("item7");
   
          Serializable[] parameters1 = { (Serializable)xx.getValue(pageContext), (Serializable)xx1.getValue(pageContext) };

//here I have Called That Method
   
    String no = (String)am1.invokeMethod("AddNumber",parameters1);

Steps to implement Subtab Region in OAF

Steps to implement Subtab Region in OAF :
Assuming ApplicationShortName = XXCUS
1.    Create a Page XXCUSSubtabPG
2.    From Page layout Region , create a new region , set region style as subTabLayout .
3.    In property Pallette under Visual , Initial Subtab = {mention the value : 0 if you want to show the 1st tab as default , 1 if you want to show the 2nd tab as default}
4.    Right Click SubTabRN and create as many regions as you want the tabs to be displayed
5.    Right click on SubTabRN and Click on Subtabs it defaults subTabBar under subTablayoutComponents
6.    Create links as many regions that you created
7.    Set destination URI property for links as                                                                                                          OA.jsp?page=/myCompany/oracle/apps/xxcus/Subname/webui/XXCUSSubtabPG&retain AM='Y'"+"&"+OASubTabLayoutBean.OA_SELECTED_SUBTAB_IDX+"="+6.
8.    Set the Visual Prompt Value for the links.
Subname is optional 


Note : No . of links under SubtabLayout = Number of Regions under SubTabRN


Used Below Code While Creating Subtab Region Page:-


OA.jsp?page=/Krishna/oracle/apps/ak/xxtr/Cal/webui/CalcPG&retainAM=Y&addBreadCrumb=Y"+"&" +OASubTabLayoutBean.OA_SELECTED_SUBTAB_IDX + "=" + 0





Tuesday, June 14, 2016

Basic Code

OAApplicationModule am = pageContext.getApplicationModule(webBean);

Friday, January 15, 2016

Registration of OAF Page in Apps



Run below script to import oa framework page:-

Run the below command from the path.

$JAVA_TOP/xx/oracle/apps/po/searchPRJ/webui



java oracle.jrad.tools.xml.importer.XMLImporter $JAVA_TOP/oareport/oracle/apps/ak/webui/XMLIntegrationPG.xml -username APPS -password apps -dbconnection " (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp) (HOST=192.168.1.200)(PORT=1521)) (CONNECT_DATA= (SID=vis) ) )" -rootdir $JAVA_TOP


Run below script to see imported xml page in toad:-


BEGIN
jdr_utils.printDocument('/xx/oracle/apps/ak/ajml/server/common/MainPG');
END;


Run Below Commands On putty:-


cd $INST_TOP/admin/scripts
./adapcctl.sh stop
./adapcctl.sh start
./adoacorectl.sh stop
./adoacorectl.sh start


If You are migrating the objects from R12.1.3 to R12.2.4 You Will  face the below error.

Exception Details.
oracle.apps.fnd.framework.OAException: Could not load application module
'xxmsc.oracle.apps.wsm.TLS.server.AssemblyLotAM'.

The solution for this is, we need to follow below steps. In R12.2.4 the weblogic server was introduced. We need to create the custom jar files and it must be made available for WebLogic to pick it up.

Steps
=====

Go to the custom path(Java Top) where class file is present

run adcgnjar

Bounce the oacore

cd $ADMIN_SCRIPTS_HOME

./admanagedsrvctl.sh stop oacore_server1

./admanagedsrvctl.sh start oacore_server1

Bounce the apache

./adapcctl.sh stop


./adapcctl.sh start

create form function like below.
Field
Value
Function
XX_EMPLOYEE_DETAILS_PAGE
User Function Name
XX_EMPLOYEE_DETAILS_PAGE https://lh5.googleusercontent.com/C1OqM5YfpbRImT2HBDckQaXqucq1fYYQusW6w55sF3c8n1Zc-Et-uZI1OXQVUGQf0FUuYQPhyxgNoeX9u5pjYyxYTMbxy4GUfh8Hz_u9QvPh3jztgAY
Type
SSWA jsp function
HTML Call
OA.jsp?page=/oareport/oracle/apps/ak/webui/XMLIntegrationPG https://lh5.googleusercontent.com/C1OqM5YfpbRImT2HBDckQaXqucq1fYYQusW6w55sF3c8n1Zc-Et-uZI1OXQVUGQf0FUuYQPhyxgNoeX9u5pjYyxYTMbxy4GUfh8Hz_u9QvPh3jztgAY



 

Then Attach  function  menu.