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

Problem with Pointer usage


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

New User


Joined: 07 Feb 2007
Posts: 61
Location: Mumbai

PostPosted: Thu Feb 25, 2010 5:15 pm
Reply with quote

Hi,
I have a code like this:

W-S SECTION
01 WS-POINTER USAGE IS POINTER.

L-S SECTION
01 L-ADDRESS USAGE IS POINTER.
01 L-VARIABLE PIC X(8).

PROCEDURE DIVISION USING L-ADDRESS.
SET ADDRESS OF L-VARIABLE TO L-ADDRESS.
SET WS-POINTER TO L-ADDRESS.
SET WS-POINTER UP BY LENGTH OF L-VARIABLE.

I am getting an error like this:
"The receiving operand "WS-POINTER" in the "SET" statementwas an invalid type. The statement was discarded."

I have verified the IBM manuals and found it to be a valid usage.
Link:
Type_Description_Herehttp://publib.boulder.ibm.com/infocenter/iadthelp/v6r0/index.jsp?topic=/com.ibm.etools.iseries.pgmgd.doc/c0925405287.htm

Kindly let me know if have coded something wrong.

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

New User


Joined: 07 Feb 2007
Posts: 61
Location: Mumbai

PostPosted: Thu Feb 25, 2010 5:17 pm
Reply with quote

Sorry this is the right link:
http://publib.boulder.ibm.com/infocenter/iadthelp/v6r0/index.jsp?topic=/com.ibm.etools.iseries.pgmgd.doc/c0925405287.htm
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Feb 25, 2010 5:27 pm
Reply with quote

Since you have two SET WS-POINTER statements in the code you posted, which one is giving the compile error?
Back to top
View user's profile Send private message
manikawnth

New User


Joined: 07 Feb 2007
Posts: 61
Location: Mumbai

PostPosted: Thu Feb 25, 2010 5:28 pm
Reply with quote

The last statement where i'm using UP BY
SET WS-POINTER UP BY LENGTH OF L-VARIABLE.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Feb 25, 2010 5:32 pm
Reply with quote

There is a link to the z/OS COBOL manuals at the top of this page. The link you provided is for AS/400 -- which means it is useless for z/OS. If you click on the manuals link, pull up the COBOL Language Reference manual, go to section 6.2.33.5, you will find that USAGE IS POINTER variables cannot be SET UP or DOWN. The compiler is correct and your statement that this structure is allowed is not correct.
Back to top
View user's profile Send private message
manikawnth

New User


Joined: 07 Feb 2007
Posts: 61
Location: Mumbai

PostPosted: Thu Feb 25, 2010 5:40 pm
Reply with quote

Hi,

Thanks for pointing it out.
At the same time could you please let me know if there is any way to increment the address (value) in a pointer data item.

Thanks,
Manikanth
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: Thu Feb 25, 2010 5:40 pm
Reply with quote

Redefine WS-POINTER as PIC 9(09) COMP (such as WS-POINTER-FWORD) and replace -

Code:

SET WS-POINTER UP BY LENGTH OF L-VARIABLE.

with -

Code:

ADD LENGTH OF L-VARIABLE TO WS-POINTER-FWORD.

Bill
Back to top
View user's profile Send private message
manikawnth

New User


Joined: 07 Feb 2007
Posts: 61
Location: Mumbai

PostPosted: Thu Feb 25, 2010 5:48 pm
Reply with quote

I really tried it first and found it failed.
It was my mistake not to define the POINTER on a quad-word boundary.

Any ways thanks a lot to every one for your quick turn-around.

Thanks again,
Manikanth
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: Thu Feb 25, 2010 5:51 pm
Reply with quote

Yes, COBOL "01" levels are doubleword (quadword) aligned, regardless whether they're defined to WORKING-STORAGE or LINKAGE.

Bill
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts STEM usage in REXX CLIST & REXX 14
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts z/OS Modules Usage report using SMF 42 DFSORT/ICETOOL 2
Search our Forums:

Back to Top