Business Requirement:
Collection Field (REGION and COUNTRY) has below values:
EMEA Armenia
APAC China
Global blank
I have a requirement in the collection to find if the region value is "Global" to issue an error :
import com.sap.odp.api.doccommon.masterdata.*;
import com.sap.odp.api.ibean.common.AbsExtensionCollection.*;
import com.sap.odp.common.db.metadata.*;
geoCol = doc.getExtensionCollection("COLLGEOGRAPHY");
// New collection entries are captured in the below variables
if (!(geoCol.size() == 0)) {
geography = geoCol.get(0);
regionNew = geography.get("REGION");
countryNew = geography.get("GEOCOUNTRY");
}
set = new HashSet();
iter = geoCol.iterator();
while(iter.hasNext())
{
nextItem = iter.next();
region = nextItem.get("REGION");
country = nextItem.get("GEOCOUNTRY");
// If the region is blank mandate region
if(! (hasValue(region))) {
throw doc.createApplicationException("COLLGEOGRAPHY", "PROJERROR_REGION_BLANK");
}
// Error for duplicate countries
if (!set.add(country)) {
throw doc.createApplicationException("COLLGEOGRAPHY", "PROJERROR_REGION");
}
if ((regionNew.equals("Global"))) {
throw doc.createApplicationException("COLLGEOGRAPHY", "PROJERROR_COUNTRY_BLANK");
}
}
The last IF condition is not working in the above scenario how do I read a collection value?
Thanks,
Ramesh