Today I will show you how to use iterator for table rows to perform any validation.
For example you have to validate table rows for any duplicate item, and throw an error If any.
Below code will be written in AM
public String DuplicateRecords(String eid,Object invItemId)
{
RowSetIterator iter = getXX_InclusiveSuppliesVO1().createRowSetIterator("iter");
int i=1;
String returnString = "N";
while(iter.hasNext()) {
Row currRow = iter.next();
getOADBTransaction().writeDiagnostics(this,"inside DuplicateRecords:"+i,1);
i=i+1;
String currEid = (String)currRow.getAttribute("Eid");
Object itemIdObject = currRow.getAttribute("UniqueValue");
// String currInvItemId = (String)itemIdObject;
String itemNumber = (String)currRow.getAttribute("Item");
getOADBTransaction().writeDiagnostics(this," currEid:"+currEid+" itemIdObject:"+itemIdObject,1);
if (!(("").equals(currEid) ) && !(("").equals(itemIdObject) ))
{
if(currEid.equals(eid) && invItemId.equals(itemIdObject))
{
returnString = "The combination of same EID:"+eid+" and ITEM:"+itemNumber+" already available in Inclusive table";
break;
}
}
}
iter.closeRowSetIterator();
return returnString;
}
No comments:
Post a Comment