Advantage of defining a prototype in D-Specs in RPGLE

I recently learned somthing about loacal procedures in fixed format RPG IV and their definition either in the D-Specs and implementation in P-Specs section or omitting the D-Specs definition.

According to the IBM Documentation, if I omit the definition in D the compiler will automatically generate the necessary definition from the procedure interface followed by the P-Spec where I implement my procedure.

Now I wonder what is the advantage of defining the procedure interface two times? Is there any benifit of writing (almost) the same code twice (in D-Specs in the top and below the P-Spec) or is this just a option for the programmer to have some meaningfull place where to define the input/outpu parameter for the procedure?

Thanks in advance


  • Starting at IBM i v7.1, for internal procedures, there is no advantage to creating prototypes, and in fact there is a risk that you will get them wrong (though that issue is easily detected and corrected). Prior to that, all procedures required a prototype. For procedures that are exported from a service program, or a module, the prototypes are critical. I keep those in a separate copy book so that I can include the same prototypes in my module source, and in the source of the program using the module. In this way you only have to have a single copy of the prototypes floating around, and it is easy to include wherever you need them.