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
 

 

How does a dynamic array work

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

New User


Joined: 22 Dec 2008
Posts: 85
Location: US

PostPosted: Thu Aug 11, 2011 10:21 am    Post subject: How does a dynamic array work
Reply with quote

Hi All,

How does a dynamic array work?

I tried out the following tests using a dynamic array v/s static array -

Code:
ws-dyn-arr - 1 to 30 times depending on i, j
     ws-dyn-var x(30)

ws-sta-arr - 30 times
     ws-sta-var x(30)


Setting i and j as 10, I populated the arrays 10 X 10 times with 30'X' and 30'Y' (X and Y repeated 30 times).

The lengths are showing up as given below (expected) -

Code:
length of ws-dyn-arr = 3000 (10 X 10 X 30)
length of ws-sta-arr = 27000 (30 X 30 X 30)


On displaying the contents, both displayed X's and Y's. In case of dynamic, the values were contiguous and in case of static, fragmented (expected).

I moved 0 to i and j -

Code:
length of ws-dyn-arr = 0 (0 X 0 X 30) (logical)
length of ws-sta-arr = 27000 (30 X 30 X 30)


On displaying the contents, the dynamic array didnt have any value. Static array displayed all Y's (again, as expected)

Now the interesting part, I moved 10 back to i and j

Code:
length of ws-dyn-arr = 3000 (10 X 10 X 30) (logical)
length of ws-sta-arr = 27000 (30 X 30 X 30)


However, I was not expecting the data to spring back in the display -

The dynamic array, whose depending variable was set to zero and had lost its values (or did it actually lose at all???), displayed all X's!!!

I understand that INITIALIZATION is not possible on variable arrays, and thought moving zeros to depending variable would kinda initialize it. This doesn't seem to be the case.

Could someone explain on the actual working on dynamic arrays? Is it advisable to use dynamic arrays as parameters to subroutines, or even more; as parameters to invoke a different transaction (maybe) ?

Dynamic Arrays look like a cool option to be used in various scenarios where one may want to optimize on space usage. I would like to know if there are any limitations/considerations to this.

Regards icon_smile.gif
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Aug 11, 2011 10:48 am    Post subject:
Reply with quote

read this topic

read this topic

read the cobol application programmers guide on COBOL Internal Tables

read the cobol application programmers guide on sharing data between modules.
this [url=http://ibmmainframes.comabout55443.html]topic[/url] is applicable

learn to use correct terminology

remember you are working on a mainframe,
and even COBOL on the PC does not have dynamic arrays
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Aug 11, 2011 12:29 pm    Post subject: Reply to: Regarding behaviour of a dynamic array
Reply with quote

Digest the reference dbz has posted.

Cobol has no (direct) support for "dynamic arrays". There is no "space saving" in working-storage.

Changing the length of a variable-length item does not affect the data referenced by the table in any way.

Try this

Code:
MOVE 20000 TO I J.
MOVE SPACE TO ws-dyn-arr
MOVE "A BANANA" TO ws-dyn-arr


If compiler option SSRANGE is not selected, the first MOVE will work, the second MOVE will work and your program will abend while trying to put a banana in your "array" (I'm assuming it is a small test program).

Setting the number of occurences to an absurd value does not change any data (in this case, your program code). Using the storage area, for instance by a MOVE, does...
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Thu Aug 11, 2011 1:20 pm    Post subject:
Reply with quote

The next link has some nice info about Dynamic Arrays and MVS Cobol using the LE heap :

http://home.centurytel.net/rjriek/
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: Thu Aug 11, 2011 1:25 pm    Post subject:
Reply with quote

Hello,

Quote:
How does a dynamic array work?
As mentoned earlier, no such thing exists.

Your learning time would be much better spent building a solid foundation of the things that do exist and that you are likely to use most often.

Suggest you continue to experiment with arrays with the COBOL documentation handy (there is a link to "IBM Manuals" at the top of the page). Also suggest you define your arrays with only a few elements rather than so many that it becomes easy to get lost. You can do this with single or multi-dimensional arrays. As you run your experiments, "dump" the entire array before and after you modify the content to verify what you expect has happened.

If you get stuck, someone here should be able to clarify.
Back to top
View user's profile Send private message
cybertaurean

New User


Joined: 22 Dec 2008
Posts: 85
Location: US

PostPosted: Thu Aug 11, 2011 1:45 pm    Post subject:
Reply with quote

Thanks a lot, amigos!!!

The last link by Peter has described the support that COBOL has for Dynamic Arrays.

Allow me present the test results -


Code:
       01 WS-SYSIN.                                           
          05 WS-I                        PIC 9(2).           
          05 WS-J                        PIC 9(2).           
                                                             
       01 WS-M                           PIC 9(2).           
       01 WS-N                           PIC 9(2).           
                                                             
       01 WS-LEN1                        PIC 9(10).           
       01 WS-LEN2                        PIC 9(10).           
                                                             
       01 WS-ARRAY-1.                                         
          05 WS-ARR1 OCCURS 1 TO 30 TIMES DEPENDING ON WS-I   
                                          INDEXED BY WS-A.   
             10 WS-ARR2 OCCURS 1 TO 30 TIMES DEPENDING ON WS-J
                                          INDEXED BY WS-B.   
                15 WS-ARR                  PIC X(30).         
       01 WS-ARRAY-2.                                     
          05 WS-ARR3 OCCURS 30 TIMES      INDEXED BY WS-C.
             10 WS-ARR4 OCCURS 30 TIMES   INDEXED BY WS-D.
                15 WS-ARRR                 PIC X(30).     

       PROCEDURE DIVISION.                           
       00000-MAIN-PARA.                             
                                                     
           ACCEPT WS-SYSIN FROM SYSIN               
           DISPLAY 'WS-I : ' WS-I                   
           DISPLAY 'WS-J : ' WS-J                   
           PERFORM VARYING WS-M FROM 1 BY 1 UNTIL WS-M > WS-I       
                   SET WS-A TO WS-M                                 
                   SET WS-C TO WS-M                                 
                   PERFORM VARYING WS-N FROM 1 BY 1 UNTIL WS-N > WS-J
                           SET WS-B TO WS-N                         
                           SET WS-D TO WS-N                         
                           MOVE 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'     
                                    TO WS-ARR (WS-A, WS-B)           
                           MOVE 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'
                                    TO WS-ARRR (WS-C, WS-D)     
                   END-PERFORM                                 
           END-PERFORM                                         
           MOVE LENGTH OF WS-ARRAY-1 TO WS-LEN1                 
           MOVE LENGTH OF WS-ARRAY-2 TO WS-LEN2                 
           DISPLAY 'CHUNK#1 : ' WS-ARRAY-1                     
           DISPLAY 'CHUNK#2 : ' WS-ARRAY-2                     
           DISPLAY 'LENGTH1 : ' WS-LEN1                         
           DISPLAY 'LENGTH2 : ' WS-LEN2                         
           MOVE ZERO TO WS-I WS-J                               
           MOVE LENGTH OF WS-ARRAY-1 TO WS-LEN1                 
           MOVE LENGTH OF WS-ARRAY-2 TO WS-LEN2                 
           DISPLAY 'CHUNK#1 : ' WS-ARRAY-1                     
           DISPLAY 'CHUNK#2 : ' WS-ARRAY-2                     
           DISPLAY 'LENGTH1 : ' WS-LEN1                         
           DISPLAY 'LENGTH2 : ' WS-LEN2                         
           MOVE 10   TO WS-I WS-J             
           MOVE LENGTH OF WS-ARRAY-1 TO WS-LEN1
           MOVE LENGTH OF WS-ARRAY-2 TO WS-LEN2
           DISPLAY 'CHUNK#1 : ' WS-ARRAY-1     
           DISPLAY 'CHUNK#2 : ' WS-ARRAY-2     
           DISPLAY 'LENGTH1 : ' WS-LEN1       
           DISPLAY 'LENGTH2 : ' WS-LEN2       
                                               
           GOBACK.   



Run with SYSIN = 1010 i.e. WS-I = 10 and WS-J = 10


Code:
WS-INDEX-VALUE : 0001                                                           
WS-I : 10                                                                       
WS-J : 10                                                                       
CHUNK#1 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXX                                                                     
CHUNK#2 : YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY         
                                                                               
                                                                               
                                                                               
                                                                               
                                                                      YYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYY                                                                     
                                                                               
                                                                               
                                                                               
                                                                               
          YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY         
                                                                               
                                                                               
                                                                               
                                                                               
                                                                      YYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
LENGTH1 : 0000003000                                                           
LENGTH2 : 0000027000                                                           
CHUNK#1 :                                                                       
CHUNK#2 : YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY         
                                                                      YYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYY                                                                     
                                                                               
                                                                               
                                                                               
                                                                               
          YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY         
LENGTH1 : 0000000000                                                           
LENGTH2 : 0000027000                                                           
CHUNK#1 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
CHUNK#2 : YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY         
                                                                               
                                                                               
                                                                               
                                                                               
                                                                      YYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYY                                                                     
                                                                               
                                                                               
                                                                               
                                                                               
          YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

LENGTH1 : 0000003000
LENGTH2 : 0000027000


As you can see, the data for static array (Y), appears fragmented whereas, the data for dynamic array (X), appears neatly stacked. The displayed lengths reflect the change in size.

Thoughts???

Wouldn't it be possible for me to get the chunk of data that I need by the following steps -

Code:
DATA-LEN = LENGTH OF WS-ARRAY-1
DATA-RQD = WS-ARRAY (1:DATALEN)


icon_biggrin.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Aug 11, 2011 2:41 pm    Post subject:
Reply with quote

I'll admit to being a little stubborn about terminology.
it is like calling a blue cow
a green horse
because you use it in a green horse race.

you can be cute and continue to call it a green horse,
but if it becomes ill,
you still have to take it to a cow doctor.

same with this DYNAMIC ARRAY nonsense.

it is dynamic MEMORY allocation used for a COBOL Internal Table.

you want to call it a Dynamic Array,
fine,
but you still have to use the terms Dynamic Memory Allocation
and
COBOL Internal Table
to find anything in the manual when you have a problem.
Back to top
View user's profile Send private message
cybertaurean

New User


Joined: 22 Dec 2008
Posts: 85
Location: US

PostPosted: Thu Aug 11, 2011 2:49 pm    Post subject:
Reply with quote

lol@Dino icon_biggrin.gif... I would take it to a Veterinary doctor who would treat cows as well as horses icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif

Us mere mortals make the mistake of calling it flexible names (well, the link by Peter http://home.centurytel.net/rjriek/ calls it so). Anyways, point noted.

Now, coming to the point, have you faced any issues with this "Dynamic Memory Allocation" in COBOL programs?

Like I mentioned before, no INITIALIZE, no REDEFINES.

I am going to be using a huge copybook structure with around 4 dimensional arrays (few of the intermediate indexes would be dynamic).

From your experience, have you found any skeletons that popped up due to usage of Dynamic Arrays.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Aug 11, 2011 3:00 pm    Post subject:
Reply with quote

cybertaurean wrote:


[...]

The last link by Peter has described the support that COBOL has for Dynamic Arrays.

[...]



Which is none.

Cobol supports various things that you can use to emulate, more or less successfully, the dynamic arrays of other languages.

However, unless you are going to insist that Cobol has "support for" credit-card processing, warehouse-control, accounting, etc etc, it does not, as I previously put it, directly support dynamic arrays. As dbz has put it, try finding dynamic arrays in the Cobol manual. It is on the page after the blue cows.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Thu Aug 11, 2011 3:01 pm    Post subject:
Reply with quote

Abraham Lincoln once asked, "If you call a tail a leg, how many legs does a dog have?" His answer was "Four -- calling a tail a leg doesn't make it a leg." YOU may continue to use the term "Dynamic Array" any way you want, but there is no such critter in COBOL. People used to working in Java or C / C++ will have a certain set of expectations when you say "Dynamic Array", and those expectations will not be met.

As long as you don't exceed the compiler limits, using a table with multiple OCCURS DEPENDING ON tables in WORKING-STORAGE is subject only to the usual restrictions -- if you change the number of occurrences in a table, there's no magic moving of data around, you have to do that yourself; the array will be allocated as if every dimension has maximum occurrences, etc.
Back to top
View user's profile Send private message
cybertaurean

New User


Joined: 22 Dec 2008
Posts: 85
Location: US

PostPosted: Thu Aug 11, 2011 3:15 pm    Post subject:
Reply with quote

There is a mention about -

"There is a sense in the mainframe universe that exotic structures like dynamic arrays and MVS Cobol are mutually exclusive. Those data structures are the domain of more sophisticated languages like C, C++, C# and Java. Well, that’s simply not true. There is a way to create dynamic arrays in MVS Cobol along with all the attendant structures like queues, sorted lists, binary search trees and even self balancing binary search trees such as AVL trees. It’s all done using language environment (LE) facilities."

----

"When I first heard of the LE version of heap in a training session, it got my attention. I was accustomed to creating dynamic arrays in C++, but thought it unlikely that such a thing would be possible in good old Cobol. And, of course, the very name heap was the trigger. In the C++ world, we are quite accustomed to the notion of heap storage. You can find the IBM documentation for heap in CEEA2190 – Language Environment Programming Guide. This document contains a rudimentary Cobol example of a linked list using heap beginning on page 183."

----

Maybe the lingo used by the person who wrote the above article (Dynamica Arrays) was wrong too? Or is it my comparing that with OCCURS DEPENDING ON which is really the mistake (guess so icon_smile.gif) ???

Thanks a lot, everyone... P-E-A-C-E icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Aug 11, 2011 3:20 pm    Post subject:
Reply with quote

Quote:
As you can see, the data for static array (Y), appears fragmented whereas, the data for dynamic array (X), appears neatly stacked. The displayed lengths reflect the change in size.


appears is the key word.

the amount of memory reserved in your working-storage for the ODO does not change,
no matter what you do to the ODO Object.

if you look at the assembler generated for the module,
you will see that the ODO Object value has an affect on the code generated to represent the actual data areas addressed by the ODO.

ODO's allow for compiler generated code to deal with varying usage of the table (value of ODO Object).
Search ALL will only look at active occurances
whereas a coded Perform varying will have to be coded to ignore items containing spaces (or whatever delimiter/code is used to deal with unused items).

you are missing the point of ODO's. they do not shrink or increase in size when the ODO Object value is changed.

The compiler generated code for an ODO will take into account used/unused occurances,
as dictated by the value contained in the ODO Object.

and an answer to your question about skeletons and Dynamic Arrays?

no, i read, consumed, tested and understood the literature,
removed all my assumptions and never have problems dealing with Cobol Internal Tables.

never had problems keeping track of what was going on with dynamic memory allocation either.

I would suggest you remove the word dynamic from your vocabulary,
and only use it when speaking of memory aquisition or SQL.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Aug 11, 2011 3:44 pm    Post subject:
Reply with quote

Quote:
f you look at the assembler generated for the module,
you will see that the ODO Object value has an affect on the code generated to represent the actual data areas addressed by the ODO.


should be:

Quote:
f you look at the assembler generated for the module,
you will see that the ODO Object value has an effect on the execution of the code generated to represent the actual data areas addressed by the ODO.
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: Thu Aug 11, 2011 3:49 pm    Post subject:
Reply with quote

Hello,

Quote:
(well, the link by Peter http://home.centurytel.net/rjriek/ calls it so).
Do you also believe that everythng you find on some website is correct? Is it possible that you have incorrectly understood what the author intended?
Quote:
Us mere mortals make the mistake of calling it flexible names
What utter nonsense. . .
You and those who believe this are eroding what took decades to establish. Sloppy use of terminology simply indicates one is unable or unwilling to abide by the established terminology. Or is just extremely unprofessional and/or lazy.

When embarking on a career in an already established field, you need to use the proper terminology of that field. If you feel some insatiable need to create terminology, invent a new field of endeavor and define the terminology that is acceptable.

It is one thing to mis-use terms - it is quite anothe to try and defend this as acceptable. . .

fwiw,

d
Back to top
View user's profile Send private message
cybertaurean

New User


Joined: 22 Dec 2008
Posts: 85
Location: US

PostPosted: Thu Aug 11, 2011 4:51 pm    Post subject:
Reply with quote

@dbz: thanks a lot!!! icon_smile.gif

@dick scherrer: it was a joke and meant to be taken in that sense. It's a case of "term misuse", I agree, but, I never mentioned that I'm not going to imbibe that piece of learning.

Food for Thought:
Does all this hold so much potential as to irritate someone. For me, it's all about learning, and trust me, I'm not eroding anything, for if it were the case, we would all have been tracing our steps back to the Stone Age.

P-E-A-C-E!!!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Thu Aug 11, 2011 4:55 pm    Post subject:
Reply with quote

I'm locking this topic. cybertaurean has an answer and obviously has some major hang up around not being a professional and using the correct terminology. I see no purpose in continuing this fruitless discussion.
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 Creating a dynamic sort card in JCL u... ChitraChhabra DFSORT/ICETOOL 4 Wed Aug 03, 2016 6:15 pm
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts Need to create file with Dynamic Name... kapil27 JCL & VSAM 4 Wed May 25, 2016 9:45 am
No new posts What is the maximum number of sort wo... Pravina M SYNCSORT 2 Mon Mar 14, 2016 4:51 pm


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