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.addPhysicalFileMember(sessionID, null);
      } else throw as;

Marshall Dunbar
DPS, Inc.
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 

Java Programming on and around the iSeries / AS400 

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. 
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());;
        Record record1 = sequentialFile.getRecordFormat().getNewRecord();
        record1.setField(0, "UNB01PEVRETUR");
--.-. 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, 
        RecordFormat[] retrieveRecordFormat = 
        if (retrieveRecordFormat.length != 1) {
            log.warn("file does not have exactly one member: " + 
        RecordFormat recordFormat = retrieveRecordFormat[0];
        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 thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by 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.