Total Pageviews

Saturday 12 December 2020

Raise bundle exceptions using raiseBundledOAAttrValException with example in OAF

package xx.oracle.apps.icx.por.rcv.webui;
import com.sun.java.util.collections.ArrayList;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAAttrValException;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.OAWebBeanTable;
import oracle.apps.icx.por.rcv.server.ReturnItemsVOImpl;
import oracle.apps.icx.por.rcv.webui.RtnSrchCO;
import oracle.jbo.Row;

public class XXRtnSrchCO6 extends RtnSrchCO
{
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
pageContext.writeDiagnostics(this, "Dbg : XXRtnSrchCO Start Process From Request ",1);

OAApplicationModule am = pageContext.getApplicationModule(webBean);
ReturnItemsVOImpl vo1 = (ReturnItemsVOImpl)am.findViewObject("ReturnItemsVO");

String str1 = null;
String str2 = null;
String str3 = null;
String usrId = null;

try
{
str1 = pageContext.getParameter("event");
}
catch(Exception e)
{
pageContext.writeDiagnostics(this, "Dbg : Exception at str1 "+e,1);
}

try
{
str2 = pageContext.getParameter("value");
}
catch(Exception e)
{
pageContext.writeDiagnostics(this, "Dbg : Exception at str2 "+e,1);
}

try
{
str3 = pageContext.getParameter("source");
}
catch(Exception e)
{
pageContext.writeDiagnostics(this, "Dbg : Exception at str3 "+e,1);
}

try
{
usrId = ""+pageContext.getUserId();
}
catch(Exception e)
{
pageContext.writeDiagnostics(this, "Dbg : Exception at usrId "+e,1);
}

pageContext.writeDiagnostics(this, "Dbg : usrId "+usrId,1);
pageContext.writeDiagnostics(this, "Dbg : str1 "+str1,1);
pageContext.writeDiagnostics(this, "Dbg : str2 "+str2,1);
pageContext.writeDiagnostics(this, "Dbg : str3 "+str3,1);

if (("goto".equals(str1)) && ("NavigationBar".equals(str3)) && ("2".equals(str2)))
{
pageContext.writeDiagnostics(this, "Dbg : Next button pressed. ",1);

Object rtnSrchVoName = (String)pageContext.getTransactionValue("RtnSrchVOName");
pageContext.writeDiagnostics(this, "Dbg : rtnSrchVoName "+(String)rtnSrchVoName, 1);

OAWebBeanTable resultsTblBean = (OAWebBeanTable)webBean.findIndexedChildRecursive("ResultsTableRN");

if (resultsTblBean != null)
{
pageContext.writeDiagnostics(this, "Dbg : resultsTblBean Entered", 1);

resultsTblBean.setViewUsageName((String)rtnSrchVoName);
OAViewObject rtnSrchVO = (OAViewObject)am.findViewObject((String)rtnSrchVoName);

if(rtnSrchVO!=null)
{
Row[] headrRow = rtnSrchVO.getAllRowsInRange();

pageContext.writeDiagnostics(this, "Dbg : Length of rtnSrchVO rows is "+headrRow.length, 1);
ArrayList errMsg = new ArrayList();

if(headrRow.length >0)
{
for (int j = 0; j < headrRow.length; j++)
{
Row currRow = headrRow[j];
oracle.jbo.domain.Number returnQty = null;

try
{
returnQty = (oracle.jbo.domain.Number)currRow.getAttribute("ReturnQuantity");
}
catch (Exception ex)
{
pageContext.writeDiagnostics(this,"Dbg : returnQty Exception "+ex,1);
}

pageContext.writeDiagnostics(this,"Dbg : returnQty "+returnQty,1);

if(returnQty!=null)
{
String query4 = "select xx_rcpt_oaf_pkg.is_rcpt_qty_elig(:1) from dual";
String isValidDecimal =null;

try
{
PreparedStatement pStmt = am.getOADBTransaction().createPreparedStatement(query4, 1);
pStmt.setString(1,returnQty.toString());

for(ResultSet rs = pStmt.executeQuery(); rs.next();)
{
if(rs != null)
{
isValidDecimal = rs.getString(1);
}
}

pStmt.close();
}
catch(Exception e)
{
pageContext.writeDiagnostics(this,"Dbg : isValidDecimal Exception "+e,1);
}

pageContext.writeDiagnostics(this,"Dbg : isValidDecimal "+isValidDecimal,1);

if(isValidDecimal!=null && isValidDecimal.length()>0 && isValidDecimal.equalsIgnoreCase("Y"))
{
pageContext.writeDiagnostics(this,"Dbg : Only 2 Decimal places are allowed at Receipt Quantity ",1);
OAAttrValException ex1 = new OAAttrValException(111,rtnSrchVO.getFullName(),currRow.getKey(),"ReturnQuantity",returnQty,"XX","XX_RCPT_QTY_DCML_MSG", null, (byte)0);
errMsg.add(ex1);
}
}
}

if (errMsg.size()> 0)
{
  pageContext.writeDiagnostics(this,"Dbg : Throwing Bundle exceptions     ",1);
  OAAttrValException.raiseBundledOAAttrValException(errMsg);
}
}
}
}
}
pageContext.writeDiagnostics(this, "Dbg : XXRtnSrchCO Process From Request End",1);
super.processFormRequest(pageContext, webBean);
}

}

No comments:

Post a Comment