pjs.createDataArea()
This API creates a data area on IBM i and optionally initializes it.
Parameters
This API can accept an optional database connection definition object to select between multiple database connections. To select the database connection, call pjs.getDB() and pass the result as the first parameter, followed by the parameters documented below. If a database connection definition object is not passed, the default database connection is used.
An object with the following key/value pairs:Â
name - A string containing the data area name, in LIBRARY/OBJECT_NAME notation. If the library is omitted, the data area will be created in the job's current library or QGPL
type - Â A string containing either "*CHAR", "*DEC", or "*LGL". This API cannot be used to create a *DDM (remote) data area.
length - The desired length for the data area. See the IBM i command help for CRTDTAARA for limitations/restrictions.
decimals (optional) - Number of decimal positions for *DEC data areas. Defaults to zero if not specified.
initValue (optional) - Initialization value. Use a string for *CHAR data areas, a number for *DEC, and a Boolean for *LGL.
Replace (optional) - If set to Boolean true, an existing data area will be replaced and re-created. If not specified, an exception will be thrown if the given data area already exists.
Return Value
None.
Exception Handling
If there is a problem creating the data area, an Error will be thrown with the following properties:
message - The IBM i message text.
error - The message id.
help - The message help text.
Examples
Create a 10-byte character data area and initialize
try {
pjs.createDataArea({
name: "mylib/mydtaara",
type: "*char",
length: 10,
initValue: "my_text"
});
Â
// Data area is created/initialized.
}
catch (error) {
// Problem! Data area not created.
}
Create a 5,2 decimal data area, initialize, and replace existing object
try {
pjs.createDataArea({
name: "mylib/mydtaara",
type: "*dec",
length: 5,
decimals: 2,
initValue: 999.99,
replace: true
});
Â
// Data area is created/initialized.
}
catch (error) {
// Problem! Data area not created.
}
Requirements
This API requires the Profound.js Connector module.
Some documentation pages have recently moved to a new section: Profound AppDev. If you are having trouble finding specific pages, try the documentation search capability or reach out to our Support team!