Hi Friends,
After a long break again am shifted to my mother platform. Here am sharing a very common requirement in i procurement like copying the Requisition header DFF's to Distribution level DFFs using simple controller class extension.
Scenario:
Once User enter the requisition details and when he navigate to end of the transaction page (Review Submit Page--In train region last page of the I-Procurement) when he click on the SUBMIT button. we have to copy the Requisition header DFFs to Distribution level DFFs.
Use the below code to fix or fulfill the above requirement.
package xxxxxx.oracle.apps.icx.por.webui;
import oracle.apps.fnd.common.VersionInfo;
import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.icx.por.req.server.RequisitionAMImpl;
import oracle.apps.icx.por.req.webui.ReviewSubmitCO;
import oracle.apps.icx.por.req.server.PoRequisitionLinesVORowImpl;
import oracle.jbo.RowSetIterator;
import oracle.jbo.ViewObject;
/**
* Controller for ...extending the ReviewSubmitCO to copy the PO Requisition Header DFF values to Distribution Level DFFS.
*/
public class XXXReviewSubmitCO extends ReviewSubmitCO {
public static final String RCS_ID = "$Header$";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
/**
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
super.processRequest(pageContext, webBean);
}
/**
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
String s = pageContext.getParameter("_FORM_SUBMIT_BUTTON");
PoRequisitionLinesVORowImpl currentLineRow = null;
int noOfDistRows=0;
int noOfCatRows=0;
int noOfLines = 0;
String noOfLines_currentReqLineID = null;
String categoryValue =null;
String categoryQuery =null;
String mtlcategoryVOs = null;
String distributionVOs = null;
if ("SubmitButton".equals(s))
{
RequisitionAMImpl am = (RequisitionAMImpl)pageContext.getApplicationModule(webBean);
OAViewObject reqHeadersVO = (OAViewObject)am.findViewObject("PoRequisitionHeadersVO");
OAViewObject reqLinesVO = (OAViewObject)am.findViewObject("PoRequisitionLinesVO");
Row headerRow = reqHeadersVO.getCurrentRow();
oracle.jbo.domain.Number reqHeaderId = (oracle.jbo.domain.Number)headerRow.getAttribute("RequisitionHeaderId");
String reqHeaderValue = reqHeaderId.toString();
if(reqHeaderValue != null)
{
reqLinesVO.setWhereClause(null);
reqLinesVO.setWhereClause("REQUISITION_HEADER_ID = "+reqHeaderValue);
reqLinesVO.executeQuery();
noOfLines = reqLinesVO.getRowCount();
RowSetIterator lineSelectIter = reqLinesVO.createRowSetIterator("lineSelectIter");
mtlcategoryVOs = "NewCat"+reqHeaderValue+"NewCat";
distributionVOs = "NewDist"+reqHeaderValue+"NewDist";
ViewObject mtlCategoriesVO = am.createViewObjectFromQueryClauses(mtlcategoryVOs,
null,
"c.ATTRIBUTE2",
"mtl_categories_b c,"+
"po_requisition_lines_all b",
" b.category_id (+) = c.category_id",
null);
ViewObject distributionVO = am.createViewObjectFromQueryClauses(distributionVOs,
"oracle.apps.icx.por.schema.server.PoReqDistributionEO",
"PoReqDistributionEO.DISTRIBUTION_ID,"
+"PoReqDistributionEO.LAST_UPDATE_DATE,"
+"PoReqDistributionEO.LAST_UPDATED_BY,"
+"PoReqDistributionEO.REQUISITION_LINE_ID,"
+"PoReqDistributionEO.LAST_UPDATE_LOGIN,"
+"PoReqDistributionEO.CREATION_DATE,"
+"PoReqDistributionEO.CREATED_BY,"
+"PoReqDistributionEO.DISTRIBUTION_NUM,"
+"PoReqDistributionEO.SET_OF_BOOKS_ID,"
+"PoReqDistributionEO.CODE_COMBINATION_ID,"
+"PoReqDistributionEO.REQ_LINE_QUANTITY,"
+"PoReqDistributionEO.ENCUMBERED_FLAG,"
+"PoReqDistributionEO.GL_ENCUMBERED_DATE,"
+"PoReqDistributionEO.GL_ENCUMBERED_PERIOD_NAME,"
+"PoReqDistributionEO.GL_CANCELLED_DATE,"
+"PoReqDistributionEO.FAILED_FUNDS_LOOKUP_CODE,"
+"PoReqDistributionEO.ENCUMBERED_AMOUNT,"
+"PoReqDistributionEO.BUDGET_ACCOUNT_ID,"
+"PoReqDistributionEO.ACCRUAL_ACCOUNT_ID,"
+"PoReqDistributionEO.VARIANCE_ACCOUNT_ID,"
+"PoReqDistributionEO.PREVENT_ENCUMBRANCE_FLAG,"
+"PoReqDistributionEO.ATTRIBUTE_CATEGORY,"
+"PoReqDistributionEO.ATTRIBUTE1,"
+"PoReqDistributionEO.ATTRIBUTE2,"
+"PoReqDistributionEO.ATTRIBUTE3,"
+"PoReqDistributionEO.ATTRIBUTE4,"
+"PoReqDistributionEO.ATTRIBUTE5,"
+"PoReqDistributionEO.ATTRIBUTE6,"
+"PoReqDistributionEO.ATTRIBUTE7,"
+"PoReqDistributionEO.ATTRIBUTE8,"
+"PoReqDistributionEO.ATTRIBUTE9,"
+"PoReqDistributionEO.ATTRIBUTE10,"
+"PoReqDistributionEO.ATTRIBUTE11,"
+"PoReqDistributionEO.ATTRIBUTE12,"
+"PoReqDistributionEO.ATTRIBUTE13,"
+"PoReqDistributionEO.ATTRIBUTE14,"
+"PoReqDistributionEO.ATTRIBUTE15,"
+"PoReqDistributionEO.USSGL_TRANSACTION_CODE,"
+"PoReqDistributionEO.GOVERNMENT_CONTEXT,"
+"PoReqDistributionEO.REQUEST_ID,"
+"PoReqDistributionEO.PROGRAM_APPLICATION_ID,"
+"PoReqDistributionEO.PROGRAM_ID,"
+"PoReqDistributionEO.PROGRAM_UPDATE_DATE,"
+"PoReqDistributionEO.PROJECT_ID,"
+"PoReqDistributionEO.TASK_ID,"
+"PoReqDistributionEO.EXPENDITURE_TYPE,"
+"PoReqDistributionEO.PROJECT_ACCOUNTING_CONTEXT,"
+"PoReqDistributionEO.EXPENDITURE_ORGANIZATION_ID,"
+"PoReqDistributionEO.GL_CLOSED_DATE,"
+"PoReqDistributionEO.SOURCE_REQ_DISTRIBUTION_ID,"
+"PoReqDistributionEO.PROJECT_RELATED_FLAG,"
+"PoReqDistributionEO.EXPENDITURE_ITEM_DATE,"
+"PoReqDistributionEO.ORG_ID,"
+"PoReqDistributionEO.ALLOCATION_TYPE,"
+"PoReqDistributionEO.ALLOCATION_VALUE,"
+"PoReqDistributionEO.AWARD_ID,"
+"PoReqDistributionEO.END_ITEM_UNIT_NUMBER,"
+"PoReqDistributionEO.RECOVERABLE_TAX,"
+"PoReqDistributionEO.NONRECOVERABLE_TAX,"
+"PoReqDistributionEO.RECOVERY_RATE,"
+"PoReqDistributionEO.TAX_RECOVERY_OVERRIDE_FLAG,"
+"PoReqDistributionEO.OKE_CONTRACT_LINE_ID,"
+"PoReqDistributionEO.OKE_CONTRACT_DELIVERABLE_ID,"
+"PoReqDistributionEO.REQ_LINE_AMOUNT,"
+"PoReqDistributionEO.REQ_LINE_CURRENCY_AMOUNT,"
+"PoReqDistributionEO.REQ_AWARD_ID" ,
"PO_REQ_DISTRIBUTIONS_ALL PoReqDistributionEO",
null,
null);
RowSetIterator distSelectIter = distributionVO.createRowSetIterator("distSelectIter1");
RowSetIterator categorySelectIter = mtlCategoriesVO.createRowSetIterator("categorySelectIter");
if(noOfLines > 0)
{
lineSelectIter.setRangeStart(0);
lineSelectIter.setRangeSize(noOfLines);
for(int i = 0; i<noOfLines; i++)
{
currentLineRow = (PoRequisitionLinesVORowImpl)lineSelectIter.getRowAtRangeIndex(i);
oracle.jbo.domain.Number currentLine = (oracle.jbo.domain.Number)currentLineRow.getAttribute("RequisitionLineId");
String currentReqLineID = currentLine.toString();
noOfLines_currentReqLineID = noOfLines+currentReqLineID;
String wherecluse = "REQUISITION_LINE_ID = "+ currentReqLineID;
distributionVO.setWhereClause(wherecluse);
distributionVO.executeQuery();
mtlCategoriesVO.setWhereClause(" b.requisition_line_id = "+ currentReqLineID);
mtlCategoriesVO.executeQuery();
categoryQuery = mtlCategoriesVO.getQuery();
noOfDistRows = distributionVO.getRowCount();
noOfCatRows = mtlCategoriesVO.getRowCount();
if(noOfDistRows > 0 && noOfCatRows > 0)
{
distSelectIter.setRangeStart(0);
distSelectIter.setRangeSize(noOfDistRows);
categorySelectIter.setRangeStart(0);
categorySelectIter.setRangeSize(noOfCatRows);
for(int j = 0; j<noOfDistRows; j++)
{
for(int l = 0; l<noOfCatRows; l++)
{
Row currentDistRow = distSelectIter.getRowAtRangeIndex(j);
oracle.jbo.domain.Number distId = (oracle.jbo.domain.Number)currentDistRow.getAttribute("DISTRIBUTION_ID");
String distributionRowId = distId.toString();
String noOfDists = noOfDistRows +"..."+ distributionRowId;
Row currentCatRow = categorySelectIter.getRowAtRangeIndex(l);
categoryValue = (String)currentCatRow.getAttribute("ATTRIBUTE2");
String attribute3 = (String)headerRow.getAttribute("Attribute3");
String attribute2 = (String)headerRow.getAttribute("Attribute2");
String attribute15 = (String)headerRow.getAttribute("Attribute15");
currentDistRow.setAttribute("ATTRIBUTE3",attribute3);
currentDistRow.setAttribute("ATTRIBUTE2",attribute2);
currentDistRow.setAttribute("ATTRIBUTE4",categoryValue);
currentDistRow.setAttribute("ATTRIBUTE15",attribute15);
currentDistRow.setAttribute("ATTRIBUTE_CATEGORY","Context Value");
}//Category For Loop Close
}//Dist For Loop Close
}//dist if close*/
}//Line For Loop Close
}//Line if close
mtlCategoriesVO.remove();
distributionVO.remove();
}//header If close
}//submit button close
super.processFormRequest(pageContext, webBean);
}
}
After a long break again am shifted to my mother platform. Here am sharing a very common requirement in i procurement like copying the Requisition header DFF's to Distribution level DFFs using simple controller class extension.
Scenario:
Once User enter the requisition details and when he navigate to end of the transaction page (Review Submit Page--In train region last page of the I-Procurement) when he click on the SUBMIT button. we have to copy the Requisition header DFFs to Distribution level DFFs.
Use the below code to fix or fulfill the above requirement.
package xxxxxx.oracle.apps.icx.por.webui;
import oracle.apps.fnd.common.VersionInfo;
import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.icx.por.req.server.RequisitionAMImpl;
import oracle.apps.icx.por.req.webui.ReviewSubmitCO;
import oracle.apps.icx.por.req.server.PoRequisitionLinesVORowImpl;
import oracle.jbo.RowSetIterator;
import oracle.jbo.ViewObject;
/**
* Controller for ...extending the ReviewSubmitCO to copy the PO Requisition Header DFF values to Distribution Level DFFS.
*/
public class XXXReviewSubmitCO extends ReviewSubmitCO {
public static final String RCS_ID = "$Header$";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
/**
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
super.processRequest(pageContext, webBean);
}
/**
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
String s = pageContext.getParameter("_FORM_SUBMIT_BUTTON");
PoRequisitionLinesVORowImpl currentLineRow = null;
int noOfDistRows=0;
int noOfCatRows=0;
int noOfLines = 0;
String noOfLines_currentReqLineID = null;
String categoryValue =null;
String categoryQuery =null;
String mtlcategoryVOs = null;
String distributionVOs = null;
if ("SubmitButton".equals(s))
{
RequisitionAMImpl am = (RequisitionAMImpl)pageContext.getApplicationModule(webBean);
OAViewObject reqHeadersVO = (OAViewObject)am.findViewObject("PoRequisitionHeadersVO");
OAViewObject reqLinesVO = (OAViewObject)am.findViewObject("PoRequisitionLinesVO");
Row headerRow = reqHeadersVO.getCurrentRow();
oracle.jbo.domain.Number reqHeaderId = (oracle.jbo.domain.Number)headerRow.getAttribute("RequisitionHeaderId");
String reqHeaderValue = reqHeaderId.toString();
if(reqHeaderValue != null)
{
reqLinesVO.setWhereClause(null);
reqLinesVO.setWhereClause("REQUISITION_HEADER_ID = "+reqHeaderValue);
reqLinesVO.executeQuery();
noOfLines = reqLinesVO.getRowCount();
RowSetIterator lineSelectIter = reqLinesVO.createRowSetIterator("lineSelectIter");
mtlcategoryVOs = "NewCat"+reqHeaderValue+"NewCat";
distributionVOs = "NewDist"+reqHeaderValue+"NewDist";
ViewObject mtlCategoriesVO = am.createViewObjectFromQueryClauses(mtlcategoryVOs,
null,
"c.ATTRIBUTE2",
"mtl_categories_b c,"+
"po_requisition_lines_all b",
" b.category_id (+) = c.category_id",
null);
ViewObject distributionVO = am.createViewObjectFromQueryClauses(distributionVOs,
"oracle.apps.icx.por.schema.server.PoReqDistributionEO",
"PoReqDistributionEO.DISTRIBUTION_ID,"
+"PoReqDistributionEO.LAST_UPDATE_DATE,"
+"PoReqDistributionEO.LAST_UPDATED_BY,"
+"PoReqDistributionEO.REQUISITION_LINE_ID,"
+"PoReqDistributionEO.LAST_UPDATE_LOGIN,"
+"PoReqDistributionEO.CREATION_DATE,"
+"PoReqDistributionEO.CREATED_BY,"
+"PoReqDistributionEO.DISTRIBUTION_NUM,"
+"PoReqDistributionEO.SET_OF_BOOKS_ID,"
+"PoReqDistributionEO.CODE_COMBINATION_ID,"
+"PoReqDistributionEO.REQ_LINE_QUANTITY,"
+"PoReqDistributionEO.ENCUMBERED_FLAG,"
+"PoReqDistributionEO.GL_ENCUMBERED_DATE,"
+"PoReqDistributionEO.GL_ENCUMBERED_PERIOD_NAME,"
+"PoReqDistributionEO.GL_CANCELLED_DATE,"
+"PoReqDistributionEO.FAILED_FUNDS_LOOKUP_CODE,"
+"PoReqDistributionEO.ENCUMBERED_AMOUNT,"
+"PoReqDistributionEO.BUDGET_ACCOUNT_ID,"
+"PoReqDistributionEO.ACCRUAL_ACCOUNT_ID,"
+"PoReqDistributionEO.VARIANCE_ACCOUNT_ID,"
+"PoReqDistributionEO.PREVENT_ENCUMBRANCE_FLAG,"
+"PoReqDistributionEO.ATTRIBUTE_CATEGORY,"
+"PoReqDistributionEO.ATTRIBUTE1,"
+"PoReqDistributionEO.ATTRIBUTE2,"
+"PoReqDistributionEO.ATTRIBUTE3,"
+"PoReqDistributionEO.ATTRIBUTE4,"
+"PoReqDistributionEO.ATTRIBUTE5,"
+"PoReqDistributionEO.ATTRIBUTE6,"
+"PoReqDistributionEO.ATTRIBUTE7,"
+"PoReqDistributionEO.ATTRIBUTE8,"
+"PoReqDistributionEO.ATTRIBUTE9,"
+"PoReqDistributionEO.ATTRIBUTE10,"
+"PoReqDistributionEO.ATTRIBUTE11,"
+"PoReqDistributionEO.ATTRIBUTE12,"
+"PoReqDistributionEO.ATTRIBUTE13,"
+"PoReqDistributionEO.ATTRIBUTE14,"
+"PoReqDistributionEO.ATTRIBUTE15,"
+"PoReqDistributionEO.USSGL_TRANSACTION_CODE,"
+"PoReqDistributionEO.GOVERNMENT_CONTEXT,"
+"PoReqDistributionEO.REQUEST_ID,"
+"PoReqDistributionEO.PROGRAM_APPLICATION_ID,"
+"PoReqDistributionEO.PROGRAM_ID,"
+"PoReqDistributionEO.PROGRAM_UPDATE_DATE,"
+"PoReqDistributionEO.PROJECT_ID,"
+"PoReqDistributionEO.TASK_ID,"
+"PoReqDistributionEO.EXPENDITURE_TYPE,"
+"PoReqDistributionEO.PROJECT_ACCOUNTING_CONTEXT,"
+"PoReqDistributionEO.EXPENDITURE_ORGANIZATION_ID,"
+"PoReqDistributionEO.GL_CLOSED_DATE,"
+"PoReqDistributionEO.SOURCE_REQ_DISTRIBUTION_ID,"
+"PoReqDistributionEO.PROJECT_RELATED_FLAG,"
+"PoReqDistributionEO.EXPENDITURE_ITEM_DATE,"
+"PoReqDistributionEO.ORG_ID,"
+"PoReqDistributionEO.ALLOCATION_TYPE,"
+"PoReqDistributionEO.ALLOCATION_VALUE,"
+"PoReqDistributionEO.AWARD_ID,"
+"PoReqDistributionEO.END_ITEM_UNIT_NUMBER,"
+"PoReqDistributionEO.RECOVERABLE_TAX,"
+"PoReqDistributionEO.NONRECOVERABLE_TAX,"
+"PoReqDistributionEO.RECOVERY_RATE,"
+"PoReqDistributionEO.TAX_RECOVERY_OVERRIDE_FLAG,"
+"PoReqDistributionEO.OKE_CONTRACT_LINE_ID,"
+"PoReqDistributionEO.OKE_CONTRACT_DELIVERABLE_ID,"
+"PoReqDistributionEO.REQ_LINE_AMOUNT,"
+"PoReqDistributionEO.REQ_LINE_CURRENCY_AMOUNT,"
+"PoReqDistributionEO.REQ_AWARD_ID" ,
"PO_REQ_DISTRIBUTIONS_ALL PoReqDistributionEO",
null,
null);
RowSetIterator distSelectIter = distributionVO.createRowSetIterator("distSelectIter1");
RowSetIterator categorySelectIter = mtlCategoriesVO.createRowSetIterator("categorySelectIter");
if(noOfLines > 0)
{
lineSelectIter.setRangeStart(0);
lineSelectIter.setRangeSize(noOfLines);
for(int i = 0; i<noOfLines; i++)
{
currentLineRow = (PoRequisitionLinesVORowImpl)lineSelectIter.getRowAtRangeIndex(i);
oracle.jbo.domain.Number currentLine = (oracle.jbo.domain.Number)currentLineRow.getAttribute("RequisitionLineId");
String currentReqLineID = currentLine.toString();
noOfLines_currentReqLineID = noOfLines+currentReqLineID;
String wherecluse = "REQUISITION_LINE_ID = "+ currentReqLineID;
distributionVO.setWhereClause(wherecluse);
distributionVO.executeQuery();
mtlCategoriesVO.setWhereClause(" b.requisition_line_id = "+ currentReqLineID);
mtlCategoriesVO.executeQuery();
categoryQuery = mtlCategoriesVO.getQuery();
noOfDistRows = distributionVO.getRowCount();
noOfCatRows = mtlCategoriesVO.getRowCount();
if(noOfDistRows > 0 && noOfCatRows > 0)
{
distSelectIter.setRangeStart(0);
distSelectIter.setRangeSize(noOfDistRows);
categorySelectIter.setRangeStart(0);
categorySelectIter.setRangeSize(noOfCatRows);
for(int j = 0; j<noOfDistRows; j++)
{
for(int l = 0; l<noOfCatRows; l++)
{
Row currentDistRow = distSelectIter.getRowAtRangeIndex(j);
oracle.jbo.domain.Number distId = (oracle.jbo.domain.Number)currentDistRow.getAttribute("DISTRIBUTION_ID");
String distributionRowId = distId.toString();
String noOfDists = noOfDistRows +"..."+ distributionRowId;
Row currentCatRow = categorySelectIter.getRowAtRangeIndex(l);
categoryValue = (String)currentCatRow.getAttribute("ATTRIBUTE2");
String attribute3 = (String)headerRow.getAttribute("Attribute3");
String attribute2 = (String)headerRow.getAttribute("Attribute2");
String attribute15 = (String)headerRow.getAttribute("Attribute15");
currentDistRow.setAttribute("ATTRIBUTE3",attribute3);
currentDistRow.setAttribute("ATTRIBUTE2",attribute2);
currentDistRow.setAttribute("ATTRIBUTE4",categoryValue);
currentDistRow.setAttribute("ATTRIBUTE15",attribute15);
currentDistRow.setAttribute("ATTRIBUTE_CATEGORY","Context Value");
}//Category For Loop Close
}//Dist For Loop Close
}//dist if close*/
}//Line For Loop Close
}//Line if close
mtlCategoriesVO.remove();
distributionVO.remove();
}//header If close
}//submit button close
super.processFormRequest(pageContext, webBean);
}
}