Search code examples
rpgle

Why do I have to specify an ExtPgm parameter for the Main Procedure?


My program, PKGDAYMONR has the control option:

ctl-opt Main( CheckDailyPackages )

The CheckDailyPackages procedure has the following PI:

dcl-pi *n ExtPgm( 'PGMNAME' );

As you can see the ExtPgm parameter is not the name of the program. In fact, it’s what came over in the template source and I forgot to change it. Despite the wrong name in ExtPgm, the program runs without a problem.

If I remove that parameter and leave the keyword as just ExtPgm, I get the following message:

RNF3573: A parameter is required for the EXTPGM keyword when the procedure name is longer than 10.

If I drop ExtPgm from the Procedure Interface altogether, it also complains:

RNF3834: EXTPGM must be specified on the prototype for the MAIN() procedure.

So why is it that I have to specify a parameter if it doesn't matter what value I enter?

O/S level: IBM i 7.2


Solution

  • I got a response from IBM and essentially Biswa was on to something, it simply wasn't clear (in my opinion) about the answer.

    Essentially the EXTPGM is required on long Main procedure names in order to support recursive program calls.

    This is the response I received from IBM explaining the reason for the scenario:

    The incorrect EXTPGM would only matter if there was a call to the main
    procedure (the program) within the module.
    When the compiler processes the procedure interface, it doesn't know
    whether there might be a call that appears later in the module.