1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Unable to resolve stale data error in parent-child page structure.

Discussion in 'JAVA, SOA and Application Development' started by ac.arijit, Jan 15, 2013.

  1. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi Experts!

    I've got a master-detail page which consists of two VOs(EO based), Lets say
    1. MasterTableVO
    2. DetailTableVO

    This page contains two page buttons "Cancel" and "Apply" till here it works all fine & perfect[by that i mean creating, retrieving, querying etc etc.]

    But now i've created another page which is actually a child page of the above mentioned one.
    Here the user'll enter to view some default configured financial info or may also update the default settings manually.

    In this page, I've got only an advancedTable based on a VO(EO based), lets say
    3. PaymentsTableVO

    This page has only one page button "Ok" and which returns back to the parent page retaining the AM.

    All the three VOs are in the same AM. Functionally untill here also it looks fine, but when i finally apply the data it throws an error on getTransaction().commit();
    Error stack:
    OAF Error Unable to perform transaction on the record.
    Cause: The record contains stale data. The record has been modified by another user.
    Action: Cancel the transaction and re-query the record to get the new data.

    Plz reply ASAP.
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    This is the 'problem' with multi-user systems and Oracle's multi-versioning approach to returning consistent data -- transactions against data being read can be applied and committed so that a populated form is no longer current. This is the issue here; you may need to re-think your 'Ok' button and re-query the data during the button 'push'. I do not know if this is possible. Otherwise you will need to follow the instruct5ions provided in the error text.
     
  3. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi David!
    Thanks a ton for the response.. :)

    I'm not able to follow u properly, can u explain a li'l more in detail. If being specific ... plz try n clarify my instinctive queries that follows below:
    1. In this situation, have i commenced something wrong in the program which is causing this? If so, then what?
    2. How to resolve this problem? If the fwk behaves this way by design, then is there any workarounds?
    3. What exactly do u mean by
    Here's the childPGCO code:
    Code (Java):

    /*===========================================================================+
     |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |
     |                         All rights reserved.                              |
     +===========================================================================+
     |  HISTORY                                                                  |
     +===========================================================================*/

    package AmritTransportation.oracle.apps.po.Transportations.webui;

    import java.io.Serializable;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.webui.OADialogPage;
    import oracle.apps.fnd.framework.OAApplicationModule;
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import oracle.apps.fnd.framework.webui.OAControllerImpl;
    import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
    import oracle.apps.fnd.framework.webui.TransactionUnitHelper;
    import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;

    /**
     * Controller for ...
     */

    public class CostAllocationsPGCO extends OAControllerImpl
    {
      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);
        if (!pageContext.isBackNavigationFired(false))  {
            TransactionUnitHelper.startTransactionUnit(pageContext,"CreateTxnCosts");
            if (!pageContext.isFormSubmission())    {
                OAApplicationModule am = pageContext.getApplicationModule(webBean);
                OAMessageTextInputBean Amount = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("Amount");
                String TransportationNum = (String)pageContext.getParameter("pTransportationNum")
                      ,TransportationId = (String)pageContext.getParameter("pTransportationId")
                      ,LockedFlag = (String)pageContext.getParameter("pLockedFlag")
                      ,OrgId = (String)pageContext.getProfile("ORG_ID");
                Serializable[] param = {OrgId,TransportationId};
                if (LockedFlag.equals("N")) {
                    am.invokeMethod("DefineDefaultCosts",param);
                }
                else    {
                    am.invokeMethod("executeCosts",param);
                    Amount.setReadOnly(true);
                }
            }
        }
        else    {
            if (!TransactionUnitHelper.isTransactionUnitInProgress(pageContext,"CreateTxnCosts",true))  {
                OADialogPage dialogPage = new OADialogPage(NAVIGATION_ERROR);
                pageContext.redirectToDialogPage(dialogPage);
            }
        }
      }

      /**
       * 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)
      {
        super.processFormRequest(pageContext, webBean);
        OAApplicationModule am = pageContext.getApplicationModule(webBean);
        if (pageContext.getParameter("Ok") != null) {
            TransactionUnitHelper.endTransactionUnit(pageContext,"CreateTxnCosts");
            pageContext.forwardImmediately("OA.jsp?page=/AmritTransportation/oracle/apps/po/Transportations/webui/CreateTransportationPG&isChildPage=1"
                                        ,null
                                        ,OAWebBeanConstants.KEEP_MENU_CONTEXT
                                        ,null
                                        ,null
                                        ,true  
                                        ,OAWebBeanConstants.ADD_BREAD_CRUMB_YES);        
        }
      }

    }
     
    Is the objective or scenario clear to you? or else lemme know if not.
     
  4. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi David!

    Any updates? .. Plz reply ASAP. I'm stuck in the middle of the project, can't proceed without resolving this.
     
  5. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi!

    Here's the AM method DefineDefaultCosts()

    Code (Java):

    /**Custom public method to define default cost
    * allocation based on the pre-defined formula
    * for cost allocation keeping parity with the
    * corresponding delivery freight details
    */

    public void DefineDefaultCosts(String StrOrgId,String StrTransportationId) {
    OAViewObject vo = (OAViewObject)getAmritTransportationCreateVO1()
    ,vo1 = (OAViewObject)getAmritTransportationPaymentsVO1()
    ,vo2 = (OAViewObject)getAmritTransportDeliveryLinesVO1();
    OADBTransaction txn = getOADBTransaction();
    ArrayList debugMessage = new ArrayList();
    HashMap PartySet = new HashMap();
    Boolean PartyEntryValid = null;
    String TransportationNum = (String)vo.getCurrentRow().getAttribute("TransportationNum")
    ,CurrencyCode = (String)vo.getCurrentRow().getAttribute("CurrencyCode")
    ,EventType = "TRNSP DELIVERED",PeriodName = null;
    Date AccountingDate = (Date)vo.getCurrentRow().getAttribute("DateDelivered");
    Number Amount = (Number)vo.getCurrentRow().getAttribute("Amount")
    ,Rate = (Number)vo.getCurrentRow().getAttribute("Rate")
    ,TripId = (Number)vo.getCurrentRow().getAttribute("TripId")
    ,OrgId = null,TransportationId = null,CodeCombinationId = new Number(576773);
    int DlvryRowCount = vo2.getRowCount(),CostDistRowCount = vo1.getRowCount();
    if (CostDistRowCount == 0) {
    try {
    OrgId = new Number(StrOrgId);
    TransportationId = new Number(StrTransportationId);
    }catch (Exception e) {}
    //debugMessage.add(new OAException("Inherited Values: "TransportationId" "TransportationNum" "CurrencyCode" "EventType" "AccountingDate" "Amount" "Rate" "+OrgId));
    try {
    Connection Conn = txn.getJdbcConnection();
    String v$Script = "Select gp.period_name period\n" +
    "From gl_periods gp\n" +
    "Where upper(gp.period_set_name) = 'AMRIT_CALENDAR'\n" +
    "And gp.adjustment_period_flag = 'N'\n" +
    "And trunc(:1) between nvl(gp.start_date,trunc(sysdate))\n" +
    " and nvl(gp.end_date,trunc(sysdate))\n";
    PreparedStatement PreExecuteQuery = Conn.prepareStatement(v$Script);
    PreExecuteQuery.setDate(1,new java.sql.Date(AccountingDate.dateValue().getTime()));
    for (ResultSet QryOutputRS = PreExecuteQuery.executeQuery();QryOutputRS.next();) {
    PeriodName = QryOutputRS.getString("period");
    }
    v$Script = "Select attl.vendor_id vendorid\n" +
    " ,asp.vendor_name vendor \n" +
    "From apps.amrit_transport_trips att\n" +
    " ,apps.amrit_transport_trip_lines attl\n" +
    " ,ap.ap_suppliers asp\n" +
    "Where att.org_id = :1\n" +
    "And att.trip_id = :2\n" +
    "And att.enabled_flag = 'Y'\n" +
    "And trunc(sysdate) between nvl(att.start_date_active,trunc(sysdate))\n" +
    " and nvl(att.end_date_active,trunc(sysdate))\n" +
    "And attl.org_id = att.org_id\n" +
    "And attl.trip_id = att.trip_id\n" +
    "And attl.enabled_flag = 'Y'\n" +
    "And trunc(sysdate) between nvl(attl.start_date_active,trunc(sysdate))\n" +
    " and nvl(attl.end_date_active,trunc(sysdate))\n" +
    "And attl.location_type = 'HZ'\n" +
    "And asp.enabled_flag = 'Y'\n" +
    "And asp.vendor_id = attl.vendor_id\n" +
    "And trunc(sysdate) between nvl(asp.start_date_active,trunc(sysdate))\n" +
    " and nvl(asp.end_date_active,trunc(sysdate))\n";
    PreExecuteQuery = Conn.prepareStatement(v$Script);
    PreExecuteQuery.setInt(1,Integer.parseInt(OrgId.toString()));
    PreExecuteQuery.setInt(2,Integer.parseInt(TripId.toString()));
    for (ResultSet QryOutputRS = PreExecuteQuery.executeQuery();QryOutputRS.next();) {
    PartySet.put(QryOutputRS.getString("vendorid"),QryOutputRS.getString("vendor"));
    }
    }catch (Exception e) {}
    /* vo2.first();
    for (int i = 1;i <= DlvryRowCount;i++) {
    if (vo2.getCurrentRow().getAttribute("CancelFlag").equals("N")) {
    PartyEntryValid = PartySet.add((Number)vo2.getCurrentRow().getAttribute("VendorId"));
    //debugMessage.add(new OAException("Set VendorId: "+vo2.getCurrentRow().getAttribute("VendorId")));
    }
    vo2.next();
    } */

    //debugMessage.add(new OAException("PartySet: "+PartySet.entrySet()));
    for (Iterator iter = PartySet.entrySet().iterator();iter.hasNext();) {
    Map.Entry entry = (Map.Entry)iter.next();
    String VendorName = (String)entry.getValue();
    Number Cost = null;
    int PartyId = Integer.parseInt(entry.getKey().toString());
    float Qty = 0;
    try {
    vo2.first();
    for (int i = 1;i <= DlvryRowCount;i++) {
    //debugMessage.add(new OAException("VO VendorId: "vo2.getCurrentRow().getAttribute("VendorId")" Cancelled: "+vo2.getCurrentRow().getAttribute("CancelFlag")));
    if (vo2.getCurrentRow().getAttribute("CancelFlag").equals("N")) {
    int VendorId = Integer.parseInt(vo2.getCurrentRow().getAttribute("VendorId").toString());
    float Quantity = Integer.parseInt(vo2.getCurrentRow().getAttribute("Quantity").toString());
    if (PartyId == VendorId) {
    Qty+= Quantity;
    //debugMessage.add(new OAException("Quantities: "Quantity" "+Qty));
    }
    }
    vo2.next();
    }
    Qty*= Float.parseFloat(Rate.toString());
    Float totalQty = new Float(Qty);
    Cost = new Number(totalQty);
    }catch (Exception e) {}
    //debugMessage.add(new OAException("PartyId: "PartyId" VendorName: "VendorName" Cost: "Cost" EntryKey: "entry.getKey()" EntryValue: "+entry.getValue()));
    Row row = vo1.createRow();
    row.setAttribute("OrgId",OrgId);
    row.setAttribute("TransportationId",TransportationId);
    row.setAttribute("TransportationNum",TransportationNum);
    row.setAttribute("EventType",EventType);
    row.setAttribute("AccountingDate",AccountingDate);
    row.setAttribute("PeriodName",PeriodName);
    row.setAttribute("CodeCombinationId",CodeCombinationId);
    row.setAttribute("PartyId",PartyId);
    row.setAttribute("VendorName",VendorName);
    row.setAttribute("CurrencyCode",CurrencyCode);
    row.setAttribute("Amount",Cost);
    row.setAttribute("TransportationAmount",Amount);
    vo1.last();
    vo1.next();
    vo1.insertRow(row);
    row.setNewRowState(Row.STATUS_INITIALIZED);
    }
    vo1.first();
    vo2.first();
    OAException.raiseBundledOAException(debugMessage);
    }
    }
     
    Hope this helps..
     
  6. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi !
    Sorry to post it late. This issue is resolved.
     
  7. Nidhi25

    Nidhi25 Forum Genius

    Messages:
    81
    Likes Received:
    9
    Trophy Points:
    835
    Thanks. It was useful discussion.
     
  8. dmitrius

    dmitrius Guest

    How do you solve the issue?

    Thanks,
    Dmitry