Linkage area variable declaration



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Linkage area variable declaration

Postby sinmani » Fri Mar 23, 2012 5:53 pm

If by mistake while coding I MOVE a working storage variable into LINKAGE area. What will happen??
will I get compilation error?
What when i try to pass values through linkage section?
-----------------------------------------
As long as you think you are a student, you are doing well.
The day you consider yourself as the master of the game..........well
sinmani
 
Posts: 93
Joined: Thu Mar 22, 2012 10:02 am
Has thanked: 14 times
Been thanked: 0 time

Re: Linkage area variable declaration

 

Re: Linkage area variable declaration

Postby BillyBoyo » Fri Mar 23, 2012 6:06 pm

If you accidently define something in Linkage which should be in Working-Storage, you won't get a compile error (the compiler doesn't know) but you'll certainly get a run-time error if you attempt to access that storage.

Why don't you try it out, before asking?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Linkage area variable declaration

Postby Robert Sample » Fri Mar 23, 2012 6:48 pm

Think about the purpose of LINKAGE SECTION. It is defining storage being passed to this program from somewhere else (another program or the system). Hence, there is absolutely no way to know at compile time if a given reference to LINKAGE SECTION variable is valid or not. And at execution time, if there's no memory allocated for those items and you attempt to use them ... plan on an ABEND!
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Linkage area variable declaration

Postby sinmani » Fri Mar 23, 2012 8:36 pm

well actually I tried it out before asking.

I tried modifying the WS variable by moving some value in it and it didn't give me any abend??
Thats what puzzled me :(
-----------------------------------------
As long as you think you are a student, you are doing well.
The day you consider yourself as the master of the game..........well
sinmani
 
Posts: 93
Joined: Thu Mar 22, 2012 10:02 am
Has thanked: 14 times
Been thanked: 0 time

Re: Linkage area variable declaration

Postby Akatsukami » Fri Mar 23, 2012 8:51 pm

sinmani wrote:If by mistake while coding I MOVE a working storage variable into LINKAGE area. What will happen??
will I get compilation error?
What when i try to pass values through linkage section?

I understand you to have coded something like
 DATA DIVISION.
 WORKING-STORAGE SECTION.
 01  WS-FOO  PIC X(9).
 01  WS-BAR  PIC 9(9).
 LINKAGE SECTION.
 01  PARM    PIC 9(9)
 PROCEDURE DIVISION.
 A-PARAGRAPH.
     MOVE WS-FOO TO PARM
*  SHOULD HAVE BEEN "MOVE WS-BAR TO PARM"

whereas Messrs. Boyo and Sample seem to understand you as having coded
 DATA DIVISION.
 WORKING-STORAGE SECTION.
 01 WS-BAR  PIC 9(9).
 LINKAGE SECTION.
 01 PARM    PIC 9(9).
 01 WS-FOO  PIC X(9).
* SHOULD HAVE GONE IN WORKING-STORAGE SECTION.

Please explain which it is.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Linkage area variable declaration

Postby sinmani » Fri Mar 23, 2012 10:44 pm

The second one!!! :)
-----------------------------------------
As long as you think you are a student, you are doing well.
The day you consider yourself as the master of the game..........well
sinmani
 
Posts: 93
Joined: Thu Mar 22, 2012 10:02 am
Has thanked: 14 times
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post