Q. I’m trying to replace the *ENTRY PLIST with a prototype, so I can use CALLP and free format. But I’m running into a problem with the LIKE keyword. The compiler is giving me the following error: “LIKE not allowed with specified Field-Location entries; keyword is ignored.”
Here’s my prototype:
D Dispatch PR Extpgm('REZ517') D 5U 0 D Like(Availstatus)
If I code a parameter name, the error disappears; but I thought the parameter names in the prototype were just for documentation. Why do the other unnamed fields work, and why does the LIKE keyword not work?
A. It’s true that the prototype parameter names primarily serve a documentary purpose. But in this case, without a field length entry, you need a “separator” to help the compiler distinguish between the two parameters. Otherwise, the compiler will think that there is only one parameter, on two lines (i.e., it will treat the LIKE keyword as a continuation of the first parameter). Naming the LIKE parameter will provide the necessary degree of separation:
D Dispatch PR Extpgm('REZ517') D Reservation 5U 0 D Availability Like(Availstatus)
If you are using “fully free” RPG, you can specify an *N placeholder to separate the parameters instead of naming them:
Dcl-pr Dispatch Extpgm('REZ517'); *N Uns; *N Like(Availstatus); End-pr;
The same requirement holds true for LIKEREC and LIKEDS keywords in a prototype.