enskill.com iSeries Training Onsite classes
DVD training
Books
Online e-Learning
Home
Resources
Contact
(c)2002-2008

Bryan's RPG IV Journal


Replacing *ENTRY PLIST with a Prototype

Q. I am trying to find the /Free replacement for the *ENTRY PLIST. The conversion tool in WDSc doesn't touch this code. Is it possible to do this in /Free code?

A. You're probably comfortable coding a prototype and procedure interface for a subprocedure. But you can also use PR/PI definitions to replace the *ENTRY PLIST for an RPG IV program When coding a procedure interface for a main procedure (i.e., a program), you must remember a few additional requirements:

  • The prototype for the main procedure must include the Extpgm keyword.
  • The procedure interface must be named (the same as the prototype).
  • The prototype must precede the procedure interface.

You have a choice when naming the prototype and the procedure interface. You can name the PR and PI descriptions to match the name of the module, or you can assign a name of your choosing -- perhaps a shop-standard name such as Main. If the name on the PR/PI descriptions doesn't match the module name, you must specify the module name with the Extpgm keyword (e.g., EXTPGM('MYPGM')).

Here's a sample *ENTRY PLIST for a program named MYPGM and a pair of sample PR/PI combinations to replace it.

*ENTRY PLIST:
C      *Entry      Plist
C                  Parm                CpyNbr     5 0
C                  Parm                AcctID     7

Corresponding PR/PI description:
  // ------------------------------------- Prototypes
D Mypgm           PR                  ExtPgm
D                                5  0
D                                7
  // ----------------------- Main procedure interface
D Mypgm           PI
D   CpyNbr                       5  0
D   AcctID                       7

Or:
  // ------------------------------------- Prototypes
D Main            PR                  ExtPgm('MYPGM')
D                                5  0
D                                7
  // ----------------------- Main procedure interface
D Main            PI
D   CpyNbr                       5  0
D   AcctID                       7

You can call this program (MYPGM) from any program, whether or not the calling program prototypes the call. The calling program can even be a CL program or an RPG III program. If the calling RPG IV program also has a prototype for MYPGM, the caller can use a free format call to MYPGM. For example:

  // ------------------------------------- Prototypes
D Mypgm           PR                  ExtPgm('MYPGM')
D                                5  0
D                                7

 /Free
  Mypgm(Company:Customer);
 /End-free

There are several reasons you might want to switch to using PR/PI descriptions instead of an *ENTRY PLIST. First, the coding is consistent with the coding required for subprocedures, which don't support *ENTRY PLIST. Second, the free-format replacement specification for C-specs doesn't support the PLIST or PARM operation; free-format coding renders the *ENTRY PLIST obsolete. Last, you can take advantage of prototyping to better control how parameters are passed by using prototyping keywords such as Const and Options(*NoPass).

Note that you can pass parameters by reference (just as you did with the *ENTRY PLIST) or by read-only reference (Const). You cannot, however, pass parameters by Value to a main procedure, nor does a main procedure support a return value.

Posted Friday, July 7, 2006

Log of Journal Entries

Use this scrollable blog map to view other journal entries:
Journal Home
It is your responsibility to ensure procedures, techniques, and code used from this website are accurate and appropriate for your installation. No warranty or support is implied or expressed.
E-mail to Bryan Meyers
Privacy and Email Policy
 
AS/400®, eServer, i5/OS, IBM i, Integrated Language Environment®, iSeries, OS/400®, RPG/400®, System i5, VisualAge®, and WebSphere® are trademarks of IBM Corporation. Note: IBM® System i is the latest member of the family of eServer iSeries. This site might refer to System i as System i5, iSeries, or AS/400.
 

If you are having trouble navigating the menu at the top of this page, you may use the following scrollable site map instead:
 

Self-paced DVD Training
DVD: RPG IV for RPG Programmers
DVD: RPG IV Modules, Procedures, and Service Programs
 
In association with Amazon.com
Programming in RPG IV
RPG IV Jump Start
Power Tips for RPG IV
Control Language Programming for the AS/400
VisualAge for RPG by Example
 
International visitors: click hereInternational visitors:
Click here!