View previous topic :: View next topic
|
Author |
Message |
senthils
Active User
Joined: 15 Nov 2005 Posts: 117 Location: Chennai, India
|
|
|
|
I have 2 tables which are defined as below.
Quote: |
01 table1.
03 sub1 occurs 18 times indexed by ix1.
05 t1-a pic 9(9) comp-3.
05 t1-b pic 9(17) comp-3. |
Quote: |
01 table2.
03 sub2 occurs 18 times indexed by ix2.
05 sub22 ocurrs 3 times indexed by ix22.
07 t2-a pic 9(9) comp-3.
07 t2-b pic 9(17) comp-3 |
I need to move t1-a and t1-b of first table to t2-a and t2-b of second table.
Before movement:
table1:
t1-a occurence 1 - 11
t1-a occurence 2 - 21
t1-a occurence 3 - 31
.
.
.
.
t1-a occurence 18 - 181
table 2:
t2-a occurence 1,1 - 0
t2-a occurence 1,2 - 0
t2-a occurence 1,3 - 0
.
.
.
.
t2-a occurence 18,1 - 0
t2-a occurence 18,2 - 0
t2-a occurence 18,3 - 0
After movement:
table 2:
t2-a occurence 1,1 - 11
t2-a occurence 1,2 - 0
t2-a occurence 1,3 - 0
.
.
.
.
t2-a occurence 18,1 - 181
t2-a occurence 18,2 - 0
t2-a occurence 18,3 - 0
I coded a PERFORM statement to do the movement.
Quote: |
PERFORM VARYING ix1 FROM 1 BY 1
UNTIL ix2 IS GREATER THAN 18
SET ix2 TO ix1
MOVE t1-a(ix1) TO t2-a(ix2 1)
MOVE t1-b(ix1) TO t2-b(ix2 1)
MOVE ZEROS TO t2-a(ix2 2)
t2-b(ix2 2)
t2-a(ix2 3)
t2-b(ix2 3)
END-PERFORM |
This is working now. But the problem is it is taking so much CPU time to execute this PERFORM statement and i have use this statement many times in my program.
Is there a better way of doing the above with less stress on CPU time? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How much is "so much"?
Why does this need to be done "many" times in the program?
Suggest you try using a w/s field that contains all 3 entries for a table2 entry.
Code: |
05 hold-entry.
10 he-a pic 9(9) comp-3.
10 he-b pic 9(17) comp-3.
10 filler pic 9(9) comp-3 value zeros.
10 filler pic 9(17) comp-3 value zeros.
10 filler pic 9(9) comp-3 value zeros.
10 filler pic 9(17) comp-3 value zeros. |
Move the actual data to he-a and he-b and them move hold-entry to sub22 rather than the individual fields. This eliminates 2/3's of the moves and reduces the index operations.
If you more completely explain the process, we may have some better suggestions. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Dick,
What was that really old method used in OS/VS COBOL for table-initialization of very large tables, where a higher group level was moved to a subordinate elementary level, which contained all the elements that required initialization and an internal propagation occurred?
I remember the compiler indicated that an MVCL would be generated (or maybe spelled out "Move Character Long").
Shaking away the Cobwebs....
Bill |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Bill,
Quote: |
What was that really old method used in OS/VS COBOL for table-initialization of very large tables, |
Something like:
Code: |
01 my-table-init.
05 my-init-item.
10 filler pic s9(9) comp-3 value zeros.
10 filler pic s9(17) comp-3 value zeros.
10 filler pic x(4) value '1234'.
05 rest-of-table.
10 . . . item2
10 . . . item3
10 . . . itemn
01 the-actual table redefines my-table-init. |
MOVE my-table-init to rest-of-table will propogate the initial value to the other array items. Once initialized, the "actual" table would be used for processing. (IIRC ) |
|
Back to top |
|
|
|