IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Transformation of 2D Array to 1D array


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 2146
Location: At my coffee table

PostPosted: Mon May 12, 2008 8:17 pm
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

Moderator Emeritus


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

PostPosted: Mon May 12, 2008 8:43 pm
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
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

Moderator Emeritus


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

PostPosted: Tue May 13, 2008 1:08 pm
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
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

Moderator Emeritus


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

PostPosted: Tue May 13, 2008 1:28 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts To find an array of words (sys-symbol... JCL & VSAM 9
No new posts How to move values from single dimens... COBOL Programming 1
No new posts array indexing PL/I & Assembler 4
No new posts COBOL batch program using large size ... COBOL Programming 3
Search our Forums:

Back to Top