Skip to main content
Solved

Help using program prototypes

  • March 26, 2026
  • 4 replies
  • 44 views

Frank Swarbrick
Forum|alt.badge.img+1

I am trying to make use of the ISO2002 option and ISO 2002 style program prototypes.  I’m running in to two, perhaps unrelated, issues.

  1. Even when I specify $set repository"update on checking on", no external repository file appears to be created.
  2. If I, in a separate calling program, code a program prototype for the called program, it appears to check for call parameter conformance correctly, but with a correctly coded call statement I end up with a fatal error, shown below.

* Options: NOLIST NOASM
* 912-S                                                                      **
**    Internal error - Dictionary invalid r/w . Please contact Rocket Technical Support.

I have three source files below:

  • f1.cbl contains a function named f1.
    • This compiles fine and writes the f1.rdf external repository file.
  • p1.cbl contains a program named p1.
    • p1, among other things, uses the f1 user defined function from above.  No function prototype is required because it is “read” from the external repository.
    • This compiles fine, but does not write an external repository file, even though I’ve specified the option to do so.
  • p0.cbl contains a program prototype for the p1 program above, and then program p0.
    • p0 calls p1
    • The error shown above (“Internal error - Dictionary invalid r/w .”) occurs during compile

Below are the three source files (inline; it wouldn’t let me attach a .cbl file).

f1.cbl

 

      $set sourceformat"free"

      $set iso2002

      $set repository"update on checking on"

function-id. f1.

linkage section.

01  x                pic x(10).

01    n                 binary-long.

01  r                binary-short.

procedure division using x optional n returning r.

    if x is not omitted

        display x

    end-if

    if n is not omitted

        display n

    end-if

    move 1 to r 

    goback.

end function f1.

 

p1.cbl

 

      $set sourceformat"free"

      $set iso2002

      $set repository"update on checking on"

program-id. p1 as 'p1'.

environment division.

configuration section.

repository.

    function f1.

linkage section.

01    x                pic x(10).

01    n                 binary-long.

procedure division using x returning n.

    display x

    compute n = f1(x omitted)

    goback.

end program p1.

p0.cbl

      $set sourceformat"free"

      $set iso2002

      $set repository"update on checking on"

program-id. p1 as 'p1' is prototype.

linkage section.

01    x                pic x(10).

01    n                 binary-long.

procedure division using x returning n.

end program p1.

program-id. p0.

environment division.

configuration section.

repository.

    program p1.

data division.

working-storage section.

01  x10             pic x(10).

01    results            binary-long.

01  bad                pic x(80).

procedure division.

    call p1 using x10 returning results

    goback.

end program p0.

 

Best answer by Chris Glazier

The prototyping works fine.

If you change the call statement to what I showed you it will compile without error.

If you change the call statement so that it doesn’t conform to the prototype you will get an error.

If I change your call statement to :
        call "p1" using x10 results returning results

The following error is generated:

“Parameter results is not consistent with that defined in prototype: category/usage mismatch”

and 

“Number of input parameters is greater than in prototype: 2 parameter(s) found but prototype specifies 1”

4 replies

Chris Glazier
Forum|alt.badge.img+3

The problem is in the call statement. The program name should be a literal or a data-name.

change it to:

call "p1" using x10 returning results

and it works fine.


Frank Swarbrick
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • March 26, 2026

I am trying to use the “call program-prototype” format.  Which, now that I look, is not documented as a feature.  I assumed it was, since program prototypes are supported (The Program-ID Paragraph Format 4).  This is a new feature in the ISO 2002 and 2014 COBOL standards.  It’s supposed to allow for checking “conformance for parameters and returning items”.

If the ability to call via program prototype is not supported then what is the use of defining a program prototype?


Chris Glazier
Forum|alt.badge.img+3
  • Moderator
  • Answer
  • March 27, 2026

The prototyping works fine.

If you change the call statement to what I showed you it will compile without error.

If you change the call statement so that it doesn’t conform to the prototype you will get an error.

If I change your call statement to :
        call "p1" using x10 results returning results

The following error is generated:

“Parameter results is not consistent with that defined in prototype: category/usage mismatch”

and 

“Number of input parameters is greater than in prototype: 2 parameter(s) found but prototype specifies 1”


Frank Swarbrick
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • March 27, 2026

OK, I got you.  My issue is I’ve been “studying” the new COBOL standards for about 25 years, but until now haven’t been able to work with anything that complies with the standard in any way.  I believe that according to the standard, the way I had it should work.  The data-name p1 is a ‘program-specifier’ declared in the repository as being a program.  So doing a call of p1 (rather than ‘p1’) should work.  But I guess Rocket isn’t following the standard in this regard.  It does make me wonder what the use of the program-specifier in the repository is.  It isn’t required for conformance checking, and it doesn’t work in the CALL statement, so what is it for?