They’re just different ways of accomplishing the same goal — calling a procedure.
Loosely think of CALL PROCEDURE as being similiar to RPG’s CALLB — both specify right there in the CALL that a procedure is being called. If you had a *SRVPGM exporting the procedure SgnMax, which takes two integer const inputs and returns the larger of the two values, then:
PROCESS NOMONOPRC.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Numeric-Value-1 PIC S9(9) BINARY VALUE 10.
01 Numeric-Value-2 PIC S9(9) BINARY VALUE 13.
01 Answer PIC S9(9) BINARY.
PROCEDURE DIVISION.
MAIN-LINE.
CALL PROCEDURE "SgnMax" USING
BY CONTENT Numeric-Value-1,
BY CONTENT Numeric-Value-2,
GIVING Answer.
DISPLAY "The larger number is: " Answer.
STOP RUN.
would call that procedure.
Using the Special-Names paragraph and specifying LINKAGE TYPE PROCEDURE allows you to identify SngMax as being a procedure without having to explicitly respecify it on each call (VERY loosely like how a RPG prototype can distinguish between a program call and a procedure call. Using SgnMax again, this would also work:
PROCESS NOMONOPRC.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
LINKAGE TYPE PROCEDURE FOR "SgnMax".
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Numeric-Value-1 PIC S9(9) BINARY VALUE 10.
01 Numeric-Value-2 PIC S9(9) BINARY VALUE 13.
01 Answer PIC S9(9) BINARY.
PROCEDURE DIVISION.
MAIN-LINE.
CALL "SgnMax" USING BY CONTENT Numeric-Value-1,
BY CONTENT Numeric-Value-2,
GIVING Answer.
DISPLAY "The larger number is: " Answer.
STOP RUN.
Simply pick one way and use it. Personally I use the CALL PROCEDURE approach.
One key difference between the two languages that you need to be aware of — in RPG you expect quoted names to be left as is. COBOL, on the other hand, will monocase mixed case procedure name literals. So if you’re not careful you will find “SgnMax” becoming SGNMAX when trying to bind to the function. To turn this feature off you use the PROCESS NOMONOPRC statement. The PROCESS statement is, again loosely speaking, like the RPG H spec (though unfortunately you can’t specify binding directories or service program names on the PROCESS statement).
If your RPG procedure prototypes a parameter as VALUE you’ll use BY VALUE in COBOL. If the prototype has CONST you’ll use BY CONTENT. And if neither VALUE or CONST, use BY REFERENCE. GIVING identifies the procedures RETURN value.
I hope this helps,
Bruce Vining
Discuss This Question: 7  Replies