Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Internal name - A String containing the desired internal file name. A variable of this name will be defined in the calling script and will be populated with a record file instance. I/O operations are then performed by calling file-specific APIsAPI.
  2. External name (optional) - A String specifying the external name of the file object. The name can optionally be qualified with a library. If the library is not specified, then the library list is used to resolve the file. If the external name is not specified, then the internal name is used instead. This parameter can be omitted, in this case the file configuration is passed for parameter 2. This parameter can also be specified as an Object with the following properties in order to implement dynamic external file names:
    • field - The name of a declared character field that hold the external file object name
    • extDesc (optional) - The name of the file object to use for file discovery before the file is opened and before the field is declared. If omitted, the internal name is used. 
  3. File configuration (optional) - An Object that sets file options using the property names / values shown below. If the external file name parameter is omitted, then the configuration should be passed as parameter 2.

...

Code Block
languagejavascript
titleDefine table for reading records
pjs.defineTable("read", "PRODUCTSP", { read: true });
read.fetchNext();
Code Block
languagejavascript
titleDeclare a table with a dynamic file name
pjs.defineTable("read", { field: "fileName", extDesc: "PRODUCTSP" }, { read: true });
pjs.define("fileName", { type: 'char', length: 25, varying: true });
fileName = "PRODUCTSL1";
read.fetchNext();
Code Block
languagejavascript
titleDefining a table with userOpen and infDS
  pjs.defineTable("productsp", { infDS: 'OPNFBK',  userOpen: true,  read: true,  levelIds: [ '4AFA8C636F188' ] });

  pjs.define("OPNFBK", { type: 'data structure', elements: {
    "FILE": { special: '*file' },
    "OPEN_IND": { type: 'boolean' },
    "ODP_TYPE": { type: 'char', from: 81, to: 82 },
    "FILE_NAME": { type: 'char', from: 83, to: 92 },
    "LIBRARY": { type: 'char', from: 93, to: 102 }
  }});

  pjs.define("data", { type: 'char', length: 24, varying: true });

  productsp.open();
  data = OPNFBK.substr(80, 22) + OPEN_IND.toString();
  productsp.close();
  data += OPEN_IND.toString();

...