View previous topic :: View next topic
|
Author |
Message |
Chiranjeevi9
New User
Joined: 14 Dec 2011 Posts: 11 Location: India
|
|
|
|
Hi,
i have a question,
Can we use the linkage section variables in Arithmetic operations?
I have tried to search in different books. i didn't get it.
Practically, i have tried in two different systems. one system has accepted the arithmetic operations and another didn't accepted to do the arithmetic operations with linkage variables.
Please let me know the answer. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Of course you can use LINKAGE SECTION variables in arithmetic operations. However, it is up to you to ensure that the LINKAGE SECTION variables CAN be used at all -- by using them only after having PROCEDURE DIVISION USING .... in your code. and actually setting up your execution to define storage for the variables. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
How could you possibly not be able to, subject to Robert's points?
Can you show us the one that "didn't work"? |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
If addressability hasn't been established to the Linkage Variables, you'll get a S0C4 Protection Exception as soon as you attempt to use them.
Linkage Variables are akin to Assembler DSECT's. |
|
Back to top |
|
|
Peter cobolskolan
Active User
Joined: 06 Feb 2012 Posts: 104 Location: Sweden
|
|
|
|
From your post I read:
Quote: |
Practically, i have tried in two different systems. one system has accepted the arithmetic operations and another didn't accepted to do the arithmetic operations with linkage variables.
|
I hope the systems you refer to are z/OS or equivalent.
Did you understand the message produced by the compiler?
It says clearly, as in this message:
IGYSC2025-W "NUM1" or one of its subordinates was referenced, but "NUM1" was a
"LINKAGE SECTION" item that did not have addressability. This reference
will not be resolved successfully at execution.
Pls note the W in the message id, which indicates a Warning and gives a return-code of 4.
The message from the compiler will dissapear if you have a Procedure Division Using Num1 .
This is what Bill just mentioned. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Peter,
Some shops (for whatever reason) suppress W errors and only consider E and above and I think it's foolhardy.
IMHO, the compile option FLAG(I,I) should be specified, regardless, because W's are raised when (for example) a LINKAGE item is not included in the PROCEDURE "USING" and the (non)addressability message is raised.
An area that always should be addressed are redefined LINKAGE fields, where a redefined field exceeds the length of the field of which addressability is established and someone tries to use the longer field, but gets a S0C4. This type of redefine inconsistency error will be raised, either as an I or a W during compilation.
Bottom line is this; LINKAGE and WORKING-STORAGE are two entirely different sections, with LINKAGE being the more volatile.
Regards, |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I completely agree with Mr Bill about compiler messages. List them all. Check them all. Fix them all, if at all possible. I've been bitten personally by ignoring them and don't know anyone who hasn't. Once bitten, you know better.
The redefines which is bigger usually indicates a problem. In the working-storage, these days, it even generates extra storage. Having seen enough redefines which are too long, and none of them coded deliberately, they should always be fixed and almost exclusively are themselves wrong. They will not, in themselves, cause S0C4.
Not to forget that PROCEDURE DIVISION USING is no longer the only way of establishing addressability. If addressability is your problem and the items are not passed to you on a CALL, then you need to do something else, but without showing us the code in question it is difficult to hand-off to you what might turn out to be a bomb on a trigger-fuse. |
|
Back to top |
|
|
Chiranjeevi9
New User
Joined: 14 Dec 2011 Posts: 11 Location: India
|
|
|
|
Hi,
Thanks for the answers.
Hi Bill Woodger,
in plain COBOL program, if i use linkage variables in arithmetic operations, i didn't get any error.
In COBOL-CICS program, i got the Abend while runtime. When i removed the arithmetic operations on linkage section variables, it went through fine.
Long back, i read some where that, Linkage variables can not be used in arithmetic operations. i don't remember where i read, i am not able to find in google also now. Because of the above issue and my old bookish knowledge i got confused.
But, i got the answer from you that, we can use the linkage variables in arithmetic operations. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
I'm scratching my head and wondering how you came to this conclusion, without understanding all that we have explained, unless you have left out all the major considerations.
Apparently, you're going to have to learn from your assumptions.... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Long back, i read some where that, Linkage variables can not be used in arithmetic operations. |
As is proven over and over - one must be very careful about what one believes from some "reading" . . . Much that is available (especially via the internet) is simply wrong and worthless. Some is misunderstood due to an author's choice of wording or confusion by the reader.
Learning a few reliable and easily understood sources is better than grabbing "stuff" from just anywhere. |
|
Back to top |
|
|
|