Using the attribute GENERIC procedures may have more than one parm list.

Syntax:
DCL procname GENERIC ( procname_1 WHEN ( parm_descriptor_1 ) ,
procname_2 WHEN ( parm_descriptor_2 ) );
Meaning at compile time:
WHENEVER a call of procname is inside the source
IF the calling parameters are like parm_descriptor_1 THEN replace procname with procname_1
ELSE IF the calling parameters are like parm_descriptor_2 THEN replace procname with procname_2
ELSE throw compile error

A procedure may be external, i.e. the source may be contained in a separate file.
This approach offers the possibility to use this procedure in more than one main program.
Every program or procedure which uses an external procedure must declare this procedure.

Compile the program and all the used external procedures in any order.

Use the linkage editor to combine the compile objects to an executable program.

The executable program now contains the binary code of its procedures at linking time,
i.e. if an external procedure is changed and recompiled after linking time this would not change the behaviour of the executable program.

A procedure will be recognised as to_be_loaded_dynamicly iff the program somewhere contains a fetch or release statement, it is not necessary that this statement will be reached at any time.

If a procedure recognised as to_be_loaded_dynamicly is invoked at runtime it will be fetched automatically if necessary.

Using this two properties the program above may be rewritten as:

example: proc options ( main );
dcl abc EXT ENTRY;
dcl dfg EXT ENTRY;
dcl ( b1 , b2 ) bit (1);
if 1 > 2 then /* this will never be true */
fetch abc, dfg; /* but abc and dfg will be MARKED AS TO_BE_LOADED_DYNAMICLY */
.....
if b1 then
do;
/* COMMENT: IF ABC IS NOT YET IN MAIN STORAGE THEN LOAD IT AUTOMATICALLY */
call abc;
end;
.....
if b2 then
do;
/* COMMENT: IF ABC IS NOT YET IN MAIN STORAGE THEN LOAD IT AUTOMATICALLY */
call abc;
/* COMMENT: IF DFG IS NOT YET IN MAIN STORAGE THEN LOAD IT AUTOMATICALLY */
call dfg;
end;
end example;