3

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

Kurt Anderson
  • 932
  • 1
  • 10
  • 26

3 Answers3

4

Probably worth pursuing as a defect with the service provider; presumably for most, that would be IBM rather than a third-party, as they would have to contact IBM anyhow, given the perceived issue is clearly with their compiler. Beyond that, as my "Answer", I offer some thoughts:

IMO, and in apparent agreement with the OP, naming the ExtPgm seems pointless in the given scenario. I think the compiler is confused while trying to enforce some requirements in validations of the implicitly generated Prototype for the linear-main for which only a Procedure Interface is supplied; i.e. enforcing requirements that are appropriate for an explicit Prototype, but requirements that could be overlooked [thus are no longer requirements] in the given scenario.? I am suggesting that while the RNF3573 would seem appropriate for diagnosing EXTPGM specifications of an explicit Prototype, IMO that same effect is inappropriate [i.e. the validation should not be performed] for an implicit prototype that was generated by the compiler.

FWiW: Was the fixed-format equivalent of that free-form code tested, to see if the same or a different error was the effect? The following source code currently includes the EXTPGM specification with 'PGMNAME' as the argument [i.e. supplying any bogus value of 10-byte naming to supplicate the compiler, just as is being done in the scenario of the OP, solely to effect a successful compile], but could be compiled with the other variations with changes to the source, mimicking what was done with free-form variations, to test if the same\consistent validations and errors are the effect:
- just EXTPGM keyword coded (w/out argument); is RNF3573 the effect?
- the EXTPGM keyword could be omitted; is RNF3834 the effect?
- the D-spec removed entirely (if there are no parameters defined); ¿that was not one of the variations noted in the OP as being tried, so... the effect?

    H MAIN(CheckDailyPackages)
     *--------------------------------------------------
     * Program name: CheckDailyPackages (PGMNAME)
     *-------------------------------------------------- 
    P CheckDailyPackages...
    P                 B
    D                 PI                  EXTPGM('PGMNAME')
      /free
       // Work is done here      
      /end-free
    P CheckDailyPackages...
    P                 E
CRPence
  • 1,259
  • 7
  • 12
  • I just tried mimicing the scenario in fixed format and had the same results. I'll pursue opening a ticket with IBM. Thanks. – Kurt Anderson Apr 20 '15 at 18:25
  • In free form, it works properly without a procedure interface if none is needed. though my external procedure names generally match the program name, so this comment may be invalid. I have no way to test this at the moment. Interesting thoughts. – jmarkmurphy Apr 24 '15 at 21:11
  • I created a ticket with IBM (finally). – Kurt Anderson Jul 31 '15 at 20:53
  • I was curious about this; if I am understanding this correctly, if you do not include a prototype definition for a procedure but you do define a procedure interface, the prototype definition is defined implicitly by the compiler based on the PI? – aruballo Dec 27 '15 at 08:34
1

EXTPGM keyword is used to define the external name of the program which you want to prototype. If you mention the EXTPGM then the program will be called dynamically.

Let us take an example in order to explain your query.

PGMA

D cmdExc          PR                  ExtPgm('QSYS/QCMDEXC')
D                              200A   const
D                               15P05 const
c                   callp     cmdExc('CLRPFM LIB1/PF1':200)
C                   Eval      *INLR = *ON 

In the above example CmdExc used for the dynamic call to QSYS/QCMDEXC.

When we use the same program name as the EXTPGM parameter it acts as an entry point to the program when called from other programs or procedure.

But in any case when we mention any name as the sample parameter the EXTPGM will not give any error in compilation, but it gives the error during run time as it tries to resolve the name during run time.

Kurt Anderson
  • 932
  • 1
  • 10
  • 26
Biswa
  • 11
  • 2
  • The question is in regard to the use of ExtPgm on the Procedure Interface, not the prototype. If the PI's ExtPgm value doesn't match the program name, the program will still be called successfully. – Kurt Anderson Jul 31 '15 at 18:25
1

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.

Kurt Anderson
  • 932
  • 1
  • 10
  • 26