Good News Everybody!
The new search engine is LIVE!
Please report any problems to david (at) midrange.com.
|
I am stuck once again, and am in desperate need of help. Quick overview: I
need to access data stored on our AS400 in older System 36 type files. Thus,
the physical file has a structure that basically only declares a delete code, a
key, and then a long stream of data.
Thus, I have been forced to define my own record format within java. I am able
to read the file sequentially, but when I try to read it as a keyed file, it
doesn't seem to find the key.
This is a snippet of the code:
// Set up the PO File
CharacterFieldDescription deleteCode = new CharacterFieldDescription(new
AS400Text(1), "POCODE"); //1
CharacterFieldDescription PONumber = new CharacterFieldDescription(new
AS400Text(8), "PONO"); //2-9
BinaryFieldDescription subRecord = new BinaryFieldDescription(new
AS400Bin2(), "POSUB"); //10-11
CharacterFieldDescription accountNumber = new CharacterFieldDescription(new
AS400Text(29), "POACCT"); //12-40
CharacterFieldDescription vendorNumber = new CharacterFieldDescription(new
AS400Text(7), "POVND#"); //41-47
CharacterFieldDescription filler1 = new CharacterFieldDescription(new
AS400Text(29), "FILLER"); //48-53
PackedDecimalFieldDescription poAmount = new
PackedDecimalFieldDescription(new AS400PackedDecimal(6,2),"POAMT"); //54-59
QSYSObjectPathName POfilePathName = new QSYSObjectPathName("QS36F",
"AB.PO","FILE");
POFile = new KeyedFile(system, POfilePathName.getPath());
AS400FileRecordDescription recDesc = new AS400FileRecordDescription(system,
POfilePathName.getPath());
try {
RecordFormat recFormat = new RecordFormat("YB.PO@");
recFormat.addFieldDescription(deleteCode);
recFormat.addFieldDescription(PONumber);
recFormat.addFieldDescription(subRecord);
recFormat.addFieldDescription(accountNumber);
recFormat.addFieldDescription(vendorNumber);
recFormat.addFieldDescription(filler1);
recFormat.addFieldDescription(poAmount);
// set up keys
recFormat.addKeyFieldDescription("PONO");
recFormat.addKeyFieldDescription("POSUB");
POFile.setRecordFormat(recFormat);
and :
try {
POFile.open(AS400File.READ_ONLY, 0, AS400File.COMMIT_LOCK_LEVEL_NONE);
Object[] key = new Object[] {tranPONumber};
Record record = POFile.read(key);
if (record != null) {
System.out.println((String)record.getField("PONO"));
}
POFile.close();
It never seems to find the key, even when I am sure that the tranPONumber that I
am seeking does exist in the file.
I am getting desperate. Can anybody see a glaring error in the code, or maybe
somebody has an example of accessing a keyed data file when you have to describe
your own record format?
Thank you,
Amy
This mailing list archive is Copyright 1997-2026 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.