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
 

 

Can we use linkage section variables in Arithmetic operation

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

New User


Joined: 14 Dec 2011
Posts: 11
Location: India

PostPosted: Thu Apr 12, 2012 8:53 pm    Post subject: Can we use linkage section variables in Arithmetic operation
Reply with quote

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
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Thu Apr 12, 2012 8:57 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Thu Apr 12, 2012 8:59 pm    Post subject: Reply to: Can we use linkage section variables in Arithmetic
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Apr 12, 2012 10:23 pm    Post subject: Reply to: Can we use linkage section variables in Arithmetic
Reply with quote

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
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Thu Apr 12, 2012 11:11 pm    Post subject: Re: Can we use linkage section variables in Arithmetic opera
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Apr 12, 2012 11:44 pm    Post subject: Reply to: Can we use linkage section variables in Arithmetic
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Fri Apr 13, 2012 12:31 am    Post subject: Reply to: Can we use linkage section variables in Arithmetic
Reply with quote

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
View user's profile Send private message
Chiranjeevi9

New User


Joined: 14 Dec 2011
Posts: 11
Location: India

PostPosted: Fri Apr 13, 2012 4:32 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Apr 13, 2012 7:04 pm    Post subject: Reply to: Can we use linkage section variables in Arithmetic
Reply with quote

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. icon_rolleyes.gif

Apparently, you're going to have to learn from your assumptions....
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Apr 13, 2012 8:38 pm    Post subject:
Reply with quote

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
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 Performing arithmetic on input field zh_lad DFSORT/ICETOOL 24 Tue Dec 06, 2016 8:04 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts Joinkeys operation betwen VB and FB file Susanta SYNCSORT 4 Sun Sep 25, 2016 9:49 pm
No new posts Is it possible to pass variables of s... Csongor CLIST & REXX 2 Fri Jun 10, 2016 7:33 pm


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