Is it mandatory to add QUALIFIED
to DS1
in order for this code to compile:
**FREE
DCL-DS DS1;
FIELD1 PACKED(5);
END-DS;
DS1.FIELD1 = 2024;
DSPLY DS1.FIELD1;
RETURN;
I know the question might sound silly (because what is the purpose of QUALIFIED
then?!) but I have a case like this in which they affirm that it compiles.
I have tested it in PUB400.com, it does not compile, but I thought I may be missing some compiler flag or something.
IIRC, originally the compiler would not complain if you used qualified name to reference a non-qualified data structure.
However, IBM "fixed" that bug a while back.
PUB400 tends to stay pretty up to date, so that explains why it doesn't work there.
I'll see if I can find specifics about when this was fixed and update this answer.
UPDATE
A quick search shows this bug was fixed in v7.2, so if you're running a really out of date version of the OS, then that explains why it works on your system.
From the v7.2 Memo to Users
A non-qualified subfield or format cannot be qualified within a subprocedure
It is not valid to use qualified notation, A.B, for subfields and record formats that are not qualified. Before IBM® i 7.2, the compiler did not always detect this error if the reference to the global subfield or record format was in a subprocedure. Starting in 7.2, the compiler detects this error and diagnostic: RNF7591 - An operand of a qualified name expression is not valid is issued at compile time.