|
Here is a code snippet I use to create physcial file members:
String asfile = ivFileReceive + sessionID + ".MBR";
SequentialFile baseFile = new SequentialFile(as400, asfile);
try {
baseFile.addPhysicalFileMember(sessionID, null);
} catch (AS400Exception as) {
if (as.getAS400Message().getID().equals("CPF5812")) {
// member exists, delete and re-add to clear the data
baseFile.deleteMember();
baseFile.addPhysicalFileMember(sessionID, null);
} else throw as;
}
===
Marshall Dunbar
DPS, Inc.
marshall@xxxxxxxxxxx
direct:(828)635-5561
main office:(317)574-4300 (800)654-4689
====
Thorbjørn Ravn Andersen <thunderaxiom@xxxxxxxxx>
Sent by: java400-l-bounces@xxxxxxxxxxxx
02/28/2006 07:51 AM
Please respond to
Java Programming on and around the iSeries / AS400
<java400-l@xxxxxxxxxxxx>
To
Java Programming on and around the iSeries / AS400
<java400-l@xxxxxxxxxxxx>
cc
Subject
Create a member in a given file?
I need to create a member in a file.
I have the full name of the member file in an IFSFile object (i.e.
/QSYS.LIB/XQ41EXI01.LIB/EDIPOMATCE.FILE/MACT9S0BYG.MBR) and I intend to
open it as a SequentialFile, create a Record per line and put in the
data I need, and write it to the SequentialFile.
Currently my code looks pretty much like:
----
IFSFile logMember = new IFSFile(system,
logFile.getAbsolutePath() + "/" + member.getName());
if (logMember.exists()) {
throw new IllegalStateException("Member already exists in
error file " + logMember);
}
SequentialFile sequentialFile =
getSequentialFileWithRecordFormatSet(system, logMember.getAbsolutePath());
sequentialFile.open();
sequentialFile.positionCursorAfterLast();
Record record1 = sequentialFile.getRecordFormat().getNewRecord();
record1.setField(0, "UNB01PEVRETUR");
sequentialFile.write(record1);
--.-. where getSequentialFile looks like
private SequentialFile getSequentialFileWithRecordFormatSet(AS400
system, String absolutePath) throws AS400Exception,
AS400SecurityException, InterruptedException, IOException,
PropertyVetoException {
AS400FileRecordDescription recordDescription = new
AS400FileRecordDescription( system, absolutePath);
SequentialFile sequentialFile = new SequentialFile(system,
absolutePath);
RecordFormat[] retrieveRecordFormat =
recordDescription.retrieveRecordFormat();
if (retrieveRecordFormat.length != 1) {
log.warn("file does not have exactly one member: " +
absolutePath);
}
RecordFormat recordFormat = retrieveRecordFormat[0];
sequentialFile.setRecordFormat(recordFormat);
return sequentialFile;
}
------
This is very similar to what I do when reading from a member, but the
only create method I can find creates the sequentialFile, not the
member. Apparently "create member" is not the right term to search for
either in google or the toolbox manual, so I am a bit lost now. I don't
grok Cobol, so I have no idea what it might be called instead.
I would appreciate a gentle hint in the right direction.
Best regards,
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.