This discussion is archived
7 Replies Latest reply: Jan 22, 2013 7:01 AM by ac4991 RSS

Problem: EO based VO not saving VO data in database

ac4991 Newbie
Currently Being Moderated
Hi Experts!

For a shocker and contradiction to the concepts and theory of OAF, something strange and wierd i came across. I got an EO based VO, which got some data (i've confirmed this by debugging) is not saving the data to database on "apply". By apply i mean .. getTransaction().commit();

This is something which violates completely with the theories, so i've no clues about it. Can anyone suggest something !!
I mean, how to trace the functionality and resolve the issue?

Regards
Ari :)
  • 1. Re: Problem: EO based VO not saving VO data in database
    Sushant Sharma Expert
    Currently Being Moderated
    Hi,

    Can you please share your code that you are using to initialize your VO while creating a new row ?

    --Sushant                                                                                                                                                                                                                                           
  • 2. Re: Problem: EO based VO not saving VO data in database
    ac4991 Newbie
    Currently Being Moderated
    Hi sushant!

    Yeah sure!!

    Here it follows: It is an AM method..

    /**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);
    }
    }

    Regards
    Ari :)
  • 3. Re: Problem: EO based VO not saving VO data in database
    ac4991 Newbie
    Currently Being Moderated
    Hi Sushant!

    Any updates??

    Regards
    Ari :)
  • 4. Re: Problem: EO based VO not saving VO data in database
    PreethamChandra Journeyer
    Currently Being Moderated
    Same here.

    I have EO Based VO.

    getOADBTransaction().commit(); not committing any data.
  • 5. Re: Problem: EO based VO not saving VO data in database
    PreethamChandra Journeyer
    Currently Being Moderated
    Hey,

    Try commenting --> row.setNewRowState(Row.STATUS_INITIALIZED);

    See if it works
  • 6. Re: Problem: EO based VO not saving VO data in database
    JayaManasa Newbie
    Currently Being Moderated
    As suggested by preetam please try commenting setNewRowState(Row.STATUS_INITIALIZED)

    also check if ur import class is import oracle.apps.fnd.framework.server.OADBTransaction;

    Thanks,
    Jaya
  • 7. Re: Problem: EO based VO not saving VO data in database
    ac4991 Newbie
    Currently Being Moderated
    Hey guyz,

    I'm sorry to post it lately(as i was wondering if some1 was following the thread or not?) .. Anywayz :)

    I've found 'A' solution, as i dunno if this is the only one or not, but it worked for me.

    I changed row.setNewRowState(Row.STATUS_INITIALIZED) to row.setNewRowState(Row.STATUS_NEW) and it was working picture perfect for me.

    Regards
    Ari :)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points