Question

I have the following call statement :

038060     CALL        PROG USING
038070                 DFH
038080                 L000
038090                 ZONE-E
038100                 ZONE-S.

This call is dynamic and use PROG.

PROG is a group defined as :

018630 01                 XX00.
018640        10          PROG.
018650         15         XX00-S06  PICTURE X(6)
018660                         VALUE  SPACE.
018670         15         XX00-S02  PICTURE X(2)
018680                         VALUE  SPACE.
018690        10          XX00-S92  PICTURE 9(02)
018700                         VALUE  ZERO.
018710        10          XX00-S91  PICTURE 9(1)
018720                         VALUE  ZERO.
018730        10          XX00-S9Z PICTURE 9(1)
018740                         VALUE  ZERO.
018750        10          XX00-9B0 PICTURE X(05)
018760                         VALUE  SPACE.
018770        10          XX00-0B0 PICTURE X(02)
018780                         VALUE  SPACE.
018790        10          XX00-BB1 PICTURE X(01)
018800                         VALUE  SPACE.
018810        10          XX00-SFN PICTURE X(07)
I cut here but there is a lot of field after...

It seems that actual progname to use is stored in :

XX00-S06

and

XX00-S02

I've also other cases where the name is on 3 or 4 fields, and the progname length is not always 8.

So my question is how Cobol know where to pick the good program name in the group? What are the resolution rules?

Configuration : I use Microfocus Net Express compiler and the environment is UniKix.

Was it helpful?

Solution

Dynamic call rules in COBOL are fairly simple. Given something like:

    CALL WS-NAME USING...

COBOL will resolve the program name currently stored in WS-NAME against the load module libraries available to it based on a linear search. The first matching load module entry point name that matches WS-NAME is used.

It doesn't matter how complex, or simple, the definition of WS-NAME is. The total length used for the name is whatever the length of WS-NAME is. For example:

   01 WS-NAME.
      05 WS-NAME-FIRST-PART     PIC X(3).
      05 WS-NAME-MIDDLE-PART    PIC X(2).
      05 WS-NAME-LAST-PART      PIC X(3).

WS-NAME is composed of 3 subordinate fields giving a total of 8 characters. You can populate these individually or just move something into WS-NAME as a whole. If the length of WS-NAME is less than 8 characters, the trailing characters will be set to spaces on any receiving field. For example:

  01 WS-SHORT-NAME.
     05 WS-SHORT-NAME-FIRST-PART          PIC X(4) VALUE 'AAAA'.
     05 WS-SHORT-NAME-LAST-PART           PIC X(2) VALUE 'BB'.

Here WS-SHORT-NAME is only 6 characters long. MOVING WS-SHORT-NAME to any longer PIC X type variable as in:

  MOVE WS-SHORT-NAME TO WS-NAME

Will result in WS-NAME taking on the value 'AAAABBbb' (note the two trailing spaces). During libary search for a matching entry point name, the trailing spaces are not significant so on the CALL statement you could use either:

  CALL WS-NAME

or

  CALL-WS-SHORT-NAME

And they will resolve to the same entry point.

I am not sure what the length rules are for MicroFocus COBOL but, for IBM z/os dynamically called program names cannot exceed 8 characters (if they do, the name is truncated to 8 characters).

OTHER TIPS

I will add little more to NeilB with specific information about Micro Focus COBOL.

fyi: PROGRAM-ID, ENTRY-POINTS are restricted to 30-31 characters (check your "System Limits and Programming Restrictions" section in the docs).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top