How to Find Duplicate Row in OAF Page?
How to Find Duplicate Row in OAF Page?
In this article, I have explained how to stop user to enter duplicate rows in OAF Page table region or advanced table region. This validation helps the users not to enter any duplicate record into system. Below method should be created in AM (Application Module) and it can be referred from CO.
Below method is used to compare rows from same VO Object with different VO instance. (mainVO and Subvo).
public void XXDuplicateVendorCharges() { OAViewObject mainVO = getXXVendorChargesEOVO1(); OAViewObject Subvo = getXXVendorChargesEOVO1(); for (Row row = mainVO.first(); row != null; row = mainVO.next()) { Number mainVOVendorChargesId = (Number)row.getAttribute("VendorChargesId"); String mainChrgType = (String)row.getAttribute("VendorChargeType"); for (Row row1 = Subvo.first(); row1 != null; row1 = Subvo.next()) { Number SubvoVendorChargesId = (Number)row1.getAttribute("VendorChargesId"); String SubChrgType = (String)row1.getAttribute("VendorChargeType"); if (!(mainVOVendorChargesId.equals(SubvoVendorChargesId))) { if ((mainChrgType).equals(SubChrgType)) { //Subvo.remove(); //remove the Child VO //getTransaction().commit(); // This performs the actual delete. throw new OAException("Duplicate row exists in Vendor Charges, select only unique Vendor Charge Type.", OAException.ERROR); } } } //SubVO } //MainVO mainVO.first(); Subvo.clearCache(); }
Another Method to check duplicate from DB Object like below.
public void XXDuplicateVendorCharges() { OAViewObject VendorHdrVO = getXXVendorHeaderEOVO1(); Row VendorHdrRow = VendorHdrVO.getCurrentRow(); try { if (VendorHdrRow != null) { VendorHdrId = (Number)VendorHdrVO.getAttribute("VendorHdrId"); } } catch (Exception exec) { throw new OAException("Error: " + exec, OAException.ERROR); } OAViewObject mainVO = getXXVendorChargesEOVO1(); XXVendorChargesEOVOImpl Subvo = (XXVendorChargesEOVOImpl)this.findViewObject("getXXVendorChargesEOVO2"); //Child VO for duplicate checking if (Subvo == null) { Subvo = (XXVendorChargesEOVOImpl)this.createViewObject("getXXVendorChargesEOVO2", "xxerp.oracle.apps.po.customapp.server.XXVendorChargesEOVO"); } Subvo.clearCache(); if (!(Subvo.isPreparedForExecution())) { Subvo.setWhereClause(null); Subvo.setWhereClause("VENDOR_HDR_ID= " + "'" + VendorHdrId + "'"); Subvo.executeQuery(); } for (Row row = mainVO.first(); row != null; row = mainVO.next()) { Number mainVOVendorChargesId = (Number)row.getAttribute("VendorChargesId"); String mainChrgType = (String)row.getAttribute("VendorChargeType"); for (Row row1 = clonevo.first(); row1 != null; row1 = Subvo.next()) { Number SubvoVendorChargesId = (Number)row1.getAttribute("VendorChargesId"); String SubChrgType = (String)row1.getAttribute("VendorChargeType"); if (!(mainVOVendorChargesId.equals(SubvoVendorChargesId))) { if ((mainChrgType).equals(SubChrgType)) { //Subvo.remove(); //remove the Child VO //getTransaction().commit(); // This performs the actual delete. throw new OAException("Duplicate row exists in Vendor Charges, select only unique Vendor Charge Type.", OAException.ERROR); } } } //Subvo } //MainVO mainVO.first(); Subvo.remove(); }
Leave a Reply
Want to join the discussion?Feel free to contribute!