This API writes to an IBM i IFS file and performs optional text conversion. If the file already exists, it is deleted and re-created.
Parameters
- Path (String) - Path to the IFS file to write.
- Data (Buffer) - A Buffer instancing containing the data to write to the file.
- File CCSID (Number/optional) – Specifies the CCSID attribute of the file. If omitted or set to zero, the IBM i job CCSID will be used.
- Data CCSID (Number/optional) - Specifies the CCSID of the data to write to the file. The data will be converted from this CCSID to the file CCSID. If this parameter is omitted or set to zero, the data will be converted from the CCSID of the IBM i job to the file CCSID. If set to 65535 no conversion will be done.
Exception Handling
An Error instance will be thrown if there are any problems writing the file.
Examples
Write JavaScript String to Text File in EBCDIC 37
var buffer = Buffer.from("Hello, world.", "utf8"); pjs.writeIFSFile("/home/rfite/ebcdic.txt", buffer, 37, 1208);
Write EBCDIC Field Data to UTF8 Text File
pjs.define("myfield", { type: "char", length: 13, initValue: "Hello, world." }); pjs.writeIFSFile("/home/rfite/utf8.txt", pjs.getBuffer(myfield), 1208, 37);