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
 

 

Transformation of 2D Array to 1D array

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

New User


Joined: 02 May 2008
Posts: 5
Location: trivandrum

PostPosted: Mon May 12, 2008 7:12 pm    Post subject: Transformation of 2D Array to 1D array
Reply with quote

Hi,

My problem is to transform the following 2D Array to 1D array-

05 acc-lbl occurs 100 times.
10 acc-type pic x(08).
10 acc-line occurs 100 times.
15 acc-num pic 9(03).

I want the structure of 1D array as-
acc-type acc-num acc-num acc-num acc-type so on.........

1 acc-type may have any number of acc-num upto 100.
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon May 12, 2008 7:24 pm    Post subject: Re: Transformation of 2D Array to 1D array
Reply with quote

isha sharma wrote:
Hi,

My problem is to transform the following 2D Array to 1D array-

05 acc-lbl occurs 100 times.
10 acc-type pic x(08).
10 acc-line occurs 100 times.
15 acc-num pic 9(03).

I want the structure of 1D array as-
acc-type acc-num acc-num acc-num acc-type so on.........

1 acc-type may have any number of acc-num upto 100.


Code:
05 acc-lbl occurs 100 times.
    10 acc-type    pic x(8).
    10 acc-num-001 pic 9(3).
    10 acc-num-002 pic 9(3).
    10 acc-num-003 pic 9(3).
    10 acc-num-004 pic 9(3).
    10 acc-num-005 pic 9(3).
    10 acc-num-006 pic 9(3).
    10 acc-num-007 pic 9(3).
...
    10 acc-num-099 pic 9(3).
    10 acc-num-100 pic 9(3).


That will be a lot harder to work with.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon May 12, 2008 8:17 pm    Post subject: Re: Transformation of 2D Array to 1D array
Reply with quote

Or slightly alternative...
Code:

05 acc-num-count-001 pic s9(4) comp value 100.
05 acc-num-count-002 pic s9(4) comp value 100.
05 acc-num-count-003 pic s9(4) comp value 100.
...
05 acc-num-count-100 pic s9(4) comp value 100.
05 acc-lbl.
    10 acc-type-001 pic x(8).
    10 acc-num    occurs 100 times
                  depending on acc-num-count-001
                  pic 9(3).
    10 acc-type-002 pic x(8).
    10 acc-num    occurs 100 times
                  depending on acc-num-count-002
                  pic 9(3).
    10 acc-type-003 pic x(8).
    10 acc-num    occurs 100 times
                  depending on acc-num-count-003
                  pic 9(3).
...
    10 acc-type-100 pic x(8).
    10 acc-num    occurs 100 times
                  depending on acc-num-count-100
                  pic 9(3).
Starting from the front, after moving the non-zero (valid) nums for each type, plug the count of the valid nums to the count field.
It is not that difficult to work with stacked ODOs, as long as you realize that to change the count of one ODO, changes the location of all that follow....
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: Mon May 12, 2008 8:43 pm    Post subject:
Reply with quote

Hello,

Quote:
My problem is to transform the following 2D Array to 1D array-
What will you do with a 1d array that you cannot easily do with the array as defined?
Back to top
View user's profile Send private message
isha sharma

New User


Joined: 02 May 2008
Posts: 5
Location: trivandrum

PostPosted: Tue May 13, 2008 12:41 pm    Post subject: Reply to: Transformation of 2D Array to 1D array
Reply with quote

I have to search for duplicate acc-num for each acc-type.......
If we had a 1D array, I thought that will be better........
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: Tue May 13, 2008 1:08 pm    Post subject:
Reply with quote

Hello,

Please clarify the "rules".

Is the same acc-num in different acc-type considered a duplicate?

What are you to do when you find a duplicate?

Are you looking to prevent a duplicate when a new entry is added to the array or identify when there is already one or more duplicates?

If you show some example data and identify a few duplicates in it, it will be helpful. To do this, i'd suggest a grid with rows by acc-type and cols by acc-num. Please post using the "Code" tag at the top of the Reply panel (for readability).
Back to top
View user's profile Send private message
isha sharma

New User


Joined: 02 May 2008
Posts: 5
Location: trivandrum

PostPosted: Tue May 13, 2008 1:19 pm    Post subject: Reply to: Transformation of 2D Array to 1D array
Reply with quote

The details are as follows -
Supoose we have
acc-type(1), acc-type(2).
Now the following scenario wont be considered as dupliacte-
acc-type(1)
acc-num(1) = 1
acc-num(2) = 2
acc-num(3) = 3

acc-type(2)
acc-num(1) = 1
acc-num(2) = 2
acc-num(3) = 3

An example for dulpicate will be as follows -
acc-type(1)
acc-num(1) = 1
acc-num(2) = 1
acc-num(3) = 3

acc-type(2)
acc-num(1) = 1
acc-num(2) = 2
acc-num(3) = 3


So, acc-type(1) has got duplicate acc-num but acc-type(2) doesn't......
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: Tue May 13, 2008 1:28 pm    Post subject:
Reply with quote

Hello,

First, you need a loop within a loop for placeholders.

The outer loop will increment thru the acct-types. The inner loop will mark the current acc-num value to be tested.

From within the inner loop, perform a separate loop that will compare the "current value" against the other entries in that level of the table (i.e. an entry should not be compared against itself).

Continue thru the inner loop until all entries have been checked. When the inner loop completes, increment the outer loop and repeat until everything has been compared.
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 Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts COBOL Program to Read Array data raj4neo COBOL Programming 8 Sat Aug 15, 2015 12:28 am
No new posts Checking for High-Values in an array amitc23 COBOL Programming 10 Wed Aug 05, 2015 4:09 pm
No new posts How to define and use Double dimensio... pkmurali DB2 3 Mon Jun 22, 2015 8:36 am
This topic is locked: you cannot edit posts or make replies. How to Compare two values in an inter... ritnihi COBOL Programming 6 Wed Jun 10, 2015 11:49 am


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