IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

Convert Double dimensional array to single dimensional array

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC

 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> Mainframe COBOL
View previous topic :: View next topic  
Author Message
simha_it



Joined: 05 May 2005
Posts: 10

Posted: Thu Aug 21, 2008 4:36 pm    Post subject: Convert Double dimensional array to single dimensional array  

Hi,
I want to convert the double dimentional array into single dimensional array. For ex,
i have an array (2D) like this...
01 table-1
02 A occurs 5 times
03 A1 Pic x(01)
03 A2 Pic x(01)
03 B occurs 5 times
04 B1 Pic x(01)

while processing this array the program will loop through this 5*5 times
And the values will looks like: 1|2|a|b|c|d|e|3|4|f|g|h|i|j......where 1,2,3,4 are A values and a,b,c,d,e,f,g,h,i,j are B values

Now i want to replace this with single dimensional array and the result should looks like: 1|2|a|1|2|b|1|2|c|1|2|d|1|2|e|3|4|f|3|4|g|3|4|h|3|4|i|3|4|j......

or Is there any other way to convert this (my main intention here is to reduce the number of repetations)

Thanks in advance,
Simha
Back to top  
Robert Sample



Joined: 06 Jun 2008
Posts: 943
Location: Atlanta, GA

Posted: Thu Aug 21, 2008 4:52 pm    Post subject:  

Simha, I have to ask just what you think you're going to accomplish by this? You're not going to change the run time by making it a one-dimensional array instead of two ... running through the array will take more time per iteration even though there are fewer iterations. If you really think you want to do it, Code: 01 table-1
02 A occurs 5 times
03 A1 Pic x(01)
03 A2 Pic x(01)
03 B1 Pic x(01)
03 B2 Pic x(01)
03 B3 Pic x(01)
03 B4 Pic x(01)
03 B5 Pic x(01)
but instead of looking at one variable B1 now you've got to look at 5 variables ... as I said you're not gonna change total resources used!
Back to top  
simha_it



Joined: 05 May 2005
Posts: 10

Posted: Thu Aug 21, 2008 5:14 pm    Post subject:  

Robert thanks for your quick response...Actually i want to increase the performance of the program. Looping through 2D array will consume more time than 1D array...

but i will not get the expected result as per declaration mentioned your response. I want to accomplish the task by usig single dimensional array which can be done usin 2D....Suggest me if you have any idea..
Back to top  
Robert Sample



Joined: 06 Jun 2008
Posts: 943
Location: Atlanta, GA

Posted: Thu Aug 21, 2008 5:23 pm    Post subject:  

What do you mean by Quote: increase the performance of the program You may want to reduce run time, reduce CPU time, make more efficient use of files, etc, etc -- you really need first to decide what it is you want to do.

Programs are either I/O-bound or CPU-bound. If the program is I/O bound, reducing the array looping won't affect the program run time at all. If the program is CPU-bound but not CPU-bound in the array loop, again changing the code won't make a difference to the run time. And without using an analysis tool like STROBE you don't really know what the program is doing -- you're just guessing.
Back to top  
dick scherrer



Joined: 23 Nov 2006
Posts: 8733
Location: 221 B Baker St

Posted: Thu Aug 21, 2008 9:02 pm    Post subject:  

Hello,

Quote: you really need first to decide what it is you want to do.
If you explain the business requirement your array(s) support, we may be able to offer suggestions. An array (single- or multi-dimensional) of one-byte entries does not provide much to work with.

If you explain the "real" process, we may know some alternatives that would be performance-friendly.
Back to top  
dbzTHEdinosauer



Joined: 20 Oct 2006
Posts: 1639
Location: germany

Posted: Fri Aug 22, 2008 1:14 am    Post subject:  

changing the COBOL table from 2 dem. to 1 is not going to save you anything.
whether you have 5*5 or 25*1 you still have to address 25 items.

if you are using subscripts, change to INDEDEX BY.
that in itself will speed up the process
and
you don't have to change your logic.

as Robert says, you are guessing. If the program is 'slow', STROBE it.

Though there are a couple performance enhancements that you always know will help, converting from 2 dem. to 1 is not one of them.

2 dem tables are based on a business need to group. If there is no grouping whatsoever and it is a 2 dem. table, then it was crap design to begin with and it is all the ridiculous logic necessary to process a 2 dem table as a 1 - and vis-a-versa.

you can always enhance performance by:following the IBM suggestions for using indexing instead of subscripting. in other words replace subscripting by indexing.
re-arranging non-ambiguous EVALUATEs, otherwise known as fast-tracking. examplesyou have an EVALUATE for 10 trancodes. If you know the population stats, you put the most frequently used trancode first.
you are doing something based on a value in a fixed length COBOL table,
(online processing input of some type)
that could also have unused items.
Say it is a 20 item table (because occasionally, there could be 20 items)
but 95 percent of the time there are only 3.
I have stopped counting the amount of money I have earned (though my ex-wives haven't)
moving the 'WHEN SPACES DO Nothing' clause from the last of 5 or 6 to the first..

enough freebee crap for tonight - have already started my weekend.
Back to top  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> Mainframe COBOL
Page 1 of 1
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM