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 thread ...

Follow-Ups:

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

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