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
 

 

internal table in cobol

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

New User


Joined: 05 Jun 2007
Posts: 24
Location: kerala

PostPosted: Fri Dec 18, 2009 10:10 am    Post subject: internal table in cobol
Reply with quote

I have an internal table in cobol declared as follows

01 ws-inter-table
03 ws-table-struct occurs 100 times.

I have moved values into this table. And suppose I am accessing the ws-table-struct[0] what would be it contain? Can I refer table elements like this.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 18, 2009 10:16 am    Post subject:
Reply with quote

Hello,

It is not clear what you are asking. . .

"ws-table-struct[0]" is invalid.

You can use a numeric literal for a subscript but you would use "ws-table-struct(n)" and n should be > zero and < 101.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Dec 18, 2009 10:16 am    Post subject:
Reply with quote

I suggest spend some time in reading manuals for this

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/IGYPG204/1.4?DT=19990113230517

OR
try yourself and let us know if you are not clear with anything...
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Fri Dec 18, 2009 4:03 pm    Post subject:
Reply with quote

The answer to your question is ... it depends.

If the compiler option SSRANGE was set when the program is compiled, COBOL checks for and does not allow any reference to an element of the table outside the defined range (1 to 100 in your case). If you attempt to do so, you get an error message.

If this compiler option was not set, then accessing a table element outside the defined range may -- and may not -- access data within your program or other memory locations. Typically such memory access is not good, may cause abends, but is not prevented by the system.
Back to top
View user's profile Send private message
ridgewalker58

New User


Joined: 26 Sep 2008
Posts: 51
Location: New York

PostPosted: Sat Dec 19, 2009 8:07 am    Post subject:
Reply with quote

As Mr. Sample has stated -- you would be able to access the space that preceeds the table by using a SUBSCRIPT with a value of ZERO.

Example: 01 WS-HOLD-AREA PIC X(02) VALUE SPACES.
01 WS-SUB1 PIC 9(04) COMP VALUE ZERO.
01 WS-TEST-FIELD PIC X(05) VALUE 'ABCDE'.
01 WS-TABLE.
05 WS-TBL-ENTRIES OCCUR 20 TIMES.
10 WS-TBL-FLD1 PIC X(03).
10 WS-TBL-FLD2 PIC X(02).

MOVE WS-TBL-FLD2 (WS-SUB1) TO WS-HOLD-AREA.
>>>>> WS-HOLD-AREA WOULD NOW CONTAIN 'DE'
>>>>> YOU HAVE MOVED 2 BYTES THAT PRECEED THE TABLE TO
WS-HOLD-AREA
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Dec 19, 2009 8:33 am    Post subject:
Reply with quote

Hello,

Quote:
>>>>> WS-HOLD-AREA WOULD NOW CONTAIN 'DE'
Did you test this?

While the code may not abend, WS-HOLD-AREA may also not have DE (unless the compiler has been changed and i didn't get the memo icon_smile.gif )
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sat Dec 19, 2009 10:10 am    Post subject:
Reply with quote

Quote:
WS-HOLD-AREA WOULD NOW CONTAIN 'DE'

As Dick indicates, if the 2 bytes before the start of WS-TABLE contain 'DE' after the MOVE, it would be a miraculous coincidence. For one thing, since 01 levels are double word aligned, there are 3 bytes of data that occur after 'ABCDE' that probably contain X'000000' with the Enterprise compiler, but there's no guarantee of that. For another, there's no guarantee that WS-TABLE immediately follows the 8 bytes where WS-TEST-FIELD begins. This information is available in the COBOL Language Reference manual.
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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm


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