Here's a test source where I need to ID and validate the (fixed) *blank positions in a fixed-len string, data. So here the first blank_string is of char(4) starting pos(2), and the second blank_string is of char(2) starting pos(8) declared as a source DS
dcl-s data char(12) inz('z zz zzz');
// '1234+6789112'
// 'z....zz..zzz'
dcl-ds source inz;
*n char(4) pos(2); //will be usually blank
*n char(2) pos(8); //will be usually blank
end-ds;
source = data;
//check if the DS is blank
if source = *blanks;
dsply 'DS is surely blank';
endif;
looking in debugger, the DS appears as expected, i.e. all blank.
Even though the DS is as clean as a glass, yet the IF condition is set to FALSE, and exits without executing the dsply.
EDIT: summarizing compiler's POV
//structure user trying to define
dcl-ds source inz;
*n char(4) pos(2); //will be usually blank
*n char(2) pos(8); //will be usually blank
end-ds;
//structure that actually got defined
dcl-ds source inz;
*n char(1) pos(1);
*n char(4) pos(2); //will be usually blank
*n char(2) pos(6);
*n char(2) pos(8); //will be usually blank
end-ds;
Because source
isn't blank. source
contains 'z zz '
as you copied data
to source
.
Just because the debugger by default is showing you the defined sub-fields of source
doesn't make that all that is in source
.
try this
eval source:c 9
Which instructs the debugger to display source as a char(9) variable.