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
 

 

Data Moving by using COBOL pointer variables

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

New User


Joined: 02 Aug 2011
Posts: 17
Location: India

PostPosted: Wed Sep 14, 2011 2:18 pm    Post subject: Data Moving by using COBOL pointer variables
Reply with quote

Hi All,

I have two variables with data as below.

01 WS-AB PIC X(02) VALUE 'AB'.
01 WS-CD PIC X(02) VALUE 'CD'.
I like to refer data 'CD' to variable WS-AB by using cobol pointers.

Please let me know how can I achieve this.

Thanks
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Wed Sep 14, 2011 2:31 pm    Post subject: Reply to: Data Moving by using COBOL pointer variables
Reply with quote

It is unclear from your description what it is that you want.

Why do you want to do it?

What do you want to achieve?

What is wrong with MOVE?
Back to top
View user's profile Send private message
Eshwar CICS

New User


Joined: 18 May 2011
Posts: 47
Location: India

PostPosted: Wed Sep 14, 2011 2:36 pm    Post subject: Reply to: Data Moving by using COBOL pointer variables
Reply with quote

Are the variables which you have mentioned reside in working storage?
Back to top
View user's profile Send private message
satishboddu

New User


Joined: 02 Aug 2011
Posts: 17
Location: India

PostPosted: Wed Sep 14, 2011 3:02 pm    Post subject: Reply to: Data Moving by using COBOL pointer variables
Reply with quote

Hi All,

I have two variables with data as below.

01 WS-AB PIC X(02) VALUE ‘123’.
01 WS-CD PICX(02) VALUE ‘345’
01 WS-F PIC X(08) VALUE.

MOVE “WS-AB” to WS-F, is populated in another program.

Based on variable name that’s in WS-F, we want to retrieve the value of that variable.
Suppose, we have WS-AB as variable in WS-F, we need 123 and if WS-CD in the variable, we are looking for 345.

I have heard pointers can be used to do this.

Please suggest ..
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Sep 14, 2011 3:17 pm    Post subject: Reply to: Data Moving by using COBOL pointer variables
Reply with quote

since in any case You have to use an if to <load> the pointer with the proper address why bother
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Wed Sep 14, 2011 3:27 pm    Post subject: Reply to: Data Moving by using COBOL pointer variables
Reply with quote

There is no fancy way to dynamically obtain the address/contents of a Cobol data-name from a piece of text.

Test the value of the text, and code out the MOVEs for the appropriate value.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Sep 14, 2011 4:26 pm    Post subject:
Reply with quote

another case of pc language skills - not able to read the manual.

cobol resolves the contents of areas indirectly addressed by use of pointers.

cobol always treats the contents of a variable as the contents of a variable.

cobol treats the contents of a pointer as the address of a variable.

that is the way that it is done.
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: Wed Sep 14, 2011 4:38 pm    Post subject: Reply to: Data Moving by using COBOL pointer variables
Reply with quote

Using POINTER's to address WS fields was not introduced until OS/390 COBOL 2.2.1, about 10-12 years ago.

If your COBOL version/release is less than the above, then you're out of luck.

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Sep 14, 2011 5:29 pm    Post subject:
Reply with quote

Bill,
you are correct.

COBOL 2 still disallows SETing a POINTER TO ADDRESS OF Variable in W-S.

but, you can CALL a module with two parms in the using list:
W-S
POINTER

and the CALLed module simply SETs the POINTER in linkage TO ADDRESS OF Variable in linkage,
and returns.
Back to top
View user's profile Send private message
Eshwar CICS

New User


Joined: 18 May 2011
Posts: 47
Location: India

PostPosted: Wed Sep 14, 2011 5:37 pm    Post subject:
Reply with quote

Satish,

My opinion is that compiler has no role to play in this context.Basically get clarity on how working storage gets allocated and understand how pointers can be used in COBOL w.r.t linkage variables.Then you can decide on the feasibility of implementing your requirement. Thanks.
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: Wed Sep 14, 2011 7:38 pm    Post subject: Reply to: Data Moving by using COBOL pointer variables
Reply with quote

Dick,

Yes, you're right.

Many moons ago, had both an Assembler sub-program and COBOL sub-program which did this.

But to tell you the truth, I still don't know what the OP is trying to accomplish.

If the concept of obtaining addresses and traversing control blocks is foreign to the OP, my suggestion is to stay away from this and KISS.

As Bill W. expressed, what's wrong with a MOVE?

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Sep 14, 2011 8:01 pm    Post subject:
Reply with quote

you can do that kind of silliness in java, c, c+, vb.
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 Unwrap the data based on delimiter X'25' bhavana yalavarthi DFSORT/ICETOOL 1 Fri Dec 09, 2016 10:25 am
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm


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