|
>I can't seem to regain control after the while loop... Any ideas?
>It just hangs there, and displaying the correct data
Tim
this is a problem I noticed sometime ago.
The problem (as I found) was that the READE function doesn't work the same
as the equivalent RPG READE op-code. If you look at the target job on the
as/400, you will find that the job is still reading the file looking for
matches ! It never seems to end ...
At this point I gave up with PBD & used the std as/400 classes and wrote a
simple procedure to check if I had got a match.
Mike
The following code is a bit messy but hopefully gives you the idea.
The ORDHDRK (format ORDHDR) file is keyed by Company then Order No.
The READE on ORDDTLK file first does a position to & then does a
READE but with no actual key. We then invoke the CheckORDDTLKkey
function to decide if there was a match !
Object[] key;
Object[] nokey = new Object[] { };
BigDecimal TotODQTYO = new BigDecimal(0.0);
BigDecimal TotODLVAL = new BigDecimal(0.0);
// Read a ORDHDR using the key array.
key = new Object[] {"01",new java.math.BigDecimal(725075) };
// read is effectively a CHAIN op-code
if ( (ORDHDR = ORDHDRKfile.read(key)) != null )
{
// Retrieve field values from the ORDDTL.
ORDDTLKfile.positionCursorBefore(key);
int eof = 0;
while ( eof == 0 ) {
if ((ORDDTL = ORDDTLKfile.readNextEqual(nokey)) != null) {
if (( eof = CheckORDDTLKkey(key)) == 0) {
TotODQTYO = TotODQTYO.add(new BigDecimal(new
String(ORDDTL.getField("ODQTYO").toString())));
TotODLVAL = TotODLVAL.add(new BigDecimal(new
String(ORDDTL.getField("ODLVAL").toString())));
}
}
else { eof = 1; }
}
}
// Heres the checking of the keys
public int CheckORDDTLKkey(Object[] Keylist) {
for (int i = 0 ; i<Keylist.length ; i++) {
String keystring = new String(Keylist[i].toString());
try {
String filekeystring = new
String(ORDDTL.getField(ORDDTLKrecformat[0].getKeyFieldDescription(i).getFieldName().toString()).toString());
if (! keystring.equals(filekeystring)) { return (1); }
}
catch (Exception e) {
System.err.println("Exception error: " + e);
this.statusBar.setText(e.toString());
e.printStackTrace();
return(1);
}
}
return(0);
}
+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.