pjs.nullInd()
The pjs.nullInd() API allows you to get or set the value of a null indicator.
For strongly typed fields with the 'nullable' configuration option, a null indicator can be used to differentiate when a variable is and isn't null.
Parameters
Null-capable field
Set value (Boolean, optional). If this parameter is passed, the Null indicator is set (true for null, false for not null); otherwise, the null indicator is simply retrieved and returned.
Return Value
Boolean value indicating whether the field is null
Examples
Example 1: Nullable field with internal null-indicator.
pjs.define("data", { type: 'char', length: 50, varying: true });
pjs.define("myNumber", {
type: 'packed decimal',
length: 10,
decimals: 0,
nullable: true
});
pjs.nullInd(myNumber, true);
data = pjs.nullInd(myNumber).toString();
Example 2: Nullable field with variable null-indicator.
pjs.define("data", { type: 'char', length: 50, varying: true });
pjs.define("myBoolean", { type: 'boolean', initValue: true });
pjs.define("myNumber", {
type: 'packed decimal',
length: 10,
decimals: 0,
nullable: 'myBoolean'
});
myBoolean = false; // Changes %nullind(myNumber) to *Off
pjs.nullInd(myNumber, true); // Changes myBoolean to *On
data += pjs.nullInd(myNumber).toString() + myBoolean.toString(); // data is now '11'
RPG Equivalent
%NULLIND()