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
 
How to declare an array dynamically in cobol

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

New User


Joined: 15 Jun 2005
Posts: 5

PostPosted: Mon Jun 20, 2005 9:03 pm    Post subject: How to declare an array dynamically in cobol
Reply with quote

Hi,

Is there any way in Cobol to declare the array dyanamically. Because this time if you array size as 100, and later if this size has to be increased...all we need to do is change the size in the program. Instead is it possible to declare the array dynamically so that programs need not be changed later on for the size. So that program should allocate by itself dyanamically as much size as required.
Back to top
View user's profile Send private message

somasundaran_k

Active User


Joined: 03 Jun 2003
Posts: 134

PostPosted: Mon Jun 20, 2005 10:07 pm    Post subject:
Reply with quote

Revan
You can't have a dynamic array in COBOL by it's true meaning. But you can create a variable length array ,if you know the maximum possible size of it.
Check this link.
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG00/1.4.5?DT=20011203125201

hth
-Som
Back to top
View user's profile Send private message
Jagamohan

New User


Joined: 17 Jun 2005
Posts: 13
Location: Mumbai

PostPosted: Wed Jun 22, 2005 1:54 pm    Post subject:
Reply with quote

hi revan
u can use depending on clause.

but any way u have to specify max size in the occur clause.

So you can give any higher value there for ur need.

thanks
jagamohan
Back to top
View user's profile Send private message
Prasanthhere

Active User


Joined: 03 Aug 2005
Posts: 306

PostPosted: Mon Aug 08, 2005 12:26 pm    Post subject:
Reply with quote

the only way 2 declare a dyanamic array is thru using the depending clause
its format is as follows

The OCCURS DEPENDING ON clause specifies variable-length tables;All data-names used in the OCCURS clause can be qualified; they cannot be subscripted or indexed.

The following fragment from an invoice record demonstrates the concept:

05 ws-array PIC 99.
05 ws-array OCCURS 0 TO 25 TIMES
DEPENDING ON ws-array.
10 QUANTITY PIC 9999.
10 DESCRIPTION PIC X(30).
10 UNIT-PRICE PIC S9(5)V99
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Changing sort Card Dynamically vickey_dw DFSORT/ICETOOL 5 Sat Aug 19, 2017 2:33 pm
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm

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