I'm using the following code to read all the records from one file (fileVAL) with keys matching the key in another file (fileINF). Occasionally, I'll get records from fileVal that are greater than the search key. Not always. Most of the time, I'll get a null back from the readNextEqual() when the next record in the file has a higher value for the key. fileINF is set as unique(*yes) and fileVal is set as unique(*no). The key is defined as eight characters long, CCSID 37, collating sequence *HEX. The value is an ever incrementing 8-byte unsigned integer. Are there values where, perhaps when the low order byte is somewhere in the hex 00 to hex 20 range, that readNextEqual() will consider different values as equal?
fileINF.positionCursorBeforeFirst();
recordINF = fileINF.readNext();
if (recordINF != null) {
String result=null;
this.doAnother = !((String)(recordINF.getKeyFields()[0])).equals("**QUIT**");
if (doAnother){
this.doAnother=true;
Object[] keys = recordINF.getKeyFields();
String uniqueId = recordINF.getField(0).toString();
WorkpieceCreationInfo wpCreate = new WorkpieceCreationInfo(
recordINF.getField(1).toString().trim(),
recordINF.getField(2).toString().trim(),
recordINF.getField(3).toString().trim(),
recordINF.getField(4).toString().trim());
log.debug("FLOCWPINF read"+
"\n\t"+recordINF.getField(0).toString().trim()+
"\n\t"+recordINF.getField(1).toString().trim()+
"\n\t"+recordINF.getField(2).toString().trim()+
"\n\t"+recordINF.getField(3).toString().trim()+
"\n\t"+recordINF.getField(4).toString().trim());
{
Record recordVAL = null;
try {
fileVAL.positionCursorBefore(keys);
do {
recordVAL = fileVAL.readNextEqual(keys);
if (recordVAL != null) {
wpCreate.addValue(
recordVAL.getField(1).toString().trim(),
recordVAL.getField(2).toString().trim());
log.debug("FLOCWPVAL read"+
"\n\t"+recordVAL.getField(0).toString().trim()+
"\n\t"+recordVAL.getField(1).toString().trim()+
"\n\t"+recordVAL.getField(2).toString().trim());
}
} while (recordVAL != null);
} catch (AS400Exception e){
// nothing in the file for the key
}
}
______________________________________________________________________________________________________________
Dan Kimmel | Workflow Guru | RJS Software Systems
2970 Judicial Road, Suite 100 | Burnsville, MN 55337 | *: 952-736-5800 | *: dkimmel@xxxxxxxxxxxxxxx<mailto:dkimmel@xxxxxxxxxxxxxxx>
[cid:652270323@18102012-2DC5]<
http://www.rjssoftware.com/>[cid:652270323@18102012-2DCC]<mailto:http://blogs.rjssoftware.com/rjsinformer/index.php/feed/>[cid:652270323@18102012-2DD3]<
http://www.facebook.com/?ref=home#!/pages/RJS-Software-Systems/124687644237867?ref=ts>[cid:652270323@18102012-2DDA]<
http://twitter.com/rjssoft>[cid:652270323@18102012-2DE1]<
http://www.linkedin.com/companies/rjs-software-systems>[cid:652270323@18102012-2DE8]<
http://www.youtube.com/user/RJSSoftwareSystems>
Manage the entire lifecycle of your business information
As an Amazon Associate we earn from qualifying purchases.