The pjs.define() API is used within Profound.js modules to declare fields, arrays, and data structures with a strong data type. All IBM i data types are available.
...
Property name | Property type | Description |
---|---|---|
type | String | The following data types can be specified:
Some config properties only apply to certain types. |
length | Number | Specifies the field length. It is required for most data types; exceptions are:
|
decimals | Number | Specifies the number of decimal positions. It required for packed and zoned fields. |
varying | Boolean | Specifies that a character field is of varying length; otherwise, the field will be a fixed length field padded with spaces. |
initValue | String/Number/Boolean/Array | Specified the field's initial value. |
dim | Number | This property turns the definition into an array. When declared this way, arrays start with an index of 1, similar to RPG. |
orderBy | String | Specifies the default sort order for arrays declared with the dim property. The orderBy property is used by array-related API, such as pjs.lookup(). Possible values are:
|
elements | Object | Specifies an object of subfields for a data structure. Each property within the object is the subfield name, while the property value is another config object. |
qualified | Boolean | Identifies a data structure as qualified, meaning that all references to its subfields must be qualified with the data structure name first; for example: MyDS.mysubfield = "myvalue". This makes the data structure similar to a JavaScript object. If qualified is not specified, the subfields can be referenced directly; for example: mysubfield = "myvalue". |
special | String | Identifies a special subfield and can only be specified on a data structure subfield configuration with the elements property. Possible values are: For a Status Data Structure (statusDS):
For an Information Data Structure (infDS):
|
nullable | Boolean / String | Use this property to create null-capable fields.
|
extName | String / Object | Specifies the name of a file that contains the fields used as the subfield description for the data structure being defined. The property can specified as a String that contains the file name or as an object with the following properties:
The file name can be qualified with a library; for example: "PRODLIB/MYFILE". |
likeRec | String / Object | Specified on a data structure to make its definition like a previously defined database table. The property can be specified as a String, which names the previously defined record format, or as an object with the following properties:
When likeRec is specified, the data structure becomes qualified automatically. |
likeDS | String | Used on a data structure to specify the name of another data structure from which the configuration is derived. |
dataArea | String | Specifies a data area object to be associated with the declared field. The name of the data area may include a library. For example:
|
statusDS | Boolean | Identifies a Status Data Structure. A Status Data Structure is automatically populated with information about the current Profound.js module and job. It is an easy way to retrieve information, such as the current IBM i job name, the current user id, and more. |
userDefinedData | Any | Specifies user-defined general purpose data associated with the field configuration. |
based | String | The name of a pointer field that the declared field will be based on. The pointer will be defined automatically, if necessary. |
dateFormat | String | The format for a date type field. The available date formats are:
|
dateSeparator | String | The separator for a date type field. The available separators are:
This property is ignored if the field is not a date field, and also ignored for date fields with format "*iso", "*usa", "*eur", and "*jis". |
timeFormat | String | The format for a time type field. The available time formats are:
This property is ignored if the field is not a time field. |
timeSeparator | String | The separator for a time type field. The available time separators are:
This property is ignored if the field is not a time field and also ignored for time fields with format other than "*hms". |
Examples
Example 1: packed decimal
...