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

MOVE or INITIALIZE, which uses less CPU


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
avik

New User


Joined: 13 May 2008
Posts: 16
Location: kolkata

PostPosted: Sun Aug 10, 2008 10:30 am
Reply with quote

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

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sun Aug 10, 2008 10:38 am
Reply with quote

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

New User


Joined: 13 May 2008
Posts: 16
Location: kolkata

PostPosted: Sun Aug 10, 2008 11:22 am
Reply with quote

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

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sun Aug 10, 2008 8:57 pm
Reply with quote

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
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 - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts How to move DB2 Installation HLQ DB2 4
No new posts How to move values from single dimens... COBOL Programming 1
No new posts Reading the CSV data in COBOL and mov... COBOL Programming 4
Search our Forums:

Back to Top