IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Linkage section variable address is invalid


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Mar 22, 2011 4:40 pm
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: 771
Location: Germany

PostPosted: Tue Mar 22, 2011 4:46 pm
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: 771
Location: Germany

PostPosted: Tue Mar 22, 2011 4:47 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Mar 22, 2011 4:50 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Routing command Address SDSF to other... TSO/ISPF 2
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Variable Output file name DFSORT/ICETOOL 8
Search our Forums:

Back to Top