Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Linkage section variable address is invalid

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
lvbntapasvi

New User


Joined: 20 Jul 2006
Posts: 30

PostPosted: Tue Mar 22, 2011 1:10 pm    Post subject: Linkage section variable address is invalid
Reply with quote

I am calling a program B from A, and a variable X is defined in both the programs in Linkage section.

I move some value to this variable X in program B and return the control to prgram A. After the control returns from B to A, when I try to access the variable, I can see an error message in the Debugger tool, which says that the address of the variable is not valid.

But the same works fine when the variable X is defined in the working storage section of the program A. Under this condition, the variable value is successfully shown in program A after the control returns to A.

If it has to work in such a way that the variable X shud be defined in working storage section of A and linkage of B, then how to access this variable if I need to use the same in a program C. More precisely saying

Program C -> Program A -> Program B

Please advise. Thanks in advance.
Back to top
View user's profile Send private message

rakesh1155

New User


Joined: 21 Jan 2009
Posts: 84
Location: India

PostPosted: Tue Mar 22, 2011 3:14 pm    Post subject:
Reply with quote

Quote:
If it has to work in such a way that the variable X shud be defined in working storage section of A and linkage of B, then how to access this variable if I need to use the same in a program C. More precisely saying

Program C -> Program A -> Program B


Is there anything stopping you from doing a move from the Linkage Section of A to Working Storage Section of A (in the program A) and then use it for calling program B.

The same should apply to program C and program A.


-Rakesh.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8120
Location: East Dubuque, Illinois, USA

PostPosted: Tue Mar 22, 2011 4:40 pm    Post subject:
Reply with quote

Variables in LINKAGE SECTION do not have any storage defined for them in the program. The storage for these variables, and presumably the values, comes from the CALLING program. When program A is the main program, and you place a variable in its LINKAGE SECTION, the behavior you see is what is expected -- since there is no calling program, the variables in LINKAGE SECTION cannot be referenced since they have no storage associated with them.

Variable X should be defined in WORKING-STORAGE of C, LINKAGE SECTION of A, and LINKAGE SECTION of B -- as long as program C calls program A calls program B. The basic rule is that every variable in a LINKAGE SECTION must be defined in some WORKING-STORAGE section (except for data passed from JCL via PARM=).
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 757
Location: Germany

PostPosted: Tue Mar 22, 2011 4:46 pm    Post subject:
Reply with quote

Morning Sir !

>> I am calling a program B from A, and a variable X is defined in both the programs in Linkage section.

Why defined in LinkageSection in both programms? Sending programm A, field in WorkingStorage. Called programm B, field in LinkageSection.

In fact that you don't use External Copybook. Using External, read more in IBM literature.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 757
Location: Germany

PostPosted: Tue Mar 22, 2011 4:47 pm    Post subject:
Reply with quote

Sorry robbert , I'm to late.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8120
Location: East Dubuque, Illinois, USA

PostPosted: Tue Mar 22, 2011 4:50 pm    Post subject:
Reply with quote

As long as we're saying the same thing, UmeySan, the order doesn't matter! icon_smile.gif
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Wed Mar 23, 2011 1:17 pm    Post subject:
Reply with quote

And don't forget to include the area identifiers in the USING statements in the CALL statements and in entry point definitions (PROCEDURE stetement).

Number of arguments and their sequence is important!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IP Address of workstation martin9 CICS 3 Fri Jun 23, 2017 7:39 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts RC 20 for Address ISPEXEC "ISRED... pkmurali CLIST & REXX 3 Sun Apr 16, 2017 11:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us