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
 

 

Variable declaration in LINKAGE and WORKING STORAGE section

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Variable declaration in LINKAGE and WORKING STORAGE section
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Fri Mar 09, 2012 2:48 pm    Post subject: Reply to: About variable declaration in LINKAGE AND WORKING
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Mar 09, 2012 6:01 pm    Post subject: Reply to: About variable declaration in LINKAGE AND WORKING
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: 110
Location: Puerto Rico

PostPosted: Fri Mar 09, 2012 7:23 pm    Post subject:
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    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 Restart=Step not working ALAK SAHA JCL & VSAM 6 Fri Jun 30, 2017 6:28 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm


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