Skip to main content
Question

procedure division header where define the varible

  • February 26, 2026
  • 1 reply
  • 15 views

M Carmen De Paz
Forum|alt.badge.img+2
Good morning, I have been working in COBOL for over 20 years and I have always believed that when a main program (PA) calls a second program (PB) using `CALL PB USING field1 field2 field3` and the procedure in PB is `PROCEDURE USING field1 field2 field3`, the parameters that are put in the `using` procedure of a program (PB) should be defined in the `linkage` section, but I see in the documentation this“ Data-name-1 must be defined as a level 01 or a level 77 entry in the Linkage Section , File Section or Working-Storage Section”
This raises a lot of questions for me.
Has this always been the case? If the variables in PB are defined in the working storage section, what relationship do the variables in PA have with those in PB? How does assigning values ​​to variables in PB affect the variables defined in PA? Could the call be made from PA without passing those parameters?

1 reply

Chris Glazier
Forum|alt.badge.img+3
  • Moderator
  • February 26, 2026

Hello,

This is a Rocket COBOL extension.

When you pass a parameter to a subprogram and the subprogram’s procedure division using statement specifies the parameter in the working-storage or file-section then it is  as if the parameter were actually passed in the linkage section and then its contents are moved to the data item in working-storage or the file section. If you modify this item in the subprogram, it will not affect the parameter in the main program. This is documented under General rules for format 1 of the procedure division header USING statement, general rules 4 which states:

 

rocket If data-name-1 is defined as a level 01 or a level 77 entry in the File Section or Working-Storage Section then the activated runtime element operates as if a data item had been declared in the Linkage Section with the same data declaration as data-name-1 and the contents of that data item were moved to data-name-1 prior to executing the first statement in the activated runtime element. In an initial program, these values are overwritten by the initialization of the program's working storage data and are therefore not available to the called program.

 


It is possible to share a data-item between a main program and a subprogram without passing it on the CALL statement by specifying the data item as being EXTERNAL in both programs.

01 my-param  pic x(5) external.

When you share data like this it means that the data item does not belong to any one program but can be shared between all programs in the run-unit defining it this way.