%NULLIND (Query or Set Null Indicator)

%NULLIND(fieldname)

The %NULLIND built-in function can be used to query or set the null indicator for null-capable fields. This built-in function can only be used if the ALWNULL(*USRCTL) keyword is specified on a control specification or as a command parameter. The fieldname can be a null-capable array element, data structure, stand-alone field, subfield, or multiple occurrence data structure.

%NULLIND can only be used in expressions in extended factor 2.

When used on the right-hand side of an expression, this function returns the setting of the null indicator for the null-capable field. The setting can be *ON or *OFF.

When used on the left-hand side of an expression, this function can be used to set the null indicator for null-capable fields to *ON or *OFF. The content of a null-capable field remains unchanged.

See Database Null Value Support for more information on handling records with null-capable fields and keys.

For more information, see Indicator-Setting Operations or Built-in Functions.

Figure 1. %NULLIND Example
 *..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
 * Test the null indicator for a null-capable field.
 /FREE
    if  %nullind (fieldname1);
        // field is null
    endif;
 
    // Set the null indicator for a null-capable field.
    %nullind(fieldname1) = *ON;
    %nullind (fieldname2) = *OFF;
 /END-FREE