View previous topic :: View next topic
|
Author |
Message |
lvbntapasvi
New User
Joined: 20 Jul 2006 Posts: 30
|
|
|
|
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 |
|
|
rakesh1155
New User
Joined: 21 Jan 2009 Posts: 84 Location: India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
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 |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Sorry robbert , I'm to late. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
As long as we're saying the same thing, UmeySan, the order doesn't matter! |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
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 |
|
|
|