The LRM indicates that a PACKAGE can contain PROCEDUREs and DECLARATIONS; and in fact, this simple example appears to work just fine:
*Process NUMBER;
p: package;
test: proc options(main);
display("I'm TEST");
end;
t2: proc;
display("Hey - I'm T2!!");
end;
/* declaration outside a PROC */
declare x fixed bin(31);
end p;
The LRM further says that if a PACKAGE statement is not present, one is effectively inserted after the first *PROCESS statement(although it doesn't make clear what is done if there is no *PROCESS statement, and does not provide the name that might be used for scoping of the PROCs/DCLs in that inserted PACKAGE statement. From the LRM:
"If the source contains a PACKAGE statement, there must be at most only one set of *PROCESS statements and those must be the first statements in the source. If the source contains no PACKAGE statement, the compiler effectively inserts one after the first set of *PROCESS statements and the source might contain multiple external procedures separated by groups of *PROCESS statements."
Furthermore - regarding the package name, the LRM has this restriction: "All PACKAGE names must be unique within a linked module." So, if you have more than one compilation unit with the inserted PACKAGE statement, what name is used? Do inserted PACKAGE statements have unique names because they have "no name"?
The description of the inserted PACKAGE statement rather explicitly does not seem to allow for DECLARATION statements, only multiple EXTERNAL PROCEDURES. So, if we have the same example with the PACKAGE statement removed, it does not compile:
*Process NUMBER;
test: proc options(main);
display("I'm TEST");
end;
t2: proc;
display("Hey - I'm T2!!");
end;
/* declaration outside a PROC */
declare x fixed bin(31);
The compiler complains with:
e.pli(12:2) : IBM1861I S All statements other than DECLARE, DEFAULT and PROCEDURE statements must be contained inside a PROCEDURE.
I'm not quite sure I understand the difference in these two situations... especially if there is an inserted (but somehow different) PACKAGE statement in the second example? Is it simply the case that the inserted PACKAGE statement only allows for multiple PROCEDURES and no DECLARATION statements? Maybe because there is a missing package name?
tdr