View previous topic :: View next topic
|
Author |
Message |
avik
New User
Joined: 13 May 2008 Posts: 16 Location: kolkata
|
|
|
|
Hi,
I want to know for a large array in COBOL, which is the more costly statement t.."MOVE" or "INITIALIZE" ?
or both the COBOL verbs consume same amount of CPU? |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
INITIALIZE becomes MOVE statements during compilation. The best method to use to initialize a table depends on how often it needs initializing, the size of it, the number of elementary fields in it, the picture clauses, etc. Also, did you know you can initialize a table by assigning values to the elementary items at compile time? All occurrences are initialized that way, not just one. Please show us the table definition and answer the above questions and someone will help. |
|
Back to top |
|
|
avik
New User
Joined: 13 May 2008 Posts: 16 Location: kolkata
|
|
|
|
Code: |
01 LU-TERM-OUT.
05 OUT-LENGTH PIC S9(6) COMP SYNC.
05 FILLER PIC X(10).
05 OUT-USERID PIC X(8).
05 OUT-OWNERSHIP-CD PIC X.
05 LU-RESPONSE-BLOCK PIC X(999976).
*
*THIS 2ND GROPING OF "HEADER TYPE" DATE IS 52 BYTES
*
05 LU-RESPONSE REDEFINES LU-RESPONSE-BLOCK.
06 CTL-LINE-CNT PIC 9(6).
06 CTL-FUNCTION PIC XX.
06 CTL-FORMAT PIC X.
06 CTL-DSOI PIC X(41).
06 CTL-FCI PIC XX.
06 CTL-AREA PIC X(999924).
06 CTL-AREAA REDEFINES CTL-AREA.
10 CTL-TT PIC X(15).
10 CTL-NWB PIC X(11).
10 CTL-LI PIC X.
10 CTL-EI PIC X.
10 CTL-FRED.
15 FILLER PIC X(3).
15 OUT-LINE.
20 OUT-LINE-CHAR PIC X
OCCURS 999893 TIMES
INDEXED BY OUT-LINE-INDEX.
.
.
.
.
INITIALIZE CTL-AREA |
in this case,MOVE or INITIALIZE,which is preferable |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
If CTL-AREA is to be initialized just once,
Code: |
MOVE SPACE TO CTL-AREA |
should do it since all of your elementary fields are defined as alphanumeric. You probably wouldn't notice much CPU difference if you used
Code: |
INITIALIZE CTL-AREA |
instead. The only difference you would see in the result is that INITIALIZE will leave the FILLER untouched. If, on the other hand, CTL-AREA needs initializing more than once, the MOVE statement would definitely be the way to go. Also,
Code: |
20 OUT-LINE-CHAR PIC X [b]VALUE SPACE[/b]
OCCURS 999893 TIMES
INDEXED BY OUT-LINE-INDEX. |
would initialize OUT-LINE the same as
Code: |
INITIALIZE OUT-LINE |
would. Since I don't have access to a mainframe, the best thing for you would be to write a test program, compare, and share your findings. |
|
Back to top |
|
|
|