file.fetchPreviousEqual()

 

This method retrieves the previous record from the file if the record matches the search argument.

Parameters
  1. Search argument - A Number, String, or Array value specifying a relative record number, key value, or list of key values (array of Number/String).

  2. Don't lock (optional) - Pass Boolean true to avoid locking the record if the file is open for update/delete. If this parameter is set to Boolean false or omitted, records will be locked for update/delete files.

  3. Record format name (optional) - A String value specifying the record format name.

  4. Input data structure (optional) - A Profound.js data structure reference. If specified, the referenced data structure will be populated with the record data. If the data structure is not qualified, you must wrap the parameter with the pjs.ds() API.

Exception Handling

An Error instance will be thrown with the following properties:

  • message - The message text.

  • error - The message id.

  • help - The message help text.

Examples
Read all records with first and second keys equal to 100 and 200, in reverse sequence
pjs.defineTable("myfile", { keyed: true, read: true }); myfile.positionAfter([100, 200]); myfile.fetchPreviousEqual([100, 200]); while (!file.endOfData()) {  // Do something with record data here.  myfile.fetchPreviousEqual([100, 200]);  }

 

Read all records with first key equal to 'Y' into data structure without locking records, in reverse sequence
pjs.defineTable("myfile", { keyed: true, read: true, qualified: true }); pjs.define("myds", { type: 'data structure', qualified: true, likerec: { intrecname: 'myfile.myrecfmt' }}); myfile.positionAfter("Y"); myfile.fetchPreviousEqual("Y", true, null, myds); while (!file.endOfData()) {  // Do something with record data here. myfile.fetchPreviousEqual("Y", true, null, myds);  } 

RPG Equivalent

READPE

Requirements

This API requires the Profound.js Connector module.