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

Variable declaration in LINKAGE and WORKING STORAGE section


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Fri Mar 09, 2012 2:32 pm
Reply with quote

For instance,
if i want to execute below sql statement in a subprogram :
Code:
EXEC SQL                             
   FETCH  ABSOLUTE :START-ROW-POS   
    FROM  CURCBKOPCS01               
    INTO :CBDOPCS-DESC               
END-EXEC                             


and if I declare host variable START-ROW-POS in LINKAGE section, and I pass a value to it from main program, SQLCODE of above sql statement after execution is always 100. (but actually, if START-ROW-POS is received by SQL, a record can be retrieved.)

while if I declare host variable START-ROW-POS in WORKING STORAGE SECTION , and I move a value to it from a linkage section variable, above SQL statement can be executed as expected.


confused by this phenomena, can anybody explain???

in addition, variables declared in linkage section have no addressability?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Mar 09, 2012 2:48 pm
Reply with quote

See if this gives you anything to start your research with.

In addition, Linkage Section data has addressability for each that you give addressability. Your PROCEDURE DIVISION USING gives addressability to each 01 (or, never done it, 77) named. You may also get addressability using SET, but start slowly, and don't imagine that SET will help you with your particular problem. Concentrate on the above topic, and understanding that.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Fri Mar 09, 2012 6:01 pm
Reply with quote

Please review some of your previous posts (as well as others) to the PL/I - Assembler board regarding Assembler questions, concentrating on questions/replies to DSECT's.

Assembler DSECT's (known as Dummy Sections) and COBOL Linkage Sections are very much (but not exactly) the same, but, close enough for general comparison.

Basically, you can't address any piece of storage in a DSECT or Linkage Section until the target storage has been given addressability.

The keyword here is "Dummy". As soon as you can understand this concept, a light bulb will go off in your head and you'll say to yourself "OK, now I've got it".

Good Luck,

Mr. Bill
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 121
Location: Puerto Rico

PostPosted: Fri Mar 09, 2012 7:23 pm
Reply with quote

Good day to all!

I just want to add that working-storage is a local storage to each individual program. The Linkage section is your dynamic storage which you need to set addressability like Bill mention in your sub-programs in order to have accessibility to the variables in your sub-programs.
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 CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
Search our Forums:

Back to Top