linkage section of calling and called program



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

linkage section of calling and called program

Postby manacm » Thu Apr 10, 2014 8:46 am

I am facing some memory overlay issues(feel so) .I have "A" program which calls "B" program
"A" program's linkage section is passed to "B" program.Whether both share the same memory section?

The calling and called program uses the same no. of variables.
But linkage section has more variables in the "B" program than the called program.Whether that cause a problem?
For e.g. Copybook group variable(not passed from "A" program,but present in linkage section of "B" PROGRAM)is initialized in "B" program.

For e.g.
"A" program
Identification division
environment division
data division
linkage section
01 ls-parms(includes pointer area)
copy a1
copy a2
copy a3

procedure division
.....
call "B" program using ls-parms
......

"B" program

Identification division
environment division
data division
linkage section
01 ls-parms(includes pointer area)
copy c1
copy c2
copy c3
copy c4


procedure division
.....
set address of c4 using pointer area
initialize c4-area
......

When initializing c4-area ,a1's area is getting corrupted....not sure what is the issue....

Can you please help me out on this...
manacm
 
Posts: 1
Joined: Thu Apr 10, 2014 8:33 am
Has thanked: 0 time
Been thanked: 0 time

Re: linkage section of calling and called program

Postby Robert Sample » Thu Apr 10, 2014 9:15 am

First, you are completely confused about the COBOL LINKAGE SECTION. From the Language Reference manual:
Record description entries and data item description entries in the linkage section provide names and descriptions, but storage within the program or method is not reserved because the data area exists elsewhere.
Unless your "A" program is called from another program, or it is referencing parameters passed from the JCL, there is no reason for program "A" to even have a LINKAGE SECTION.

Second, you have NOT described nearly enough about the programs and their use of arguments / parameters to be able to answer your question for sure. For example, if your COPY A1 ... COPY A2 ... COPY A3 are bringing in 01 level variables, then your CALL statement must reference each 01 structure separately, and program "B"'s PROCEDURE DIVISION USING should reference each as well. Also, you can run into problems if your calling program "A" and called program "B" reference different amounts of data.

The bottom line: most likely your storage problems are caused by your coding of the parameter lists in the programs as well as how you are using the values. There is plenty of material in the manuals on passing data between COBOL programs; a close study of this material would resolve many storage problems before they occur.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post