Anil's Blog is Best Viewed on GOOGLE CHROME

Wednesday, January 22, 2020

Import Database Connections into Oracle SQL Developer


These screenshot are from JDevelopers - 12c

1. Click on Window - Resources



2. In the Resources pallet - Click on Import to open the 'Import Catalogs and Connections' window.




3. Now browse to locate the *.rcx file containing connection details.





4. Then click on Import to import the connections.


Wednesday, December 4, 2019

SOA 12C Instance Auto Recovery



Instance Auto recovery is the functionality to recover the failed instances with in a stipulated time period. The Instances which are faulted and marked to be recovered can be recovered in a particular time.

At sometime it's a disadvantage if your instances are falling which might lead increase table spaces issue in soa-infra.

To overcome this, we need to change the recoveryConfig property as mentioned below:

STEPS

Login to Enterprise Manager and Go to SOA Administrator - BPEL Properties.


2. Click on 'More BPEL Configuration Properties'


3. Under RecoveryConfig --> RecurringScheduleConfig.

Update the MaxMessageRaiseSize to 0.


Friday, September 13, 2019

Deployment over different environments


Use ORAMDS for all XSD / WSDL files on the project (oramds:...) in all composite.xml and wrappers in location tag. Doing that you will guarantee that you can deploy anywhere even when you don't have remote access to a environment. 

Also, in this way it is not necessary to change endpoints in composite.xml during compilation time (by script for instance) then use configuration plans.

Cheers!!

BPEL Transaction and Delivery Policies

BackgroundTransaction context between different BPEL services are controlled by mainly two properties/attributes.  Those are Delivery and Transaction attributes.  

Details
Case 1 : If BPEL Process is Async or one-way process then, Delivery policy attribute can have three values. Those are 1)- async.persit  2)- async.cache 3)- sync

meaning:
- async.persit: Delivery messages are persisted in the database in table dlv_message. With this setting, reliability is obtained with some performance impact on the database. When the client initiates a process instance, an invocation request is placed in an internal queue. Inside Oracle BPEL Server, a message-driven bean (MDB), WorkerBean, monitors the queue for invocation requests. When a message is dequeued, Oracle BPEL Server allocates a thread to process the message.

   
    required
   
              many="false">async.persist


- async.cache : Incoming delivery messages are kept only in the in-memory cache. If performance is preferred over reliability, this setting should be considered. Message are not dehydrated into dlv_message table. Rest all is same as async.persist.

   
    required
   
              many="false">async.cache


- sync : Directs Oracle BPEL Server to bypass the scheduling of messages in the invoke queue, and invokes the BPEL instance synchronously. In some cases this setting can improve database performance. So there is no role of invoke queue and worker bean here.


   
    required
   
              many="false">sync


Case 2: If BPEL Process is Sync process then, transaction context between client and bpel-process is controlled by "Transaction" Attribute. Values of these attributes are 1)- Required 2)- Requires New

meaning:
- Required : This makes the BPEL process execute as part of the calling transaction. If no calling transaction exists, it will create a new one.

bpel.config.transaction property is set to requiresNew:
   
    many="false" type="xs:string">required

- RequiresNew : This is the default value and makes the BPEL process execute as a separate transaction. Any existing transaction will be suspended.

bpel.config.transaction property is set to requiresNew:
     
     many="false" type="xs:string">requiresNew


Wednesday, August 21, 2019

SOA Composite Sensors : Good Practice

In this article we will see how to stop a running SOA composite process. It is normal to stop from Enterprise Manager (http: // {hostname}: {port number} / em), but I thought this was not "user friendly". 

How can I use the API to identify the SOA composite instance ID? It is easiest to incorporate a composite sensor into the SCA composite. With a composite sensor, you can easily retrieve business data from a composite. You can query the composite with the data from this sensor. 

For example, you might want to create a composite sensor that outputs a primary key (such as orderId) for the composite you created. If you need to manipulate or query the composite, you can easily identify the instance ID using the sensor ID. 

For how to create a composite sensor ID, refer to the following document. 

https://docs.oracle.com/cd/E23943_01/dev.1111/e10224/sca_compsensors.htm#SOASE20703

Thanks,
Anil

SOA - Change Logging Level for SOA 11g

This content has already been introduced in many entries, but I will keep it personally as many people still ask me.
  1. Log in to Enterprise Manager Fusion Middleware Control.
    http: // {host name or IP}: {port number} / em
  2. Open the SOA folder, right click on the soa_infra (soa_server1) folder and select Log> Log Customization.

  3. Change the log level of the component you want to monitor. If necessary, you can change the log level of the parent package. If you set the parent log level to FINEST, a large amount of logs will be output, so it is not recommended.
  4. A confirmation message will appear asking whether to apply the change. Set it to Yes before reflecting the change.
          Cheers!!

OSB - Using JSON with Oracle Service Bus REST Services

Two new Oracle Service Bus samples have been registered on the Oracle Technology Network site. The first sample project is osb-205-SimpleREST. This demonstrates how to fully implement a REST service in OSB. “Complete” means that the following HTTP methods are implemented using OSB.
  • GET
  • POST
  • PUT
  • DELETE
  • HEAD
  • OPTIONS
Another REST sample is now over. This is an osb-206-JSONREST project, which is an implementation sample for making OSB respond to JSON messages. JSON (JavaScript Object Notation) is often used in web browsers. Passing XML to a javascript client is not the only communication method. JSON is a popular method for exchanging data, especially for web developers. The reason for this is that JSON objects are easy to handle for javascript, but more infrastructure on the client side is needed to handle XML responses. 
For reasons of JSON characteristics, the osb-206-JSONREST sample targets HTTP methods GET and POST (both can be executed from a web browser). If you move a little, you can create a robust REST service for production environments and process XML and JSON payloads according to the HTTP Header Content-type. All OSB samples are uploaded to the SOA Suite sample site. The URL is as follows. Click the OSB section on the left side of the 

Official Oracle SOA Suite Samples 
https://www.oracle.com/downloads/samplecode/service-bus-downloads.html

page to see OSB samples. The site also provides samples of other components of the SOA Suite, so it's worth a look. 

SOA - DB Adapter performance issue having 1-N Relations Table


I faced the problem that it took a long time to execute select in DB Adapter. There were three tables that contained a large amount of data and contained many columns, and these tables were being handled by the DB Adapter.

The database side configured a primary key / foreign key relationship between the tables and recreated the DB Adapter, but the same problem occurred. The problem occurs when the user edits the SQL on the Define Selection Criteria page of the DB Adapter. Here are some ways to work around this problem:

Open -or-mappings.xml file
Find true </ batch-reading> and change true to false

Open the DB Adapter wizard again, go to the Define Selection Conditions page, and define the where clause.  Check the Return a single result set for both master and detail tables using outer join checkbox. This recreates the SQL.

Change the where clause of this new SQL statement. Be careful not to change before the From clause.

Click Finish to deploy the project.

Test the application.

For TopLink batch attribute reading (default is true),  if this is true and you edit "Selection Condition Definition" in the DB Adapter Wizard, you may scan the entire table with a one-to-many relationship .
To avoid this, batch loading was set to false.

Cheers!!

Friday, March 4, 2016

Controller Extension in R12.2.x

Deploying Customizations in Oracle E-Business Suite Release 12.2

This article describes how to deploy customizations in an Oracle E-Business Suite Release 12.2 environment.

A little bit background before we move onto the exact steps required to move the customization.

An Oracle E-Business Suite Release 12.2 installation now includes two editions (versions) of the application code and seed data.

The "Run Edition" is the code and data used by the running application. As a developer, you will connect to the Run Edition whenever you are engaged in normal development activity on the system.

The "Patch Edition" is an alternate copy of Oracle E-Business Suite code and seed data that is updated by Online Patching. End users cannot access the Oracle E-Business Suite Patch Edition, but as a developer you may need to connect to the Patch Edition of a system when applying patches or debugging problems with Online Patch execution.

The Oracle E-Business Suite application-tier files are installed in a base directory of the customer's choosing. Within that base directory you will now find three important sub-directories:

fs1 - file system 1 (either run or patch edition)
fs2 - file system 2 (alternate of file system 1)
fs_ne - non-editioned file system, for data files

The fs1 and fs2 directories contain the Run Edition and Patch Edition files for Oracle E-Business Suite. The "run" and "patch" file system designation will switch back and forth between fs1 and fs2 for each patching cycle.

Connecting to the Run Edition

Oracle E-Business Suite Release 12.2.2 and higher includes a script to set the run or patch edition environment by edition type. The script is called "EBSapps.env" and is found in the base directory of an Oracle E-Business Suite application-tier installation.

Login to Putty:-

1. Connect to the run edition file system on your development environment. Run EBSapps.env to find the run instance.

$ source /u01/R122_EBS/EBSapps.env run

E-Business Suite Environment Information
----------------------------------------
RUN File System : /u01/R122_EBS/fs2/EBSapps/appl
PATCH File System : /u01/R122_EBS/fs1/EBSapps/appl
Non-Editioned File System : /u01/R122_EBS/fs_ne
DB Host: slc04axp.us.oracle.com Service/SID: gbzd122x

 Here you can see that FS2 is the RUN instance so we have to move our Controller/View Object/Any Java/Xml file to FS2.

cd /u01/R122_EBS/fs2/EBSapps/appl
cd $JAVA_TOP/xx_top/oracle/apps/fnd/framework/webui/

As an instance I am moving xxEmpCo (Controller) file to above path. Once files is moved you can run JAVAC to compile the JAVA file.

2. After you copy any custom files under the $JAVA_TOP directory, run the adcgnjar utility.
The adcgnjar utility does not require any parameters on the command line. When prompted, enter the user name and password of the APPS user.

3.Stop & Start managed servers using using the command. When prompted enter the weblogic password.

$ $ADMIN_SCRIPTS_HOME admanagedsrvctl.sh stop oacore_server1
$ $ADMIN_SCRIPTS_HOME admanagedsrvctl.sh start oacore_server1


Note : If for any reason you have modified seeded .JSP/XML/JAVA file the we need to run "Generate product JAR files" from adadmin which will regenerate product jar files for Oracle applications.

We use the adcgnjar utility for any custom Java or BC4J code for Oracle Application Framework, Oracle CRM Technology Foundation (JTT), Oracle Web Applications Desktop Integrator (BNE), custom servlets, or other custom Java code. This utility generates and signs a file named customall.jar file containing the custom Java and BC4J code and extensions.

Thanks,
Anil

Dynamic View Object through Personalization | R12.2 New Feature

               Create View Object through Personalization

This post will help you to understand on how we can create a view object with the help of OAF personalization.

1. Set 'Personalize Self-Service Defn' & 'FND: Personalization Region Link Enabled' Profile options so that you can get the personalization link.

2. In R12.2 we get the personalize link through the Setting icon as seen below.


3. Then navigate to any oaf page and click on 'Personalize Page' and then click on 'Model Personalization'




 4. Click on create button to create a Dynamic View Object. We can only create a dynamic read-only view instance that encapsulates a database query, to the root application module of the current OA Framework-based page.

Once you create a new dynamic view instance, you can also enable, disable, or delete the view instance, or delete the model personalization from the root application module.


5. Now specify a name for the view instance and enter the SQL query for the view instance.



 6. Select Apply to save the changes.


 7.  Then I have created a Advance Table and three columns through personalization only to see the data which I have defined in above view object. Columns are - User Name,



 8.  Now as per below screenshots you can see that a view only table region get added to existing OAF page and also it is showing the data.





Thanks,
--Anil

Sunday, January 11, 2015

Integrate XML Publisher Report with OAF


In this example we are going to integrate a simple XML publisher report with OAF. The business scenario is something like that we have a OAF page and on click of "Print" button we want to call a XML publisher report.

Steps
1. Create a OAF page with table region and print button to call a XML publisher report.


2. Designed XML report template. here I have not mentioned steps to register the XML report in Oracle apps.



Controller Code
Here we are handling the print button action and calling the XML report.
    public void processFormRequest(OAPageContext pageContext, 
                                   OAWebBean webBean) {
        super.processFormRequest(pageContext, webBean);
        if (pageContext.getParameter("Print") != null) {

            System.out.println("Print Button clicked");

            printReport(pageContext, webBean, "pdf");

        }

    public void printReport(OAPageContext pageContext, OAWebBean webBean, 
                            String outputType) {

        OAApplicationModule lo_am = pageContext.getApplicationModule(webBean);
        
        String ls_extensionType = "pdf"; //Setting the output extension type
        byte l_outputType = 0;
        l_outputType = TemplateHelper.OUTPUT_TYPE_PDF;


        DataObject lo_sessionDictionary = 
            pageContext.getNamedDataObject("_SessionParameters");
        HttpServletResponse lo_response = 
            (HttpServletResponse)lo_sessionDictionary.selectValue(null, 
                                                                  "HttpServletResponse");
        try {
            ServletOutputStream lo_outputStream = 
                lo_response.getOutputStream();

            // setting the report name & output type
            String lo_contentDisposition = 
                "attachment;filename=OrderDetails." + ls_extensionType;
            lo_response.setHeader("Content-Disposition", 
                                  lo_contentDisposition);
            lo_response.setContentType("application/pdf");

            System.out.println("Calling XML generation method");

            XMLNode xmlNode = 
                (XMLNode)lo_am.invokeMethod("getOrderReportDetailsXML");
            // Calling getOrderReportDetailsXML method to get the XML for the VO query

            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

            xmlNode.print(outputStream);
            System.out.println("After calling XML generation method" + 
                               outputStream.toString());
            //Above sop will return the XML output which will help you in designing the template.
 
            ByteArrayInputStream lo_inputStream = 
                new ByteArrayInputStream(outputStream.toByteArray());
            ByteArrayOutputStream lo_outputFile = new ByteArrayOutputStream();
            
            // Pass the Template code and Application short name
            try {
                TemplateHelper.processTemplate(((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(), 
                                               "PA", "XX_ORDER_DT", 
                                               ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(), 
                                               ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(), 
                                               lo_inputStream, l_outputType, 
                                               null, lo_outputFile);

            } catch (XDOException xe) {
                throw new OAException("Exception:" + xe.getMessage());

            }

            byte[] l_bytes = lo_outputFile.toByteArray();

            lo_response.setContentLength(l_bytes.length);
            lo_outputStream.write(l_bytes, 0, l_bytes.length);
            lo_outputStream.flush();
            lo_outputStream.close();
        } catch (Exception e) {
            lo_response.setContentType("text/html");
            throw new OAException(e.getMessage(), OAException.ERROR);
        }
        pageContext.setDocumentRendered(false);

    }

Application Module Code

 This method will return the XML output of the VO query attached to the page.

   public XMLNode getOrderReportDetailsXML() {
        //XMLNode lo_xmlNode;
       System.out.println("Inside the AM Method");
        OrderReportDetailsVOImpl vo = getOrderReportDetailsVO1();
            vo.executeQuery();
          XMLNode  lo_xmlNode = (XMLNode)vo.writeXML(-1, 0L);

//OL Stands for XMLInterface.XML_OPT_ALL_ROWS which means to includes all rows in the view object's row set in the XML.

        return lo_xmlNode;
    }


Report Output


Thanks,
 --Anil

Thursday, December 4, 2014

Another Way : Passing Table Type Object from OAF


This article will describe you another way of passing table type object from OAF. I have already posted same article on it in 2010. Here is the link for your reference

http://oracleanil.blogspot.ae/2010/09/oaf-passing-table-type-object-to-oracle.html


Pre steps

1. We need to have object Type & Table Type for this.
   a) XX_OM_ORDER_TBL_TYPE
   b) XX_OM_ORDER_REC_TYPE

/* Script for your reference */

CREATE OR REPLACE TYPE APPS.XX_OM_ORDER_TBL_TYPE IS TABLE OF XX_OM_ORDER_REC_TYPE;


CREATE OR REPLACE TYPE APPS.XX_OM_ORDER_REC_TYPE AS OBJECT (
  ORDER_ID         NUMBER,
  ORDER_TYPE       VARCHAR2(20),
  ORDER_DATE       DATE,
  DESCRIPTION      VARCHAR2(200) );

*/ End Here.


2. Custom Table to insert data.
   a) xx_order_details
   
   /* Script for your reference */
   
   CREATE TABLE APPS.XX_ORDER_DETAILS
(
  ORDER_NUMBER       VARCHAR2(100 BYTE),
  ORDER_DESCRIPTION  VARCHAR2(240 BYTE),
  ORDER_TYPE         VARCHAR2(100 BYTE),
  ORDER_DATE         DATE
)

*/ End Here.

OAF Stuff starts here

1. Here we have to create components like - Controller, Page, AM, VO. 
2. Then we have to search for Object & Table type in Jdeveloper so that we can generate JAVA for these objects.

   Navigation : Connection Navigator --> Database --> DB SID --> Types
   






   
3. Back in the Application Navigator window you will find that reference java files are created




4. Order page will have table region and a save button.



5. Now we will first create blank rows in VO & then handle the event of Save button in Controller and add the logic in AMImpl file

//Controller code start here

package xx.oracle.apps.ont.order.webui;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;

/**
 * Controller for ...
 */
public class OrderCO extends OAControllerImpl
{
  public static final String RCS_ID="$Header$";
  public static final boolean RCS_ID_RECORDED =
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
     //init method to initialize the VO & to create 5 rows in it.
      pageContext.getApplicationModule(webBean).invokeMethod("init");
  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
        super.processFormRequest(pageContext, webBean);
      // AM method to handle the save button logic
      pageContext.getApplicationModule(webBean).invokeMethod("saveOrderData");

//Controller code end here

//AMImpl code start here
package xx.oracle.apps.ont.order.server;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.server.OAExceptionUtils;

import oracle.jbo.Row;
import oracle.jbo.domain.Number;
import oracle.jdbc.OracleCallableStatement;
import oracle.jdbc.OracleTypes;
import xx.oracle.apps.ont.order.server.OrderVOImpl;
/*
* Method to initialize the VO & to create blank rows in VO */
public void init() {
        OrderVOImpl vo = getOrderVO1();
        if (!vo.isPreparedForExecution()) {
            vo.executeQuery();
        Row row = null;
        for (int i = 0; i <= 5; i++) {
            row = vo.createRow();
            vo.insertRow(row);
        }
        row.setNewRowState(Row.STATUS_INITIALIZED);
    }

/* Wrapper to save the Order Entry Data. getOrderRecord() method will return the table type. We are getting this data from Order VO and then passing it to the object type. 

Further callOmOrderApi is getting called in this method which takes orderRec as a input parameter and calls the Pl/SQL to insert the data into the custom table.  */
  public void saveOrderData() {
        XxOmOrderTblType orderRec = getOrderRecord();
        callOmOrderApi(orderRec);
    }
    public XxOmOrderTblType getOrderRecord() {

        OrderVOImpl vo = getOrderVO1();
        XxOmOrderRecType[] orderRec = null;
        boolean l_error = false;

        if (vo != null) {
            System.out.println("VO is not null");
            Row[] vorow = vo.getAllRowsInRange();
            orderRec = new XxOmOrderRecType[vorow.length];

            for (int i = 0; i < vorow.length; i++)
                try {
                    XxOmOrderRecType recType = new XxOmOrderRecType();
                    OrderVORowImpl row = (OrderVORowImpl)vorow[i];

                    BigDecimal bg = new BigDecimal(row.getOrderNumber());
                    recType.setOrderId(bg);
                    recType.setOrderType(row.getOrderType());
                    recType.setDescription(row.getOrderDescription());

                    oracle.jbo.domain.Date d = row.getOrderDate();
                    java.sql.Date jd = d.dateValue();
                    System.out.println("Conv Date" + jd);
                    java.sql.Timestamp t = new Timestamp(jd.getTime());
                    System.out.println("Conv Date 1 " + t);
                    recType.setOrderDate(t);

                    orderRec[i] = recType;

                } catch (Exception e) {
                    throw new OAException("Error " + e.getMessage());
              }

        }
        XxOmOrderTblType table_row = new XxOmOrderTblType(orderRec);
        return table_row;
    }

/* This method accept table type parameter and calls PL/SQL procedure to write data to DB.
 *

    public void callOmOrderApi(XxOmOrderTblType issueTable) {
        Number lo_count = null;
        String lo_status = null;
        String ls_msgData = null;
        OracleCallableStatement lo_oraclecallablestatement;
        OADBTransaction lo_dbtransaction = getOADBTransaction();

        System.out.println("Above the callable statement");
        lo_oraclecallablestatement = null;
        try {
            lo_oraclecallablestatement = 
                    (OracleCallableStatement)lo_dbtransaction.createCallableStatement("begin xx_create_order_prc(:1, :2); end;", 
                                                                                      1);
            lo_oraclecallablestatement.setObject(1, issueTable, 
                                                 OracleTypes.ARRAY);

            lo_oraclecallablestatement.registerOutParameter(2, Types.VARCHAR);
            lo_oraclecallablestatement.execute();
            lo_status = lo_oraclecallablestatement.getString(2);

            if ("S".equalsIgnoreCase(lo_status)) {
                lo_dbtransaction.commit();
                lo_dbtransaction.putDialogMessage(new OAException("Order Created", 
                                                                  OAException.CONFIRMATION));
            } else {
                lo_dbtransaction.rollback();
                OAExceptionUtils.checkErrors(getOADBTransaction());
            }
            if (lo_oraclecallablestatement != null)
                lo_oraclecallablestatement.close();
        } catch (SQLException sqlexception) {
            throw new OAException(sqlexception.getMessage());
        }


    }


PL/SQL Code

//This code accept table type parameter then we loop through the records and insert those records to custom table and finally it return back the status as 'E' or 'S'

CREATE OR REPLACE PROCEDURE APPS.xx_create_order_prc (
      p_i_order_tbl                    XX_OM_ORDER_TBL_TYPE,
      p_o_return_status   OUT NOCOPY   VARCHAR2
   )
   IS    
   BEGIN
   
         FOR i IN p_i_order_tbl.FIRST .. p_i_order_tbl.LAST
         LOOP
            INSERT into xx_order_details VALUES (
            p_i_order_tbl (i).order_id,
            p_i_order_tbl (i).description,
            p_i_order_tbl (i).order_type,
            p_i_order_tbl (i).order_date);
           
         END LOOP;
   
   p_o_return_status := 'S';
 
   EXCEPTION
      WHEN OTHERS
      THEN
         p_o_return_status := 'E';
   
   END xx_create_order_prc;

/

Thanks,
--Anil

Sunday, August 31, 2014

Find Duplicate Row OR Copy/Clone VO Row

This article will give you idea on how to restrict user to enter duplicate rows. The requirement came when we want to enhance the user experience by providing the functionality to allow multiple Tools issue at one time.

This is applicable to all pages having table region/ advance table region and you want to restrict the user from enetring duplicate row. Here please keep in mind that I am not comparing the VO rows with DB rows. 

Application Module Method

        public void checkDuplicateRow() {

        XxTestToolsVOImpl lo_tools = getXxTestToolsVO(); //Table View Object
        XxTestToolsVOImpl clonevo = 
            (XxTestToolsVOImpl)this.findViewObject("XxTestToolsVO2"); //Dummy VO for check duplicity 
        if (clonevo == null) {
   //Create Dummy VO
            clonevo = 
                    (XxTestToolsVOImpl)this.createViewObject("XxTestToolsVO2", 
                                                             "xxadat.oracle.apps.ahl.tools.server.XxAdatToolsVO");
        }

        clonevo.clearCache();
        Row[] sourceVORows = 
            lo_tools.getFilteredRows("SelectFlag", "Y"); //Picking only those row where the Checkbox is checked
        if (!(clonevo.isPreparedForExecution())) {
            clonevo.executeQuery();
        }
  
  //Create ClonveVO with SourceVO rows
        for (Row row: sourceVORows) {
            Row cloneRow = clonevo.createRow();
            cloneRow = row;
            clonevo.insertRowAtRangeIndex(clonevo.getRangeIndexOf(clonevo.last()) + 
                                          1, cloneRow);//Inserting row one after another
        }
        int i = 0;
        int j;
        {
   for (Row row: sourceVORows) {
                j = 0;
                for (clonevo.first(); j < clonevo.getFetchedRowCount(); 
                     clonevo.next()) {
                    if (i == j) {
                        j++;
                        continue; //Ignore the row where index is same.
                    }
// This loop compare 1st row with all the rows except 1st then second row will   all the rows except 2nd and so on.
        if ((row.getAttribute("SerialNumber") +"").equals((clonevo.getCurrentRow().getAttribute("SerialNumber"))+"") && (row.getAttribute("InventoryItemId") + "").equals((clonevo.getCurrentRow().getAttribute("InventoryItemId"))+"") && (row.getAttribute("LotNumber") + "").equals((clonevo.getCurrentRow().getAttribute("LotNumber")) +  "") && (row.getAttribute("SubinventoryCode") +  "").equals((clonevo.getCurrentRow().getAttribute("SubinventoryCode")) + "") &&  (row.getAttribute("Locator") + "").equals((clonevo.getCurrentRow().getAttribute("Locator")) + ""))
                {
                  clonevo.remove(); //If the row is duplicate remove the dummy VO
                  throw new OAException("Row Number " + (i + 1) + " and " + (j + 1) + " is duplicate." + " Please select only unique Tools to issue");
                    }
                      j++;
                }
                i++;
            }
            lo_tools.first();
            clonevo.remove();

        }
    }
Thanks, --Anil

Sunday, July 20, 2014

Setting WHO columns in OAF & setting date in custom table

import java.text.SimpleDateFormat;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Timestamp;

Application Module Code

    public void SettingWhoColumns(String CStringDate) {
        java.sql.Date ConvStringDate = null;
        try {
            Connection conn = getOADBTransaction().getJdbcConnection();

            String Query = 
                "insert into XX_INSERT_WHO_COLUMNS  CREATION_DATE, CREATED_BY, LAST_UPDATE_DATE, LAST_UPDATED_BY, LAST_UPDATE_LOGIN values (:1, :2, :3, :4 ,:5)";
            PreparedStatement stmt = conn.prepareStatement(Query);
            //Creation Date
            stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
            stmt.setInt(2, getOADBTransaction().getUserId()); // Created by
            //Last update date 
            stmt.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
            stmt.setInt(4, getOADBTransaction().getUserId()); // Last updated by
            stmt.setInt(5,getOADBTransaction().getLoginId()); // Last updated login
            //Who columns setting end here.....

            // Getting Date as a String, Converting it to Date format and setting it
            if (CStringDate != null & !("".equalsIgnoreCase(CStringDate))) {
                SimpleDateFormat dtformatter = 
                    new SimpleDateFormat("dd-MMM-yyyy");
                ConvStringDate = 
                        new java.sql.Date(dtformatter.parse(CStringDate).getTime());
                dtformatter.format(ConvStringDate);
            }
            stmt.setDate(6, ConvStringDate);
        } catch (Exception e) {
            throw new OAException("Exception" + e);
        }
    }

Thanks,
--Anil

Friday, April 25, 2014

Make OAF page readonly


In the Controller process request method just write the below code to make whole page read only in one go.


import com.oaframework.toolkit.util.WebBeanUtil;

    public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
        super.processRequest(pageContext, webBean);
{
     // this class loops all the webbean hierarchy and make read only each and even bean and also sets the CSS accordingly.

      WebBeanUtil.setViewOnlyRecursive(pageContext, webBean);
}



In case of you are not able to get the WebBeanUtil file then please mail me I will provide you.

Thanks,
Anil

Setting value in specific segment of KFF


Hi Friends,

Recently I got a request from one of my friend to check the feasibility for setting value in one specific segment of KFF.

I tried a lot and finally I was able to accomplish this. Here is the code which you all can refer if you get this similar kind of requirement.

Just mentioning the DFF link also, incase you come across similar requirement on DFF.
Setting value in specific attribute of DFF


Steps
1. I created a dummy page and add a Flex bean to it.
2. Set few property of KFF as per below screenshot
3. Attached Controller & Application Module to this page.



In this test case, I am setting the value during page load. Hence you can see I have written code in the ProcessRequest method of the Controller.

However in case you want to set the value based on any event. So you have to capture the event in ProcessFormRequest method and then redirect to same page based on any parameter - HashMap or any session value and write the code in ProcessRequest only.

This is because when I tried to set the value in PFR method then the changes are not getting displayed.

Controller Code


        public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
        super.processRequest(pageContext, webBean);

        OAApplicationModule oaapplicationmodule = 
            pageContext.getApplicationModule(webBean);

        // Executing KFF VO query
        oaapplicationmodule.invokeMethod("executeQuery");
                //Getting the KFF Bean 
                OAKeyFlexBean kffId = 
            (OAKeyFlexBean)webBean.findChildRecursive("kffFlex");


        kffId = (OAKeyFlexBean)webBean.findChildRecursive("kffFlex");
        kffId.setStructureCode("JOB_FLEXFIELD");
        kffId.setCCIDAttributeName("IdFlexNum");
        //kffId.setDynamicInsertion(true);
        kffId.useCodeCombinationLOV(false);

        kffId.processFlex(pageContext);
        
        System.out.println("kff " + 
                           kffId.getIndexedChildCount(pageContext.getRenderingContext()));
        int i = kffId.getIndexedChildCount(pageContext.getRenderingContext());
        for (int j = 0; j < i; j++) {
            System.out.println("Inside the for loop");
            oracle.cabo.ui.UINode uinode = 
                kffId.getIndexedChild(pageContext.getRenderingContext(), j);
            if (uinode instanceof OAMessageTextInputBean) {
                System.out.println("Inside the MTI");
                // ((OAMessageTextInputBean)uinode).setText("message");
                // ((OAMessageTextInputBean)uinode).setCSSClass("OraErrorText");
                
                //Setting value in selected KFF Bean (It start from 0, thats why for our case it is kffFlex0)
                if ("kffFlex0".equalsIgnoreCase(uinode.getID()))
                    ((OAMessageTextInputBean)uinode).setText("HYLEX");
                System.out.println(uinode.getID());
            }

        }

    }
PS: Here I have not mentioned step by step process on how to create KFF.

Sunday, April 20, 2014

Create event programatically


Use this code to set event (could be FirePartialAction or FireAction) on any field.

    public void processRequest(OAPageContext pageContext, OAWebBean webBean) {

super.processRequest(pageContext, webBean);

oracle.cabo.ui.action.FireAction FireActionA = new oracle.cabo.ui.action.FireAction();
FireActionA.setEvent("RevenueEvent"); //Event Name
FireActionA.setUnvalidated(true);
revenuechk.setPrimaryClientAction(FireActionA); //revenuechk is the Id of the field

 public void processFormRequest(OAPageContext pageContext, OAWebBean webBean){

super.processFormRequest(pageContext, webBean);

if("RevenueEvent".equals(pageContext.getParameter(SOURCE_PARAM)))

{
//Event handling here
}
Thanks,
Anil