Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 2504
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: 112
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 sharing PLI storage Pedro PL/I & Assembler 2 Mon Oct 16, 2017 10:11 pm
No new posts LIBDEF not working in called proc packerm CLIST & REXX 0 Fri Sep 15, 2017 7:22 pm
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us