Wednesday, 24 June 2015

Update, Insert & Delete Records in OAF in oracle apps

Pre-Requisite
Do complete the following exercises

Step 1: Create Delete Icon for Delete Action
Select SearchPG.xml
Right click on SearchTable -> New -> Item


Update the Properties
Attribute
Property
ID
Delete
Item Style
image
Atribute Set
/oracle/apps/fnd/attributesets/Buttons/Delete
Prompt
Update
Image URI
deleteicon_enabled.gif
Additional Text
Delete record
Height
24
Width
24
Action Type
fireAction
Event
delete
Submit
TRUE
Parameters
Name
Value
PPersonType
${oa.SearchVO.PersonType}
PPersonName
${oa.SearchVO.PersonName}
PEmailAddresss
${oa.SearchVO.EmailAddresss}
PContactNumber
${oa.SearchVO.ContactNumber}
  

Step 2: Add the below code in SearchAMImpl.java
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.jbo.domain.Number;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import oracle.jbo.RowSetIterator;
public void deleteRecord()
{
OAViewObject vo = getSearchVO();
SearchVORowImpl row = null;
int fetchedRowCount = vo.getFetchedRowCount();
RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");
if (fetchedRowCount > 0)
{  deleteIter.setRangeStart(0); 
 deleteIter.setRangeSize(fetchedRowCount);
 for (int i = 0; i < fetchedRowCount; i++)
{
  row = (SearchVORowImpl)deleteIter.getRowAtRangeIndex(i);
  row.remove();
  getTransaction().commit();
  break;
}
}
deleteIter.closeRowSetIterator();
}
Step 3: Add the below code in SearchCO.java
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean;
import com.sun.java.util.collections.HashMap;
import oracle.apps.fnd.framework.webui.OADialogPage;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OARow;
import oracle.apps.fnd.framework.OAApplicationModule;
Add the below code in processFormRequest
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
OAViewObject vo =(OAViewObject)am.findViewObject("SearchVO");
String rowRef =
pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
OARow row = (OARow)am.findRowByRef(rowRef);
if ("delete".equals(pageContext.getParameter(EVENT_PARAM)))
{
OAException message = new OAException("Are you sure you want to delete this row?",OAException.WARNING); 
pageContext.putDialogMessage(message);
OADialogPage dialogPage = new OADialogPage(OAException.WARNING, message, null, "", "");
String yes = pageContext.getMessage("AK", "FWK_TBX_T_YES", null);
String no = pageContext.getMessage("AK", "FWK_TBX_T_NO", null);
dialogPage.setOkButtonItemName("DeleteYesButton");
dialogPage.setOkButtonToPost(true);
dialogPage.setNoButtonToPost(true);
dialogPage.setPostToCallingPage(true);
dialogPage.setOkButtonLabel(yes);
dialogPage.setNoButtonLabel(no);
pageContext.redirectToDialogPage(dialogPage);
}
else if (pageContext.getParameter("DeleteYesButton") != null)
{
am.invokeMethod("deleteRecord", null);
OAException confirmation = new OAException("Record deleted Successfully", OAException.CONFIRMATION);
pageContext.putDialogMessage(confirmation);
}
Step 4: Save all your work and Run the SearchPG.xml

Step 5: Delete a Record

1 comment:

  1. Why 1.Are you sure you want to delete this row? is appearing again on search page?

    ReplyDelete