Tuesday, September 13, 2016

ADD_ROWS in Advance Table OAF

In Controller Code:


  OAAdvancedTableBean tableBean =
      (OAAdvancedTableBean)webBean.findChildRecursive("AdvTableId");

    if (tableBean.getName().equals(pageContext.getParameter(SOURCE_PARAM)) &&
        ADD_ROWS_EVENT.equals(pageContext.getParameter(EVENT_PARAM)))
    {

      String[] param ={ pageContext.getParameter(EVENT_PARAM), pageContext.getParameter("ProgrId") };
      Serializable[] k ={ pageContext.getParameter("ProgrId"),ObjVerNum};
      am.invokeMethod("repeatRowValidation", param);
      am.invokeMethod("createRow", k);
    }


Inside AM:


  public void repeatRowValidation(String Event, String prgid)
  {
    OAViewObject VOMain = getSaleableAreaDtlsVO1();

    System.out.println("Fetched vvvv Rowcount -->" + 
                       VOMain.getFetchedRowCount());
    int fetchedRowCount = VOMain.getFetchedRowCount();

    if (fetchedRowCount >= 1)
    {
      intIter = intIter + 1;
      strIter = "Iter" + intIter;
      RowSetIterator iter = VOMain.createRowSetIterator(strIter);
      for (int i = 1; i <= fetchedRowCount; i++)
      {
        SaleableAreaDtlsVORowImpl row = (SaleableAreaDtlsVORowImpl)iter.next();
        if (row == null)
        {
          iter.closeRowSetIterator();
          intIter = intIter + 1;
          strIter = "Iter" + intIter;
          throw new OAException("SaleableAreaDtlsVORow Doesnt Exist");
        } else
        {
          System.out.println("type is -->" + row.getSaleableareaType());
          if (row.getSaleableareaType() != null && 
              !row.getSaleableareaType().equals("USR_DTLS"))
          {
            Row[] VOCommerRows = 
              VOMain.getFilteredRows("SaleableareaType", row.getSaleableareaType());
            System.out.println("length -->" + VOCommerRows.length);
            if (VOCommerRows.length > 1)
            {
              throw new OAException("The Type should be Unique..", 
                                    OAException.ERROR);
            }
          }
          Row[] rows = VOMain.getFilteredRows("ProgramId", prgid);
          Row Vorow = null;
          if (rows != null && rows.length > 0)
          {
            if (Event != null && Event.equals("addRows"))
            {
              Vorow = rows[rows.length - 1];
              if (Vorow.getAttribute("UnitsMeasure") == null)
              {
                throw new OAException("Units Should not be null..", 
                                      OAException.ERROR);
              }
            }
          }
        }
      }iter.closeRowSetIterator();
    }
  }

public void createRow(String progid,String ObjVerNum)
  {
    OAViewObject pervo = getSaleableAreaDtlsVO1();
    //if(!pervo.isPreparedForExecution()){  pervo.executeQuery(); }
    pervo.setMaxFetchSize(0);
    pervo.last(); // Go to the last Row of the VO
    pervo.next();
    Row row = pervo.createRow();
    pervo.insertRow(row);
    row.setNewRowState(Row.STATUS_INITIALIZED);

    row.setAttribute("ProgramId", progid);
    Number Sno = new Number(pervo.getFetchedRowCount());
    row.setAttribute("SrNo", Sno);
    row.setAttribute("ObjVerNum",new Number(Integer.parseInt(ObjVerNum)));
    row.setAttribute("DeleteDisable", Boolean.FALSE);
  }








Thursday, September 8, 2016

Finance Interview Questions and Answers

1.       What are mandatory parameters of Procedures and what the use of those?
·         Errorbuf: It is used to returns the error messages and sent it to the log file.
·         Retcode: It is used to show the status of the Procedure with 0, 1, and 2.
0 for Completed Normal
1 for Completed Warning
2 for Completed Error
2.       What are the levels at which profile option can be set? If answered, ask the priority from lowest to highest of these level.
1. Site
2. Application
3. Responsibility
4. User
3.       What is Exception? What are the two types of exceptions?
Error handling part of PL/SQL block is called Exception. They have two types : user_defined and predefined
4.       List of Pre-Defined Exception.(Expecting a minimum of four)
DUP_VAL_ON_INDEX
ZERO_DIVIDE
NO_DATA_FOUND
TOO_MANY_ROWS
CURSOR_ALREADY_OPEN
INVALID_NUMBER
INVALID_CURSOR
PROGRAM_ERROR
TIMEOUT _ON_RESOURCE
STORAGE_ERROR
LOGON_DENIED
VALUE_ERROR
5.       What are the cursor attributes used in PL/SQL?
%ISOPEN: it checks whether the cursor is open or not.
%ROWCOUNT: returns the number of rows affected by DML operations: INSERT,DELETE,UPDATE,SELECT.
%FOUND: it checks whether cursor has fetched any row. If yes - TRUE.
%NOTFOUND: it checks whether cursor has fetched any row. If no - TRUE.
6.       What are the modes of parameters that can be passed to a procedure?
IN,OUT,IN-OUT parameters
7.       What is difference between a PROCEDURE & FUNCTION?
A FUNCTION is alway returns a value using the return statement.
A PROCEDURE may return one or more values through parameters or may not return at all.
8.       Can we associate a view to a trigger
Yes
9.       When a trigger is associated to a view, Is the base table triggers are normally disabled ?
No
10.   Difference between KFF and DFF
     

11.   What are different report triggers and what is their firing sequence ?
Before Parameter Form
After Parameter Form
Before Report
Between Pages
After Report.
12.   What are Interface table in AP
AP INTERFACE TABLE: 1). AP_INTERFACE_CONTROLS.
                                        2). AP_INTERFACE_REJECTIONS
                                        3). AP_INVOICE_INTERFACE
                                        4). AP_INVOICE_LINES_INTERFACE.

13.   What are Interface table in AR
                                                    1). AR_PAYMENTS_INTERFACE_ALL
                                                    2). AR_TAX_INTERFACE
                                                    3). HZ_PARTY_INTERFACE
                                                    4). HZ_PARTY_INTERFACE_ERRORS
                                                    5). RA_CUSTOMERS_INTERFACE_ALL
                                                    6). RA_INTERFACE_DISTRIBUTIONS_ALL
                                                    7). RA_INTERFACE_ERRORS_ALL
                                                    8). RA_INTERFACE_LINES_ALL
                                                    9). RA_INTERFACE_SALESCREDITS_ALL
14.   What are Interface table in GL
                     1). GL_BUDGET_INTERFACE
                                                  2). GL_DAILY_RATES_INTERFACE
                                                  3). GL_IEA_INTERFACE
                                                  4). GL_interface
                                                  5). GL_INTERFACE_CONTROL
                                                  6). GL_INTERFACE_HISTORY
15.   Difference between Lookups and Value Sets
1.Value sets can be attached to parameters of a concurrent program, whereas Lookups can't.
2.Value sets can contain values that are a result of an SQL Statement.
Hence it is possible to make Value Set list of values dynamic.
On the contrary, Lookup Codes are Static list of values.
16.   What are the differences between FAH and SLA?
FAH
• Deals with external (i.e. non-E-Business Suite) applications.
• No seeded event models – event models need to be build from scratch.
• No seeded accounting rules – accounting rules need to be build from scratch.
• Requires purchasing a separate license.
SLA:
• Deals with the E-Business Suite subledger applications (AR, AP, etc.).
• Seeded event models which cannot be changed (extensions can be build using Custom Sources).
• Seeded accounting methods which can be customized (copied and modified) at will.
• Integral part of E-Business Suite Financials (R12 onwards).

17.   What is transaction object table in FAH
These are the custom staging tables created to map the Third party system data to oracle.

18.   What are the mandatory accounting attributes used in FAH?
Entered Amount, Entered Currency code, First distribution identifier, distribution type ,GL Date
19.   What are supporting references and when can we use?
• To provide additional business information about a sub ledger journal entry at the header or line level
• To establish a sub ledger balance for a particular source value or combination of source values for a particular account
20.   Name few XLA tables
XLA_Events,
XLA_Transaction_entities,
xla_ae_headers,
xla_ae_lines,

xla_distribution_links

Wednesday, September 7, 2016

Xml Publisher Report

1. How to Upload RTF Template from Back end ?

By using oracle.apps.xdo.oa.util.XDOLoader

Upload:

java oracle.apps.xdo.oa.util.XDOLoader UPLOAD -DB_USERNAME $apps_user -DB_PASSWORD $apps_pwd -JDBC_CONNECTION Host Ip:Port:SID -LOB_TYPE TEMPLATE_SOURCE -APPS_SHORT_NAME XX -LOB_CODE XX_TEMP -LANGUAGE en -TERRITORY US -XDO_FILE_TYPE RTF -FILE_CONTENT_TYPE 'application/rtf' -FILE_NAME 'XX_TEMP.rtf' -CUSTOM_MODE FORCE

2. How to Map RTF Template Via Backend
   Using api FND_PROGRAM.ADD_TEMPLATE

3. What are the executeable and Concurrent Program used to develop a report without RDF?
     Executable: XDODTEXE
     Concurrent Program : Java Concurrent Program
  For developing a XML Publisher report without RDF

4. How to repeat header of the template on each and every page of the output ?
   Use <?@section: ?> in order to repeat that specific section in each page of the output. Also to reset the page number.

5. How many ways we can display images in a BI Publisher report?
    It can done in 5 ways
--> Direct insertion in RTF Template
--> URL Reference
--> OA_MEDIA directoty reference
--> Image from BLOB datatype from database
--> Using BI Beans

6. Conditional formatting:
      --> If statements :     <?if:condition?> your data <?end if?>
      -->If then else statements :            <?xdofx:if element_condition
                                                                                 Then output1
                                                                                 else output2     end if?>
      -->Choose statements:     for multiple conditions
                                                  <?choose?><?when:expression?><?otherwise?>

    There are more ways for Conditional Formatting in addition to the above like column formatting, row formatting etc.

7. Tables in Xml Publisher:
PER_GB_XDO_TEMPLATES
XDO_DS_DEFINITIONS_B
XDO_DS_DEFINITIONS_TL
XDO_DS_DEFINITIONS_VL
XDO_LOBS
XDO_TEMPLATES_B
XDO_TEMPLATES_TL
XDO_TEMPLATES_VL
XDO_TEMPLATE_FIELDS
XDO_TRANS_UNITS
XDO_TRANS_UNIT_PROPS
XDO_TRANS_UNIT_VALUES





Web ADI (Web Application Desktop Integrator)

Oracle Web Application Desktop Integrator (Web ADI) is Oracle E-Business Suite's solution for integrating E-Business Suite applications with desktop applications such as Microsoft Excel, Word and Projects.  "Integrators" encapsulate the metadata and other information needed to integrate a particular Oracle E-Business Suite task with a desktop application


The Desktop Integration Framework allows you to:

  • Create Integrators using a wizard-based user interface
  • Define Integrators to upload data through PL/SQL APIs or directly to tables
  • Define Integrators to download data from text files or using SQL Queries
  • Define data validation rules
  • Embed UI widgets (List of values, Pop lists, Date pickers, Flexfields) in spreadsheets
  • Use the Oracle E-Business Suite Security Model
  • Define layouts and mappings for custom integrators



Login --> Desktop Integration Manager --> Manage Integrator or Create Integrator



Contains below stages:

1. Integrator 
          --> Integrator Information
          --> Integrator Parameters
          --> Security Rules (functions to attach access the Web ADI)
2. Interfaces
          --> Enter the Interface table name (Temporary Table to load data into table)
                     or Procedure name (select in TYPE column)
          --> API Returns (FND Message Code - shows user defined messages, error messages - oracle error messages
          --> Define all attributes based on the Interface columns or parameters.
3. Contents
          --> Used to download data into Excel from Temporary (Interface) table.
          --> Need to write SQL Query in Content type to get data into excel
          --> Content Columns: link between query columns and excel columns

4. Uploader
         --> to Upload data 
5. Importer
         --> Validation package (procedure) to load data from Temporary table to Interface table.


6. Define Layout
   --> Need to select Integrator and  Require fields (line , Header etc)
7.Define Mappings:
     --> To Link for Layout and Integrator
     --> Select Source Columns and Target Columns for LOV buttons
8. Preview to see the preview of Integrator.

Tuesday, September 6, 2016

Data Template Method

Data engine supports the following functionality:
·         Single and multiple data queries
·         Query links
·         Parameters
·         Aggregate functions (SUM, AVG, MIN, MAX, COUNT)
·         Event triggers
·         Multiple data groups
XML output generated by the data engine supports the following:
·         Unicode for XML Output
Unicode is a global character set that allows multilingual text to be displayed in a single application. This enables you to develop a single multilingual application and deploy it worldwide.
·         Canonical format
The data engine generates date elements using the canonical ISO date format: YYYY-MM-DDTHH24:MI:SS.FF3TZH:TZM for a mapped date element, and ######.## for number elements in the data template XML output.

Data Template Definition:

The data template is an XML document that consists of 4 basic sections:
- Define parameters,
- Define triggers,
- Define data query,
- Define data structure.

This structure is shown as follows:



As shown in the sample figure, the data template consists of 
     a <parameters> section in which parameters are declared in child <parameter> elements; 
     a <dataQuery> section in which the SQL queries are defined in child <sqlStatement> elements; 
     a <dataStructure> section in which the output XML structure is defined.


Create Data Definition & Associate with Data Template
XML Publisher Administrator -> Data Definitions -> Create Data Definition




GL Interview Questions

1. What is journal, how many types of journal?
 Journals it is used to record the business transaction it contains debit and credit lines always debit must be equal to credit.
         Types of journals are
              --> Suspense Journal or Unbalanced Journal
              --> Recurring Journals
              --> Reversal journals.

Types of Journals:

1. Functional Currency Journal: This Journal, we enter Local Currency transaction purpose.

2. Foreign Currency Journal: this Journal, we enter other than local currency transaction purpose...before we define exchange rates

3.Suspense Journal: this Journal, whenever debit is not equal to credit that time, we enable in set of books window Suspense button, then it works otherwise it's not working

4.Tax Journal: this Journal, calculate taxation of Purchased items

5.Reverse Journal: this Journal whenever we enter recurring journal, at the time of we using..We have two methods...one is Debit to Credit and second one is sign (+ to -)

6.Recurring Journal:this one is We define one template, we use Periodically, these are 3 types
1.Standard 2.Skeleton 3.Formula

7.Mass Allocation Journal:Set of Expenses or Set of Revenue allocate different parts using Formula A*B/C
A is Total Cost Pool..B is Usage Factor...C is Total Usage Factor...

8. Batch Journal: Group of Journal we enter at a time, We Define Control Amount

9. Stat Journal: This JV we have one side of Amount either debit or Credit.....

3. Interface tables in General Ledger ?

GL_BUDGET_INTERFACE
GL_DAILY_RATES_INTERFACE
GL_IEA_INTERFACE
GL_INTERFACE
GL_INTERFACE_CONTROL
GL_INTERFACE_HISTORY




TCA API's

API's in TCA:


Friday, August 26, 2016

Attachment to Workflow Notification

Add multiple Attachments to Workflow Notification:


1. Create Attribute like below:


2. Add Message Attribute like below (to to respective Notification Messages)
                             
                              Internal name : #ATTACHMENTS
                              Display Name: #ATTACHMENTS
                                Value:    Custom Attachment Attribute (which created above)


3. In the Workflow Package Set the Attribute Value Like Below:
               
 
        SELECT count(*) into l_attach_cnt
      FROM  FND_ATTACHED_DOCS_FORM_VL
      WHERE  function_name  =DECODE(0,1,NULL,'GLXJEENT')
      AND function_Type=DECODE(0,1,NULL,'O')
      AND  (    (      entity_name = 'GL_JE_HEADERS'    AND pk1_value = l_je_batch_id )  )    ;
   
           

     if l_attach_cnt >0  then

        wf_engine.SetItemAttrText( itemtype => itemtype,
                                     itemkey  => itemkey,
                                     aname    => 'ATTACH_ATTRIBUTE',
                                     avalue   => 'FND:entity=GL_JE_HEADERS&'||'pk1name=je_batch_id&'||'pk1value='||l_je_batch_id );
     end if ;


4. After that check the notification to find all the attachments, all the attachments count is equal to l_attach_cnt variable. 

File Upload to Unix Server (OAF Controller Code)

import com.sun.java.util.collections.ArrayList;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable;

import java.util.Date;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OADialogPage;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;
import oracle.apps.xx.server.pathListVOImpl;
import oracle.apps.xx.server.pathListVORowImpl;

import oracle.cabo.ui.data.DataObject;

import oracle.jbo.Row;
import oracle.jbo.domain.BlobDomain;

/**
 * Controller for ...
 */
public class xxFileUploadCO6 extends OAControllerImpl
{
  public static final String RCS_ID="$Header$";
  public static final boolean RCS_ID_RECORDED =
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
  String path = "";
  /**
   * 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 oawebbean)
  {
    super.processRequest(pageContext, oawebbean);
    System.out.println(" --  Start PR xxFileUploadCO  -- ");
    OAApplicationModule am =(OAApplicationModule) pageContext.getApplicationModule(oawebbean);
    if (!pageContext.isFormSubmission())
       am.invokeMethod("createRecord");
     
//       // Test
//      
//        OAMessageChoiceBean k = (OAMessageChoiceBean)oawebbean.findIndexedChildRecursive("choiceList");
//        k.setListVOBoundContainerColumn(0, tableBean,"DepColvalue1");
//        k.setListVOBoundContainerColumn(1, tableBean,"DepColvalue2");
//        k.setPickListCacheEnabled(false);                 //  "DepColvalue1","DepColvalue2" are the Item ID in the page Structure and the choice list query execute based on these values for each row in Table Region Dynamically.
//      
//       // end test
  }

  /**
   * 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
   */
   ArrayList Msgs= new ArrayList();
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    System.out.println(" --  Start PFR xxFileUploadCO  -- ");
    OAApplicationModule am =(OAApplicationModule) pageContext.getApplicationModule(webBean);
   
    if (pageContext.isLovEvent())
    {
      String lovInputSourceId = pageContext.getLovInputSourceId();
      if("Entity_name".equals(lovInputSourceId))
      {
        OAMessageLovInputBean lovBean=(OAMessageLovInputBean)webBean.findIndexedChildRecursive(lovInputSourceId);
        if(lovBean != null)
        {
          String lovInput  =  (String) lovBean.getValue(pageContext);
          System.out.println("--lovInput --"+lovInput);
        }
      }
      String v_path = pageContext.getParameter("PathToUpload");
      System.out.println("--value v_path --"+v_path);
      Serializable [] param = {v_path};
      path = v_path;
      am.invokeMethod("exeVO",param);
    }
   
   
   
   
     if (pageContext.getParameter("Upload") != null)
    {
      if(path == null || path.equals(""))
      {
        throw new OAException("Please Select Valid Path..", OAException.ERROR);
      }
      validatUploadFileExtn(pageContext, webBean);
      ValiadteFileUploadExists(pageContext, webBean,path);
    }
       if (pageContext.getParameter("WarningYesButton") != null)
       {
         upLoadFile_FromInstance(pageContext, webBean, path);
         //upLoadFile_FromLocalMachine(pageContext, webBean);
       }
       if(pageContext.getParameter("search")!= null)
       {
         ValidatePopulateFileToSearch(pageContext, webBean);
       }
     
       if(pageContext.getParameter(EVENT_PARAM).equals("FileDownloadfromServer"))
       {
         String rowRef = (String)pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
         pathListVORowImpl lineRow = (pathListVORowImpl)am.findRowByRef(rowRef);
         if(lineRow != null)
         {
            System.out.println("Path to Download File-->"+lineRow.getpath());
            String file_name_with_path = lineRow.getpath();
            downloadFileFromServer(pageContext, file_name_with_path,webBean) ;
         }
       }
       if (pageContext.getParameter("archievdddde") != null)
       {
         Msgs.clear();
         pathListVOImpl vo = (pathListVOImpl) am.findViewObject("pathListVO1");
         Row Vorow = null;
         Row[] rows = vo.getFilteredRows("SelectFlag", "Y");
         if(rows.length > 0)
         {
           String ConfirmationMsg = "All Files Moved Successfully..";
           for (int i = 0; i < rows.length; i++)
           {
             Vorow = rows[i];
             System.out.println(" --> " + Vorow.getAttribute("path"));
             String CurrentPath = Vorow.getAttribute("path").toString();
             archieveFiles(pageContext,webBean, CurrentPath);
           }

           if(Msgs.size() > 0 )
            OAException.raiseBundledOAException(Msgs);
           else
             throw new OAException(ConfirmationMsg,OAException.CONFIRMATION );
         }
       
         if(rows.length == 0)
         {
           throw new OAException("No files Selcted to Archieve..");
         }
       }
  }
 
  public void archieveFiles(OAPageContext pageContext,OAWebBean webBean, String CurrentPath)
  {
     FileValidations(CurrentPath);
     String archiedPath = "/tmp/guruswamy";
     File afile = new File(CurrentPath);
     String RenamePath = archiedPath + afile.separator + "archive";
     FileValidations(RenamePath);
     String fname = RenamePath + afile.separator + afile.getName();
     if (afile.renameTo(new File(fname)))
     {
       System.out.println("File Moved");
       //Msgs.add(new OAException((String)("File moved successfully to path : " + RenamePath)));
     }
     else
     {
       Msgs.add(new OAException((String)("Unable to Move file : " + fname)));
     }
   }
 
  public void FileValidations(String fileName)
  {
   /* {
      throw new OAException("File path is invalid." + fileName);
      MessageToken[] token = {new MessageToken("USER", getOADBTransaction().getUserName()),new MessageToken("NUM",hMember.getChildNumber())};
      errorMsg.add(new OAException((String)(getOADBTransaction().getMessage("XXCH","XXCH_NO_ACCESS",token))));
      Msgs.add(new OAException((String)("File path is invalid.. "+fileName)));
    }  */
    if (((fileName == null) || ("".equals(fileName))))
    {
      Msgs.add(new OAException((String)("File Path Should not be null : " + fileName)));
    }
    else
    {
      File fileToDownload = new File(fileName);
      if (!fileToDownload.exists())
      {
        Msgs.add(new OAException((String)("File Path does not exist :" + fileName)));
      }
      if (!fileToDownload.canRead() && fileToDownload.exists() )
      {
         Msgs.add(new OAException((String)("Not Able to read the file Path :" + fileName)));
      }
    }
  }
 
  public void downloadFileFromServer(OAPageContext pageContext, String file_name_with_path,OAWebBean webBean)
  {
    HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletResponse();
    if (((file_name_with_path == null) || ("".equals(file_name_with_path))))
    {
      throw new OAException("File path is invalid.");
    }
    File fileToDownload = null;
    try
    {
      fileToDownload = new File(file_name_with_path);
    }
    catch (Exception e)
    {
      throw new OAException("Invalid File Path or file does not exist.");
    }
    if (!fileToDownload.exists())
    {
      throw new OAException("File does not exist.");
    }

    if (!fileToDownload.canRead())
    {
      throw new OAException("Not Able to read the file.");
    }
   
    System.out.println(" file_name_with_path -->"+file_name_with_path);
    String file_name_with_ext_toSave = fileToDownload.getName();
   
    System.out.println(" File to save download File -->"+file_name_with_ext_toSave);
   
    String fileType = "application/pdf"; //getMimeType(file_name_with_ext_toSave);
    response.setContentType(fileType);
    response.setContentLength((int) fileToDownload.length());
    response.setHeader("Content-Disposition", "attachment; filename=\"" + file_name_with_ext_toSave + "\"");

    InputStream in = null;
    ServletOutputStream outs = null;

    try
    {
      outs = response.getOutputStream();
      in = new BufferedInputStream(new FileInputStream(fileToDownload));
      int ch;
      while ((ch = in.read()) != -1)
      {
        outs.write(ch);
      }
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
    finally
    {
      try
      {
        outs.flush();
        outs.close();
        if (in != null)
        {
          in.close();
        }
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    }
  }
 
  public void validatUploadFileExtn(OAPageContext pageContext, OAWebBean webBean)
  {
    String uFileName = null;
    try
    {
      DataObject fileUploadData = pageContext.getNamedDataObject("MsgFileUpload");
      uFileName = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
    }
    catch (Exception ex)
    {
      throw new OAException(ex.getMessage(), OAException.ERROR);
    }
    if(uFileName != null )
    {
      String FileExtn = null;
      if(uFileName.lastIndexOf(".") != -1 && uFileName.lastIndexOf(".") != 0)
       FileExtn  = uFileName.substring(uFileName.lastIndexOf(".")+1);
      System.out.println("File Extention --> "+FileExtn);
      System.out.println("profile value for FileEXtnetion  : "+pageContext.getProfile("XX_FILE_UPLOAD_TYPE_PF"));
     
      if(pageContext.getProfile("XX_FILE_UPLOAD_TYPE_PF") == null
                  || pageContext.getProfile("XX_FILE_UPLOAD_TYPE_PF").equals(""))
      {
        throw new OAException("Please Select Profile Value for File Extention ", OAException.ERROR);
      }
     
      String fe = pageContext.getProfile("XX_FILE_UPLOAD_TYPE_PF");
      String[] okFileExtensions = fe.split(",");
      int cnt = 0;
      for(int i= 0 ; i< okFileExtensions.length; i++)
      {
        if(okFileExtensions[i].replace("\"","").toLowerCase().equals(FileExtn.toLowerCase()))
        {
          cnt = cnt + 1;
        }
      }
      if(cnt == 0)
      {
        throw new OAException("Please select File Type as : { "+ fe + " }", OAException.ERROR);
      }
    }
   
  }
 
  public void ValidatePopulateFileToSearch(OAPageContext pageContext, OAWebBean webBean)
  {
    OAApplicationModule am =(OAApplicationModule) pageContext.getApplicationModule(webBean);
    OAMessageTextInputBean m = (OAMessageTextInputBean )webBean.findChildRecursive("FileToSearch");
    Object FileToSearch_k = m.getValue(pageContext);
 
    if( FileToSearch_k  == null || FileToSearch_k.equals(""))
    {
      throw new OAException("Enter Valid value for \"Exact File Path to Find \" ",OAException.ERROR);
    }
    String FileToSearch = FileToSearch_k.toString();
    System.out.println(" File to Search value -->"+FileToSearch);
    am.invokeMethod("deleteRows");
   
    if(FileToSearch == null || FileToSearch.equals(""))
    {
      throw new OAException ("Path Should not be null",OAException.ERROR);
    }
   
    File paramFile = new File(FileToSearch);
   
    if(!paramFile.exists())
    {
      MessageToken[] arrayOfMessageToken = { new MessageToken("PATH", FileToSearch, false) };
      throw new OAException(pageContext.getMessage("FND", "PERZ_INVALID_DOC_PATH", arrayOfMessageToken), OAException.ERROR);
    }
   
    try
     {
       ArrayList paramArrayList = new ArrayList();
       ArrayList lastModifyDateArrayList = new ArrayList();
       populateFilesToArrayList(paramArrayList, paramFile,lastModifyDateArrayList);
       for (int i = 0; i<paramArrayList.size();i++ )
       {
         Serializable parameters[]  = {paramArrayList.get(i).toString(),lastModifyDateArrayList.get(i).toString()};
         Class paramTypes[] = {String.class, String.class};
         am.invokeMethod("setPath",parameters,paramTypes);
       }
     }
     catch (OAException localOAException)
     {
        System.out.println("inside localOAException "+localOAException);
     }
  }
 
 
  public void ValiadteFileUploadExists(OAPageContext pageContext, OAWebBean webBean,String path)
  {
      String uFileName = "";
      if(path == null || path.equals(""))
      {
        throw new OAException("Please Select value for \"Unix Path\" to Upload ..", OAException.ERROR);
      }
      DataObject fileUploadData = pageContext.getNamedDataObject("MsgFileUpload");
      if (fileUploadData != null)
      {
        uFileName = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
      }
      File UploadingFileFullPath = new File(path + File.separator + uFileName);
      if(UploadingFileFullPath.exists())
      {
        dialoguePage(pageContext, webBean);
      }
      else
      {
        //upLoadFile_FromLocalMachine(pageContext, webBean);
        upLoadFile_FromInstance(pageContext, webBean, path);
      }
     
  }
 
 
  public void dialoguePage(OAPageContext oapageContext, OAWebBean oawebBean)
    {
      OADialogPage dialoguepage = null;
      //OAException mainmsg = new OAException("CF","XX_TEST");
      OAException mainmsg =
        new OAException("The Files Already Exist in path.. Do You want to Overwrite it..");
      dialoguepage = new OADialogPage(OAException.WARNING, mainmsg, null, "", "");
      dialoguepage.setOkButtonItemName("WarningYesButton");
      dialoguepage.setOkButtonToPost(true);
      dialoguepage.setNoButtonToPost(true);
      dialoguepage.setPostToCallingPage(true);
      dialoguepage.setOkButtonLabel("Yes");
      dialoguepage.setNoButtonLabel("No");
      dialoguepage.setPageTitle("File Alreay Exists Warning..");
      oapageContext.redirectToDialogPage(dialoguepage);
    }
   
   
  private static void populateFilesToArrayList(ArrayList paramArrayList, File paramFile,ArrayList lastModifyDateArrayList)
  {
    String[] arrayOfString = paramFile.list();
    if (arrayOfString == null)
    {
      File localFile = new File(paramFile.getAbsolutePath());
      if(localFile.isFile())
      {
        paramArrayList.add(localFile);
        Date k = new Date(localFile.lastModified());
        lastModifyDateArrayList.add(k);
      }
    }
    if(arrayOfString != null)
    {
      for (int i = 0; i < arrayOfString.length; i++)
      {
        File localFile = new File(paramFile.getAbsolutePath() + File.separator + arrayOfString[i]);
        if (localFile.isDirectory())
        {
          populateFilesToArrayList(paramArrayList, localFile,lastModifyDateArrayList);
        }
        if(localFile.isFile())
        {
          paramArrayList.add(localFile);
          Date k = new Date(localFile.lastModified());
          lastModifyDateArrayList.add(k);
        }
      }
    }
  }
 

  // CODE #1 -- If Page has not deployed at instance, testing at Local Machine, use following Code


  public void upLoadFile_FromLocalMachine(OAPageContext pageContext, OAWebBean webBean)
  {
    String filePath = "D:\\PRajkumar";
    String status = "N";
    File file = null;
    String fileUrl = null;
    try
    {
      DataObject fileUploadData = pageContext.getNamedDataObject("MsgFileUpload");
      //FileUploading is my MessageFileUpload Bean Id
      if (fileUploadData != null)
      {
        String uFileName = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
        String contentType = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
        FileOutputStream output = null;
        InputStream input = null;

        BlobDomain uploadedByteStream = (BlobDomain) fileUploadData.selectValue(null, uFileName);
        file = new File("D:\\PRajkumar", uFileName);
        output = new FileOutputStream(file);
        input = uploadedByteStream.getInputStream();
        byte abyte0[] = new byte[0x19000];
        int i;
        while ((i = input.read(abyte0)) > 0)
          output.write(abyte0, 0, i);
        output.close();
        input.close();
        status = "Y";
      }
    }
    catch (Exception ex)
    {
      throw new OAException(ex.getMessage(), OAException.ERROR);
    }
    if( status.equals("Y"))
    {
      throw new OAException("File Uploaded Successfully to Path : "+file, OAException.CONFIRMATION);
    }
  }


  // CODE #2 -- If Page has been Deployed at Instance, Use Following Code


  public void methodChangeFilePermissions(File fileUrl)
  {
    try
    {
      String[] command = { "/bin/chmod", "777", fileUrl.getAbsolutePath(), };
      Runtime rt = Runtime.getRuntime();

      Process proc = rt.exec(command);
      InputStream stdin = proc.getInputStream();
      InputStreamReader isr = new InputStreamReader(stdin);
      BufferedReader br = new BufferedReader(isr);
      String line = null;
      System.out.println("<OUTPUT>");
      while ((line = br.readLine()) != null)
        System.out.println(line);
      System.out.println("</OUTPUT>");
      int exitVal = proc.waitFor();
      System.out.println("Process exitValue: " + exitVal);
     
      if(proc.exitValue()!=0)
      {
        throw new OAException("The permission change failed with exit value" + proc.exitValue()+ " -->"+exitVal, OAException.ERROR);
      }
    }
    catch (Throwable t)
    {
      throw new OAException("Exception in  methodChangeFilePermissions :"+fileUrl.getAbsolutePath()+"-->"+t, OAException.ERROR);
    }
  }

  public void upLoadFile_FromInstance(OAPageContext pageContext, OAWebBean webBean,String path)
  {
    String filePath = path;
    String status = "N";
    File file = null;
    String fileUrl = null;
 
    try
    {
      DataObject fileUploadData = pageContext.getNamedDataObject("MsgFileUpload");
      //FileUploading is my MessageFileUpload Bean Id
      if (fileUploadData != null)
      {
        String uFileName = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
        String contentType = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
        FileOutputStream output = null;
        InputStream input = null;
        BlobDomain uploadedByteStream = (BlobDomain) fileUploadData.selectValue(null, uFileName);
        file = new File(filePath, uFileName);
        fileUrl = filePath + file.separator +"\""+ uFileName+"\"";
        output = new FileOutputStream(file);
        input = uploadedByteStream.getInputStream();
        byte abyte0[] = new byte[0x19000];
        int i;
        while ((i = input.read(abyte0)) > 0)
          output.write(abyte0, 0, i);

        output.close();
        input.close();
        status = "Y";
      }
    }
    catch (Exception ex)
    {
      throw new OAException(ex.getMessage(), OAException.ERROR);
    }
    methodChangeFilePermissions(file);
    if( status.equals("Y"))
    {
      throw new OAException("File Uploaded Successfully to Path : "+file, OAException.CONFIRMATION);
    }
  }
}

Thursday, August 25, 2016

Oracle Workflow Topics

1. Oracle Workflow Basics
2. Attributes and Attribute Types
3. Process, Notifications, Functions, Events
4. Messages and Message Attributes, Lookup Types
5. Simple Workflow Creation from WFSTD
6. Intiate workflow
7. Deploying and call workflow in Instance
8. Debugging Workflow Processes
9. WAIT, TIMEOUT, LOOP, NOOP, AND, OR etc. Workflow Standard Functions
10. Database Tables of Workflow
11. FYI and Respond Notifications
12. Workflow Background Process, Workflow Definiation Loader
13. Notification with Attachment
14. Send OAF Page Link from Oracle Workflow
15. Parent and Child Workflow processes
16. Migration of Workflow through WF_LOAD

Friday, August 19, 2016

API to Delete Oracle Alert

Query to Get Alert Details:


Select * from ALR_ALERTS where alert_name like 'TEST_ALERT_NEW';


API to Delete Alert:

Declare
l_Alert_appl_id Number := 20003;                    -- Application Id from ALR_ALERTS
l_Alert_id Number := 11111;                         -- Alert Id from ALR_ALERTS

BEGIN
ALR_ALERTS_PKG.DELETE_ROW(l_Alert_appl_id,l_Alert_id);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Alert Deleted Successfully..'||SQLERRM);
ROLLBACK;
END;

Monday, August 15, 2016

OAF Topics

1. Introduction to OAF (Basics)
2. JDeveloper Setup and Deployment
3. MVC Architecture and Implementation
4. BC4J Objects
5. Hello World Page
6. Data Entry, Search and Update Page and Delete Page
7. Regions, Region Types, and Item Styles
8. Concepts of LOV's and Picklists and Event Capturing
9. PPR , Dependent LOV's, SPEL 
10. Passing Parameters in OAF
11. Table and Advance Table Concepts (single Selection, Multiple selection, totalling etc.)
12. File Upload Page, Download,  Tree Region in OAF
13. Dialogue page and Processing Page in oaf
14. Switcher Region in oaf
15. Tabs , Navigations in oaf
16. Master Child Relationship, Association objects in oaf
17. Images, Hide/Show, Java Script in OAF, Pop-up, Links in oaf
18. Single and Multiple Attachments in OAF
19. Calling PL SQL, SQL Statements from OAF
20. Validations and Debugging in oaf Pages
21. OAF Registration on Applications
22. Personalization, Extension of CO & VO in OAF 
23. Calling Oracle Form and Oracle Workflow from OAF page
24. Migration of OAF pages and OAF Page Personalizations
25. Custom CSS Properties to OAF Pages

Monday, August 1, 2016

ADF Quotes

1. Clear ADF Connection details and need to open JDeveloper fresh in 11g ?

Ans: Goto below path:

             C:\Users\<SystemUserName>\AppData\Roaming\JDeveloper

         and remove or rename file : system11.1.2.4.39.64.36.1 and restart the JDeveloper.

Friday, July 29, 2016

WF_NOTE in workflow

select count(*) into L_attr_cnt
from wf_notification_attributes
where notification_id =  wf_engine.context_nid
and name = 'WF_NOTE'  ;                              
                   
    if  L_attr_cnt = 0 then    
        wf_notification.ADDATTR( wf_engine.context_nid,'WF_NOTE');
    end if;                                              
     l_comment := wf_notification.getattrtext(wf_engine.context_nid,'WF_NOTE');
     wf_notification.SetAttrText(wf_engine.context_nid, 'WF_NOTE', l_comment);

Raise Exception in Workflow Procedure

EXCEPTION  WHEN OTHERS THEN
    Wf_Core.Context('XX_PKG', 'xx_apprs', itemtype, itemkey);
    raise;

Add Attribute Programatically to Workflow

select count(name)  into l_attr_cnt
                    from wf_item_attribute_values where item_key = itemkey
                    and name like to_char('xx attr name')
                    and item_type = 'GLBATCH';
if l_attr_cnt = 0 then    
        apps.WF_ENGINE.AddItemAttr( itemtype =>  itemtype,
                                    itemkey =>  itemkey,
                                    aname =>  to_char('xx attr name'),
                                      text_value=> 'Guru',                -- If want to create attribute Text Type
                                      number_value=> null,                -- If want to create attribute Number Type
                                      date_value=> null);                 -- If want to create attribute Date Type
                                     
 end if;
apps.wf_engine.setitemattrtext (itemtype =>  itemtype,
                                itemkey  =>  itemkey,
                                aname    =>  to_char('xx attr name'),
                                avalue   =>  'Guru' )