call srs window from oaf

Upload: ashmitashrivas

Post on 04-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 call SRS window from OAF

    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 ModuleController Code

    1. import java.sql.ResultSet;

    2. import java.sql.SQLException;3. import java.sql.Connection;

    4. import java.sql.PreparedStatement;

    5. import oracle.apps.fnd.framework.OAException;6.7.8. Serializable paras[] = {employee_id};

    9. Object result[] = new Object[10]; // declaring result of Array Type10. result = (Object[])am.invokeMethod("getparameters", paras); // Calling AM Method11.

    12. String userid = (String)result[0]; // Capturing value from Array

    13. String userName = (String)result[1]; // Capturing value from Array

    http://oracleanil.blogspot.com/2009/04/custrespco-wf.htmlhttp://oracleanil.blogspot.com/2009/04/custrespco-wf.html
  • 7/29/2019 call SRS window from OAF

    2/17

    Application Module Code

    1. public Object[] getparameters(String employeeid)2. {

    3. ResultSet resultset = null;4. int employee_id = Integer.parseInt(employeeid);5.

    6. Object result[] = new Object[10];7. OADBTransaction oadbtransaction = getOADBTransaction();

    8. Debug.write(oadbtransaction, this, "Employee id is " + employee_id, 1);9.

    10. try11. {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. Debug.write(oadbtransaction, this, "Project Number is " + result[0], 1);23.

    24. result[1] = resultset.getString("user_name");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 Controller36. }

  • 7/29/2019 call SRS window from OAF

    3/17

    Important Profile Options in OAF37. FND_Diagnostics

    Setting the FND : Diagnostics (FND_DIAGNOSTICS) profile option to "Yes" will enable thediagnostics global button to be rendered on the screen. Pressing this button brings the user to aninterface 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 thedefinition 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. Eachlink takes you first to the Choose Personalization Context page, then to the Page HierarchyPersonalization page with focus on the region node from which you selected the "PersonalizeRegion" 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 tmpdirectory 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 Controllerwrite this code:-pageContext.writeDiagnostics(this, "Checking profile options", 1);

    In Application Module write this codegetOADBTransaction().writeDiagnostics(this, "Checking Profile Option", 1);

    http://oracleanil.blogspot.com/2009/04/itemrn.htmlhttp://oracleanil.blogspot.com/2009/04/itemrn.html
  • 7/29/2019 call SRS window from OAF

    4/17

    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 andClick on Go

    How to capute current row in Table Regionpublic 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 rowString 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){}

    http://oracleanil.blogspot.com/2009/04/serialco.htmlhttp://1.bp.blogspot.com/_kNYvUMH2rtU/S6G47nYfQaI/AAAAAAAAABA/F9E6tsymFJQ/s1600-h/Diagnostics.bmphttp://oracleanil.blogspot.com/2009/04/serialco.html
  • 7/29/2019 call SRS window from OAF

    5/17

    How to compare two datesimport oracle.jbo.domain.Date;

    Date scoStartDate = null;Date scoEndDate = null;

    scoStartDate = (Date)rowi.getScoRoleStartDate(); // Capturing dates from RowImplscoEndDate = (Date)rowi.getScoRoleEndDate(); // Capturing dates from RowImpl

    java.sql.Date javaSqlDate = scoStartDate.dateValue();

    if (scoEndDate.dateValue().before(javaSqlDate)){

    //throw Exception}

    PreparedStatement In Controleer:

    1. import java.sql.Connection;

    2. import java.sql.PreparedStatement;3. import java.sql.ResultSet;4.

    5. try6.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 not 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.

    http://oracleanil.blogspot.com/2009/04/itemco.htmlhttp://oracleanil.blogspot.com/2009/04/itemco.html
  • 7/29/2019 call SRS window from OAF

    6/17

    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. import java.sql.CallableStatement;2.

    3. import java.sql.Types;4. import oracle.apps.fnd.framework.OAApplicationModule;5.

    6. import oracle.apps.fnd.framework.OAException;

    7. import oracle.apps.fnd.framework.server.OADBTransaction;8.

    9. try10.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. {

    http://oracleanil.blogspot.com/2009/04/itemqueryvoxml.htmlhttp://oracleanil.blogspot.com/2009/04/itemqueryvoxml.htmlhttp://oracleanil.blogspot.com/2009/04/itemqueryvoxml.htmlhttp://oracleanil.blogspot.com/2009/04/itemqueryvoxml.htmlhttp://oracleanil.blogspot.com/2009/04/itemqueryvoxml.html
  • 7/29/2019 call SRS window from OAF

    7/17

    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){

  • 7/29/2019 call SRS window from OAF

    8/17

    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 addedoaviewobject1.next(); //new line addedOARow 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);

  • 7/29/2019 call SRS window from OAF

    9/17

    }while(true)}}

    Convert Date TO String:

    view plaincopy to clipboardprint?

    1. Date date = (Date)oaapplicationmodule.findViewObject("AddNewAssignmentVO").first().getAttribute("StartDate");

    2. Date edate = (Date)oaapplicationmodule.findViewObject("AddNewAssignmentVO").first().getAttribute("EndDate");

    3.4.

    5. if (date != null && edate != null)6. {7. String Xs11 = oapagecontext.getOANLSServices().dateToString(date);

    8. String Xs12 = oapagecontext.getOANLSServices().dateToString(edate);9. }

    Change the date Format from YYYY-MM-DD to DD-MM-YYYYIn 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");

    http://oracleanil.blogspot.com/2009/04/plsql.htmlhttp://oracleanil.blogspot.com/2009/04/globacodeco.htmlhttp://oracleanil.blogspot.com/2009/04/plsql.htmlhttp://oracleanil.blogspot.com/2009/04/plsql.htmlhttp://oracleanil.blogspot.com/2009/04/plsql.htmlhttp://oracleanil.blogspot.com/2009/04/plsql.htmlhttp://oracleanil.blogspot.com/2009/04/globacodeco.html
  • 7/29/2019 call SRS window from OAF

    10/17

    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. public void processRequest(OAPageContext pageContext, OAWebBean webBean)2. {

    3. super.processRequest(pageContext, webBean);4. String sMode = "test";5. OAApplicationModule am = pageContext.getApplicationModule(webBean);

    6. OAViewObject oaviewobject = (OAViewObject)am.findViewObject("xxScoResourceVO1");

    7. if(oaviewobject == null)8. {

    9. oaviewobject = (OAViewObject)am.createViewObject("xxScoResourceVO1","xx.oracle.apps.pa.poplist.server.testVO");

    10. }11.

    12. oaviewobject.setWhereClause("DESCRIPTION IS NULL OR DESCRIPTION = '" + sMode + "'"); //Setting where clause Dynamically of Poplist VO

    13.14. oaviewobject.executeQuery();

    15. OAMessageChoiceBean oamessagechoicebean = (OAMessageChoiceBean)createWebBean(pageContext, "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 Value24. webBean.addIndexedChild(oamessagechoicebean);25. }

  • 7/29/2019 call SRS window from OAF

    11/17

    26.27. How to capture its Value28.

    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 addedoaviewobject1.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");

  • 7/29/2019 call SRS window from OAF

    12/17

    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);

    }}}}

  • 7/29/2019 call SRS window from OAF

    13/17

  • 7/29/2019 call SRS window from OAF

    14/17

  • 7/29/2019 call SRS window from OAF

    15/17

  • 7/29/2019 call SRS window from OAF

    16/17

  • 7/29/2019 call SRS window from OAF

    17/17