Wednesday, January 9, 2019

Oracle OAF :- Search Button Logic

Controller
===========================================

  if (pageContext.getParameter("Search") != null)  {
   String BuildingID = pageContext.getParameter("SearchBuild");
   String FloorID = pageContext.getParameter("SearchFloor");
   String OfficeID = pageContext.getParameter("SearchOffice");
   am.xxinitBuildQuery(BuildingID, FloorID, OfficeID);
  }


Application Module
============================================


public void xxinitBuildQuery(String BuildingID, String FloorID, String OfficeID) {
     BuildingVOImpl vo = getBuildingVO1();
     vo.xxBuildingDetails(BuildingID, FloorID, OfficeID);

    if (((BuildingID == null) || ("".equals(BuildingID))) && ((FloorID == null) || ("".equals(FloorID))) && ((OfficeID == null) || ("".equals(OfficeID))))
       throw new OAException("If Building ,Floor & Office search options are null, then this page will display all the location data", (byte)2);
   }


View Object
============================================

 public void xxBuildingDetails(String BuildingID, String FloorID, String OfficeID)
   {
     if ((BuildingID != null) && (!"".equals(BuildingID)))
     {
      setWhereClauseParam(0, BuildingID);
     }
     else setWhereClauseParam(0, null);

     if ((FloorID != null) && (!"".equals(FloorID)))
    {
       setWhereClauseParam(1, FloorID);
     }
    else setWhereClauseParam(1, null);

    if ((OfficeID != null) && (!"".equals(OfficeID)))
     {
       setWhereClauseParam(2, OfficeID);
     }
     else setWhereClauseParam(2, null);

    executeQuery();
  }

View Query
========================

SELECT *
  FROM  pn_locations_v
 WHERE  location_code = NVL (:1, location_code)
      AND (NVL (:2, 'A') = 'A'
            OR (location_id =
                   (SELECT flr.parent_location_id
                      FROM pn_locations_all flr
                     WHERE     flr.location_code = :2
                           AND flr.location_type_lookup_code = 'FLOOR'
                           AND ROWNUM = 1)) )
         AND  (NVL (:3, 'A') = 'A'
            OR   (location_id =
                   (SELECT flr.parent_location_id
                      FROM pn_locations_all flr
                     WHERE     flr.location_id = (SELECT flr.parent_location_id
                      FROM pn_locations_all flr
                     WHERE     flr.location_code = :3
                           AND flr.location_type_lookup_code = 'OFFICE' AND ROWNUM = 1)
                           AND flr.location_type_lookup_code = 'FLOOR'
                           AND ROWNUM = 1)) )

Sunday, January 6, 2019

Oracle OAF :- Lov Dynamic Parameter



AM
====================================================

public void initPOLovVO(String orgIDStr)
{
   itemLovVOImpl vo = getItemLovVO1();
   vo.clearCache();
   vo.setWhereClause(null);
   vo.setWhereClause("org_id = "  + orgIDStr);
   vo.executeQuery();
}



Process Request
===================================

LovPageAMImpl am = (LovPageAMImpl)pageContext.getApplicationModule(webBean);
am.initPOLovVO ("-1");



Process Form Request
==============================

if (pageContext.isLovEvent())
  {
  String lovSourceIDStr = pageContext.getLovInputSourceId(); /* Get the ID of the Lov Item */  
  if (lovSourceIDStr != null && "orgNameLovID".equals(lovSourceIDStr)) /* Compire it with the required lov ID */
  {
  OAMessageLovInputBean orgNameLovIDBean = (OAMessageLovInputBean)webBean.findIndexedChildRecursive("orgNameLovID");
  String orgNameStr = (String)orgNameLovIDBean.getValue(pageContext); /* Get the Lov Item Data*/
  OAFormValueBean orgIDFVBean = (OAFormValueBean)webBean.findIndexedChildRecursive("tempOrgId");
          String orgID = (String)orgIDFVBean.getValue(pageContext); /* Get the Form Value Data*/
          am.initPOLovVO (orgID);
  } 
  }
  

Monday, December 31, 2018

Oracle OAF :- Deploying New Page



Page Compile
===================

java oracle.jrad.tools.xml.importer.XMLImporter $JAVA_TOP/oracle/apps/fnd/framework/navigate/webui/NewHomePG.xml /* Page Path */
-username apps  /* User Name */
-password testapps   /* Password */
-rootdir $JAVA_TOP
-dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(
HOST=192.11.101.11 /*Host*/
)(
PORT=1001 /*Port*/
))(CONNECT_DATA=(
SID=TESTINSTANCE /*SID*/
)))"


Check the Page is Deployed
=============================

DECLARE
BEGIN
   jdr_utils.printdocument (
      '/oracle/apps/fnd/framework/navigate/webui/NewHomePG',
      1000);
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (SQLERRM);
END;



Oracle OAF: Get & Set Session Values

Put Session Value 
=========================

 pageContext.putSessionValue("mode", "U");

Get Session Value 
=========================

String mode = (String)pageContext.getSessionValue("mode");

 if (mode.equals("C"))

Oracle OAF : Code Combination Dynamic

Controller
===================

OAApplicationModule am = pageContext.getApplicationModule(webBean);
System.out.println("Before Setting the Flex Field ");
String str12 = (String)am.invokeMethod("getFSC", new Serializable[] { String.valueOf(pageContext.getOrgId()) });
OAKeyFlexBean kffId = (OAKeyFlexBean)webBean.findIndexedChildRecursive("WriteoffCodeCombination");
kffId.useCodeCombinationLOV(true);
kffId.setStructureCode(str12);
kffId.setCCIDAttributeName("WriteoffCodeCombinationId");
// kffId.setRequired("yes");
// kffId.setWidth("170%");
kffId.addVRule("", "SUMMARY_FLAG", new Message("SQLGL", "GL_NO_PARENT_SEGMENT_ALLOWED"), true, new String[] { "N" });


Ampplication Module
====================

public String getFSC(String paramString)
{
String str1 = null;
String str2 = "begin select kst.id_flex_structure_code  into :1  from apps.fnd_id_flex_structures kst, apps.gl_ledgers gll,  apps.hr_operating_units hro  where     kst.id_flex_code = 'GL#' and kst.application_id = 101 and kst.id_flex_num = gll.chart_of_accounts_id   and gll.ledger_id = hro.set_of_books_id   and hro.organization_id = :2 ; end;";
CallableStatement localOracleCallableStatement = getOADBTransaction().createCallableStatement(str2, 1);
try
{
int i = Integer.parseInt(paramString);
localOracleCallableStatement.setInt(2, i);
localOracleCallableStatement.registerOutParameter(1, 12);
localOracleCallableStatement.execute();
str1 = localOracleCallableStatement.getString(1);
}
catch (SQLException e)  {throw new OAException("Sequence not found");}
if ((str1 == null) || ("".equals(str1.trim()))) str1 = "OPERATIONS_ACCOUNTING_FLEX";
return str1;
 }

OAF AddRow : Create New Row In Line Table

Controller
========================================

if ("AddRow".equals(pageContext.getParameter("event"))) { am.invokeMethod("AddRow");}
 

Application Module
========================================

public void AddRow()
{
OAViewObject voLine = (OAViewObject)getWrOffLineVO1();
OAViewObject voHeader = (OAViewObject)getWrOffHeaderVO1();
if (!voLine.isPreparedForExecution()) { voLine.setMaxFetchSize(0); voLine.executeQuery(); }
voLine.last(); voLine.next();
Row row = voLine.createRow(); voLine.insertRow(row);
row.setNewRowState((byte)-1);
String HReqID = voHeader.getCurrentRow().getAttribute("InvWriteoffHeaderId").toString();
row.setAttribute("LineNo", Integer.valueOf(voLine.getRowCount()));
row.setAttribute("InvWriteoffHeaderId", HReqID);
}

Sunday, December 30, 2018

Oracle OAF : Calling PLSQL Procedure From OAF

Controller
========================================

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
          OAApplicationModule am = pageContext.getApplicationModule(webBean);
          if (pageContext.getParameter("item3") != null)       
           {         
                Serializable[] ParamAddValues = { pageContext.getParameter("item1"),
   pageContext.getParameter("item2")};
                             
            String retSumValue = (String)am.invokeMethod("AddNumber", ParamAddValues);
            String message = "Sum:  " + retSumValue;                   
            throw new OAException(message, OAException.INFORMATION);
            }
  }
 

Application Module
========================================

import java.sql.CallableStatement;
import java.sql.SQLException;
import oracle.apps.fnd.framework.OAException; 
 
public String AddNumber(String item1,String item2)
    {
    OADBTransaction oadbtransaction = (OADBTransaction)getTransaction();
        OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)getTransaction();
        String retValues;
        StringBuffer 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;
    }