Separate definitions between prototype and procedure interface

I start with RPGLE, and I am trying to determine if there is a way to simply define the parameters for the procedures in my service program once. I know that I can put prototypes inside a member of the copy (which I did), but then I still have to put the same code in the body of the procedure ("procedure interface").

My question is: is there any way to use the prototype to define parameters in the procedure interface (or vice versa)?

Ideally, something like:

Prototype:

D buildForm        PR
D  formType                      10A   CONST
D  mode                           4A   CONST

Procedure:

P buildForm        B
D buildForm        PI
D  formType                            LIKE(formType)
D  mode                                LIKE(mode)

Well, ideally, I can just say "use a prototype" or something in the body of the procedure, or the compiler will find it myself ...


I don’t understand how to create prototypes and interfaces of procedures, or they actually repeat when executed correctly:

Prototype:

D buildForm        PR
D  formType                      10A   CONST
D  mode                           4A   CONST

Procedure:

P buildForm        B
D buildForm        PI
D  formType                      10A   CONST
D  mode                           4A   CONST

.

+3
3

7.1, , , . , ( !)

, . PI, PR, /copy , :

  /copy buck/qprotosrc,buildform
  ...
  buildform(form: mode);

, "double define", - , PI. - . :

qprotosrc (buildform)

  // Build form prototype and start of interface
  // Service program will complete the interface with P    E
  /if not defined(buildform_proto)
  /define buildform_proto
 D buildForm       PR
  /else
 P buildForm       B
 D buildForm       PI
  /endif
 D  formType                     10A   CONST
 D  mode                          4A   CONST

qrpglesrc (mysrvpgm)

  /copy buck/qprotosrc,buildform
  ...
  /copy buck/qprotosrc,buildform
  // body of buildform here
  ...
   return;
 p                 e

, /copy , - , . buildform_proto. /. buildform_proto , P... B D... PI. P... E.

+4

, , , .

parm. . " ", , , . , PI PR.

Bucks, . , include , , , - include . - .

/if defined(MYPROTO_INC)
/EOF
/endif
/define MYPROTO_INC

, , , .

, , , . , .

, .

 d formType_t      S             10a   template
 d formMode_t      s              4a   template

 D buildForm       PR
 D  type                               CONST like(formType_t)
 D  mode                               CONST like(formMode_t)

 P buildForm       B
 D buildForm       PI
 D  type                               CONST like(formType_t)
 D  mode                               CONST like(formMode_t)

, .

, , STDTYPES APPTYPES.

+3

Many stores solve this by putting parm in the copy book. The copy is then used immediately after the D-spec Prototype (PR) line and the procedure interface (PI) line.

+1
source

All Articles