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
 

 

What will happen if we move values to zero subscript variab?

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

New User


Joined: 29 Jan 2007
Posts: 33
Location: chennai

PostPosted: Fri Apr 25, 2008 1:58 pm    Post subject: What will happen if we move values to zero subscript variab?
Reply with quote

In Cobol array concept,ie., OCCURS CLAUSE

What will happen if we try to execute the below statement..

say ,

MOVE '2' TO EXAMPLE(0)

ie., moving the value to Zero subscript variable. Will that be possible to move to Zero subscript variables ?
Back to top
View user's profile Send private message

ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri Apr 25, 2008 2:15 pm    Post subject:
Reply with quote

Hi,

The lowest possible subscript value is 1 which points to first item in the table.

for your query y dont you try it out and see what happens ?
Back to top
View user's profile Send private message
mymains
Currently Banned

New User


Joined: 24 Apr 2008
Posts: 5
Location: Banglore

PostPosted: Fri Apr 25, 2008 2:45 pm    Post subject:
Reply with quote

i think it is possible to move the value to the subscript .
thnkz
mymains
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Apr 25, 2008 3:02 pm    Post subject:
Reply with quote

Quote:

i think it is possible to move the value to the subscript


since a subscript is just a numeric field, the obvious answer is yes.

The subject had you bothered to read the OP post is what will happen
Quote:

MOVE '2' TO EXAMPLE(0)


The execution of an instruction (without the SSRANGE options on) with a zero subscript is an excpetion - error.

But even if the SSrange Options are off, and your instruction with a 0 value in the subscript executes without error, you will not populate the table being subscripted - you will populate an area before the defined cobol internal table.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Apr 25, 2008 3:04 pm    Post subject:
Reply with quote

I don't think that an instruction with a literal value of 0 as the index value will compile.

with a subscript, you can even use negative values, if the SSRANGE option is off.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Fri Apr 25, 2008 7:38 pm    Post subject:
Reply with quote

I agree with Dick, the code won't compile if you code (0) in the subcript.
However you can do this
Code:
  move 0 to sub
  move '2' to EXAMPLE(sub)

this should compile and it will populate area before the array.
I have seen typical use of such 'tricky' code to get the RDW of variable length record. If you are trying to do the same, use the RECORD IS VARYING clause of COBOL instead.
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 Apr 25, 2008 8:21 pm    Post subject: What will happen if we move values to zero subscript variab?
Reply with quote

Agkshirsagar,

You're very correct with that statement as it applies to COBOL2 and greater.

I remember trying this, by setting the subscript to ZERO, in a COBOL2 environment about 20 years ago and it did NOT work.

FWIW, this trick was outlined in both of Harvey Bookman's COBOL2 and COBOL/370 books (from the J. Ranade series / McGraw Hill), late 80's / early 90's.

Harvey has since retired.

Regards,

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

New User


Joined: 29 Jan 2007
Posts: 33
Location: chennai

PostPosted: Sat Apr 26, 2008 9:00 am    Post subject: Reply to: What will happen if we move values to zero subscri
Reply with quote

Thanks for all your responses.. I will give a try and let u know..
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 SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 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
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm


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