Вы находитесь на странице: 1из 17

How to call SRS Window in OAF Controller PFR Code import oracle.apps.fnd.framework.webui.

OAUrl; StringBuffer l_buffer = new StringBuffer(); StringBuffer l_buffer1 = new StringBuffer(); l_buffer.append("javascript:mywin = openWindow(top, '"); l_buffer1.append("&akRegionApplicationId="+"0"); l_buffer1.append("&akRegionCode="+"FNDCPREQUESTVIEWPAGE"); l_buffer1.append("&retainAM=Y"); String url = "/OA_HTML/OA.jsp?page="+l_buffer1.toString(); OAUrl popupUrl = new OAUrl(url, OAWebBeanConstants.ADD_BREAD_CRUMB_SAVE ); String strUrl = popupUrl.createURL(pageContext); l_buffer.append(strUrl.toString()); l_buffer.append("', 'lovWindow', {width:750, height:550},false,'dialog',null);"); pageContext.putJavaScriptFunction("SomeName",l_buffer.toString());

How to return array from Application Module


Controller Code

1. 2. 3. 4. 5.
6. 7. 8.

import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Connection; import java.sql.PreparedStatement; import oracle.apps.fnd.framework.OAException; Serializable paras[] = {employee_id}; Object result[] = new Object[10]; // declaring result of Array Type result = (Object[])am.invokeMethod("getparameters", paras); // Calling AM Method String userid = (String)result[0]; // Capturing value from Array String userName = (String)result[1]; // Capturing value from Array

9. 10.
11.

12. 13.

Application Module Code

1.
2.

3. 4.
5.

public Object[] getparameters(String employeeid) { ResultSet resultset = null; int employee_id = Integer.parseInt(employeeid); Object result[] = new Object[10]; OADBTransaction oadbtransaction = getOADBTransaction(); Debug.write(oadbtransaction, this, "Employee id is " + employee_id, 1);

6.
7.

8.
9.

10.

try 11. { 12. Connection conn = getOADBTransaction().getJdbcConnection(); 13. String query = "sselect user_id, user_name from fnd_user where employee_id=:1"; 14. 15. PreparedStatement stmt = conn.prepareStatement(query); 16. stmt.setInt(1, employee_id); 17. 18. for(resultset = stmt.executeQuery(); resultset.next(); 19. { 20. 21. result[0] = resultset.getString("user_id");

22.
23.

Debug.write(oadbtransaction, this, "Project Number is " + result[0], 1); result[1] = resultset.getString("user_name");

24. 25.

Debug.write(oadbtransaction, this, "Project ClassCode is " + result[1], 1); 26. 27. } 28. } 29. 30. catch(Exception e) 31. 32. { 33. Debug.write(oadbtransaction, this, "Exception " + e.getMessage(), 1); 34. } 35. return result; // Returning result array to Controller 36. }

Important Profile Options in OAF


37. FND_Diagnostics
Setting the FND : Diagnostics (FND_DIAGNOSTICS) profile option to "Yes" will enable the diagnostics global button to be rendered on the screen. Pressing this button brings the user to an interface where the user can choose what type of logged messages to display. Personalization Levels Personalizations can be enabled at the function, site, operating unit or responsibility level. Personalizations at lower levels override personalizations at higher levels. Values inherit the definition from the level immediately above unless changed. FND: Personalization Region Link Enabled : Valid values: Yes - renders the "Personalize Region" links above each region in a page. Each link takes you first to the Choose Personalization Context page, then to the Page Hierarchy Personalization page with focus on the region node from which you selected the "Personalize Region" link. Personalize Self-Service Defn Set this profile to Yes to allow personalizations. Disable Self-Service Personalization - Yes will disable all personalizations at any level. FND: Personalization Document Root Path (new in 11.5.10) - Set this profile option to a tmp directory with open (777) permissions for migrating personalizations between instances. How to See Log on Page Enable profile Option FND_Diagnostics to "Yes" at User OR Site Level. In Controller write this code:pageContext.writeDiagnostics(this, "Checking profile options", 1); In Application Module write this code getOADBTransaction().writeDiagnostics(this, "Checking Profile Option", 1);

Now to see log on screen Click on Diagnostics on Page [Top right on page]

Then Choose Show Log on Screen from the picklist and choose log level as Statement Level and Click on Go

How to capute current row in Table Region


public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean); String event = pageContext.getParameter("event"); if ("").equals(event)) { // Get the identifier of the PPR event source row String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE); Serializable[] parameters = { rowReference }; // Pass the rowReference to a "handler" method in the application module. am.invokeMethod("", parameters); } } In your application module's "handler" method, add the following code to access the source row: OARow row = (OARow)findRowByRef(rowReference); if (row!=null) { }

How to compare two dates


import oracle.jbo.domain.Date; Date scoStartDate = null; Date scoEndDate = null; scoStartDate = (Date)rowi.getScoRoleStartDate(); // Capturing dates from RowImpl scoEndDate = (Date)rowi.getScoRoleEndDate(); // Capturing dates from RowImpl java.sql.Date javaSqlDate = scoStartDate.dateValue(); if (scoEndDate.dateValue().before(javaSqlDate)) { //throw Exception }

PreparedStatement In Controleer: 1. 2. 3.
4. import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet;

5.

try 6. 7. { 8. 9. 10. Connection conn = pageContext.getApplicationModule(webBean).getOADBTransaction().getJdb cConnection(); 11. 12. String Query = "SELECT count(*) count from XX_PA_SCO_V where project_id=:1 and CI_ID is no t null"; 13. 14. PreparedStatement stmt = conn.prepareStatement(Query); 15. stmt.setString(1, project_id);

16. for(ResultSet resultset = stmt.executeQuery(); resultset.next();)


17. { 18. pageContext.writeDiagnostics(this, "Query Executed", 1);

19. result = resultset.getInt("count");; 20. pageContext.writeDiagnostics(this, "Query Executed"+ result, 1);


21. } 22. } 23.

24. catch(Exception exception)


25. 26. { 27. throw new OAException("Error in Staffing Query"+exception, OAException.ERROR); 28. } 29. 30. if(result >0) 31. { 32. throw new OAException("One or more Scope Change Order is existing on this project", OAExce ption.INFORMATION); 33. }

CallbbleStatementsIn-Controller: view plaincopy to clipboardprint?

1.
2.

import java.sql.CallableStatement; import java.sql.Types; import oracle.apps.fnd.framework.OAApplicationModule; import oracle.apps.fnd.framework.OAException; import oracle.apps.fnd.framework.server.OADBTransaction;

3. 4.
5.

6. 7.
8.

9.

try 10. 11. { 12. Connection conn = (Connection)oapagecontext.getApplicationModule(oawebbean).getOADBTr ansaction().getJdbcConnection(); 13. 14. CallableStatement cs = conn.prepareCall("{call XX_UPDATE_SCO_DETAILS_PKG.SCO_ADD_ON_ WORK(?,?,?,?,?,?,?)}"); 15. 16. cs.setString(1, Proj_ID);

17. cs.setString(2, SCOID); 18. cs.setString(3, Assign_ID); 19. cs.setString(4, "ADD_NEW_RESOURCES"); 20. cs.setString(5, strStartDate); 21. cs.setString(6, strEndDate); 22. cs.registerOutParameter(7, Types.VARCHAR);
23. cs.execute(); 24. error_mess = cs.getString(7);

25. if(!StringUtils.isNullOrEmpty(error_mess))
26. { 27. throw new OAException("Error in saving data in custom table OR Updating LOE: "+error_mess) ; 28. } 29. conn.commit(); 30. cs.close(); 31. } 32. catch (SQLException sqle) 33. {

34. throw OAException.wrapperException(sqle);


35. } 36. Debug.log(oapagecontext, this, "Callabe Statement Executed", 3);

CreatingVo AtRunTimeInControllerrDynamicallyCreatedVO: ViewObject viewobject = oapagecontext.getApplicationModule(oawebbean).findViewObject("ObtainProjectId"); if(viewobject == null) { String s14 = "SELECT project_id FROM PA_PROJECTS_ALL WHERE segment1 =:1"; viewobject = oaapplicationmodule.createViewObjectFromQueryStmt("ObtainProjectId", s14); } viewobject.setWhereClauseParam(0, s5); viewobject.executeQuery(); int i = viewobject.getRowCount(); if(i != 1) { Debug.log(oapagecontext, this, "Error : Project Number is Invalid or not unique", 3); OAException oaexception4 = null; oaexception4 = new OAException("PA", "PA_PROJECT_NUMBER_INVALID"); oaexception4.setApplicationModule(oaapplicationmodule); throw oaexception4; } oracle.jbo.Row row = viewobject.last(); if(row != null) { Object obj2 = row.getAttribute(0); if(obj2 != null) { s3 = obj2.toString(); if(s3 != null) {

oapagecontext.putTransactionValue("paProjectId", s3); // Capturing projectid in Session if(oaapplicationmodule.findViewObject("AddNewAssignmentsVO") != null) { oaapplicationmodule.findViewObject("AddNewAssignmentVO").first().setAttribute("ProjectId", s3); } } } }

Getting And Setting Value: Capturing the value from VO and setting Explictiy in EO

import oracle.apps.fnd.framework.OAViewObject; import oracle.apps.fnd.framework.OARow; public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); OAApplicationModule am = pageContext.getApplicationModule(webBean); OAViewObject oaviewobject1 =(OAViewObject)am.findViewObject("NewEmployeeVO1"); if (oaviewobject1 != null) { System.out.println("Inside"); oaviewobject1.reset(); //New line added oaviewobject1.next(); //new line added OARow row = (OARow)oaviewobject1.getCurrentRow(); String fullName = (String)row.getAttribute("FullName"); OAViewObject vo1 = (OAViewObject)am.findViewObject("EmployeeEOVO1"); vo1.reset(); if (vo1 != null) { do { if(!vo1.hasNext()) break; vo1.next(); EmployeeEOVORowImpl lcerl = (EmployeeEOVORowImpl)vo1.getCurrentRow(); lcerl.setFullName(fullName);

}while(true) } }

Convert Date TO String: view plaincopy to clipboardprint?

1. 2.
3. 4.

Date date = (Date)oaapplicationmodule.findViewObject("AddNewAssignmentVO").first().getAtt ribute("StartDate"); Date edate = (Date)oaapplicationmodule.findViewObject("AddNewAssignmentVO").first().getAt tribute("EndDate");

5.
6. 7. 8. 9.

if (date != null && edate != null) { String Xs11 = oapagecontext.getOANLSServices().dateToString(date); String Xs12 = oapagecontext.getOANLSServices().dateToString(edate); }

Change the date Format from YYYY-MM-DD to DD-MM-YYYY


In Controller import java.text.ParseException; import java.text.SimpleDateFormat; import java.text.DateFormat; import java.util.Date; String newProjStartDate,newProjEndDate, sConvertNewStartDate, sConvertNewEndDate = null; newProjStartDate= (String)pageContext.getSessionValue("newstartdate"); newProjEndDate= (String)pageContext.getSessionValue("newenddate"); try { DateFormat formatter ; Date date, date1, date2, date3; formatter = new SimpleDateFormat("yyyy-MM-dd");

date = formatter.parse(newProjStartDate); date1 = formatter.parse(newProjEndDate); pageContext.writeDiagnostics(this, "Anil date is =" + date, 1); pageContext.writeDiagnostics(this, "Anil date1 is =" + date1, 1); SimpleDateFormat formatterNew = new SimpleDateFormat("dd-MMM-yyyy"); sConvertNewStartDate=formatterNew.format(date); sConvertNewEndDate=formatterNew.format(date1); pageContext.writeDiagnostics(this, "sConvertStartDate date is =" + sConvertNewStartDate, 1); pageContext.writeDiagnostics(this, "sConvertEndDate date1 is =" + sConvertNewEndDate, 1); } catch (ParseException e) { throw new IllegalArgumentException("Encountered Date format error "+ e); }

Conver String TO Date:


oapagecontext.getOANLSServices().stringToDate("xxxx"); Creating messagechoice in programatacally:

1.
2.

3. 4.
5.

public void processRequest(OAPageContext pageContext, OAWebBean webBean) { super.processRequest(pageContext, webBean); String sMode = "test"; OAApplicationModule am = pageContext.getApplicationModule(webBean); OAViewObject oaviewobject = (OAViewObject)am.findViewObject("xxScoResourceVO1");

6. 7.
8.

if(oaviewobject == null) { 9. oaviewobject = (OAViewObject)am.createViewObject("xxScoResourceVO1","xx.oracle.apps.pa. poplist.server.testVO"); 10. } 11. 12. oaviewobject.setWhereClause("DESCRIPTION IS NULL OR DESCRIPTION = '" + sMode + "'"); //S etting where clause Dynamically of Poplist VO 13. 14. oaviewobject.executeQuery(); 15. OAMessageChoiceBean oamessagechoicebean = (OAMessageChoiceBean)createWebBean(pag eContext, "MESSAGE_POPLIST"); 16. oamessagechoicebean.setPrompt("Back"); 17. oamessagechoicebean.setListViewObject(pageContext, oaviewobject); 18. oamessagechoicebean.setListDisplayAttribute("Meaning");

19. oamessagechoicebean.setListValueAttribute("LookupCode");
20.

21. oamessagechoicebean.setName("xxAddAsgmtApplyAction"); 22. oamessagechoicebean.setAllowBlankValue(false); 23. oamessagechoicebean.setDefaultValue("RETURN_BACK"); //Setting Default Value


24. webBean.addIndexedChild(oamessagechoicebean); 25. }

26. 27. How to capture its Value 28. 29. String PoplistValue = oapagecontext.getParameter("xxAddAsgmtApplyAction");

OABEEAN Hide imageBeen import oracle.apps.fnd.framework.webui.beans.OAImageBean; import oracle.apps.fnd.framework.OAViewObject; import oracle.apps.fnd.framework.OARow; public void processRequest(OAPageContext pageContext, OAWebBean webBean) { super.processRequest(pageContext, webBean); OAApplicationModule am = pageContext.getApplicationModule(webBean); String userid = pageContext.getUserId()+""; if (userid.equals(pageContext.getUserId()+"")); { OAViewObject oaviewobject1 =(OAViewObject)am.findViewObject("EmployeeEOVO1"); OAViewObject svo =(OAViewObject)am.findViewObject("StatusPVO1"); OARow row1 = (OARow)svo.first(); if (oaviewobject1 != null) { System.out.println("Inside"); oaviewobject1.reset(); //New line added oaviewobject1.next(); //new line added OARow row = (OARow)oaviewobject1.getCurrentRow(); String fullName = (String)row.getAttribute("Attribute1"); if (fullName.equals("A")) { OAImageBean imagebean = (OAImageBean)webBean.findChildRecursive("approved"); OAImageBean imagebean1 = (OAImageBean)webBean.findChildRecursive("rejected"); OAImageBean imagebean2 = (OAImageBean)webBean.findChildRecursive("inProcess");

imagebean.setRendered(true); imagebean1.setRendered(false); imagebean2.setRendered(false); } else if (email.equals("R")) { OAImageBean imagebean = (OAImageBean)webBean.findChildRecursive("approved"); OAImageBean imagebean1 = (OAImageBean)webBean.findChildRecursive("rejected"); OAImageBean imagebean2 = (OAImageBean)webBean.findChildRecursive("inProcess"); imagebean.setRendered(false); imagebean1.setRendered(true); imagebean2.setRendered(false); } else if (email.equals("W")) { OAImageBean imagebean = (OAImageBean)webBean.findChildRecursive("approved"); OAImageBean imagebean1 = (OAImageBean)webBean.findChildRecursive("rejected"); OAImageBean imagebean2 = (OAImageBean)webBean.findChildRecursive("inProcess"); imagebean.setRendered(false); imagebean1.setRendered(false); imagebean2.setRendered(true); } else { System.out.println("Inside ELSE"); OAImageBean imagebean = (OAImageBean)webBean.findChildRecursive("approved"); OAImageBean imagebean1 = (OAImageBean)webBean.findChildRecursive("rejected"); OAImageBean imagebean2 = (OAImageBean)webBean.findChildRecursive("inProcess"); imagebean.setRendered(false); imagebean1.setRendered(false); imagebean2.setRendered(false); } } } }