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
 

 

Convert Double dimensional array to single dimensional array

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

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Thu Aug 21, 2008 4:36 pm    Post subject: Convert Double dimensional array to single dimensional array
Reply with quote

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
View user's profile Send private message

Robert Sample

Global Moderator


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

PostPosted: Thu Aug 21, 2008 4:52 pm    Post subject:
Reply with quote

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
View user's profile Send private message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Thu Aug 21, 2008 5:14 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Aug 21, 2008 5:23 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Aug 21, 2008 9:02 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Aug 22, 2008 1:14 am    Post subject:
Reply with quote

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. examples
    • you 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
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 Convert CLIST to REXX cvnlynn CLIST & REXX 12 Tue Jun 27, 2017 2:06 am
This topic is locked: you cannot edit posts or make replies. SDSF multiple spool datasets extracte... PJAlarcon CLIST & REXX 1 Fri Apr 21, 2017 10:50 pm
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts Splitting of single report to seperat... abdulrafi TSO/ISPF 7 Mon Mar 27, 2017 3:59 pm


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