INITIALIZE VERB
Moderators: dbzTHEdinosauer, Moderator Group
-
- Active Member
- Posts: 59
- Joined: Tue Jul 24, 2007 7:25 pm
INITIALIZE VERB
what is INITIALIZE VERB .give me example.
You can read more about the INITIALIZE Statement in the COBOL Manual
The INITAILIZE statement is used to initialize one or more variables to a pre-determined value. It is equivalent to one move statement for each variable.
Given the following code structure:
Is equivalent to:
There are issues with the INITIALIZE statement however. INITIALIZE does nothing with FILLER areas and creates a move statement for every variable.
If the OUTPUT-RECORD-AREA was a table item INITIALIZE would create a MOVE for every variable for every table subscript.
Now imagine a structure that may have hundreds or thousands of valuables in it. I think you can see that the over use of the INITIALIZE statement can have a dramatic affect on the performance of the program.
A better way to get the same results, with much better performance is to INITIALIZE the structure once at the start of you program; you should have an initialization paragraph. After doing the INITIALIZE, move the structure to a save area of the same structure, it can be all filler, as below:
Then, whenever you need to initialize the RECORD-OUT-AREA, simply
There are other options for the INITIALIZE Statement, but not normally used. You can read about those in the manual.
Dave
The INITAILIZE statement is used to initialize one or more variables to a pre-determined value. It is equivalent to one move statement for each variable.
Given the following code structure:
Code: Select all
01 RECORD-OUT-AREA.
05 ACCOUNT-NUMBER PIC S9(9) COMP-3.
05 FILLER PIC X.
05 ACCOUNT-BALANCE PIC 9,999,999.99
05 FILLER PIC X.
05 NEXT-DUE-DATE.
15 MM PIC XX.
15 DD PIC XX.
15 YYYY PIC XXXX.
01 OUTPUT-RECORD-COUNT PIC S9(9) COMP-3.
Code: Select all
(ex 1)
INITIALIZE RECORD-OUT-AREA.
(ex 2)
INITIALIZE OUTPUT-RECORD-COUNT.
(ex 3)
INITIALIZE ACCOUNT-BALALNCE.
Code: Select all
(ex 1)
MOVE 0 TO ACCOUNT-NUMBER.
MOVE 0.00 TO ACCOUNT-BALANCE.
MOVE SPACES TO MM.
MOVE SPACES TO DD.
MOVE SPACES TO YYYY.
(ex 2)
MOVE 0 TO OUTPUT-RECORD-COUNT.
(ex 3)
MOVE 0.00 TO ACCOUNT-BALANCE.
If the OUTPUT-RECORD-AREA was a table item INITIALIZE would create a MOVE for every variable for every table subscript.
Now imagine a structure that may have hundreds or thousands of valuables in it. I think you can see that the over use of the INITIALIZE statement can have a dramatic affect on the performance of the program.
A better way to get the same results, with much better performance is to INITIALIZE the structure once at the start of you program; you should have an initialization paragraph. After doing the INITIALIZE, move the structure to a save area of the same structure, it can be all filler, as below:
Code: Select all
01 RECORD-OUT-AREA-INIT_SAVE.
05 FILLER PIC S9(9) COMP-3.
05 FILLER PIC X.
05 FILLER PIC 9,999,999.99
05 FILLER PIC X.
05 FILLER.
15 FILLER PIC XX.
15 FILLER PIC XX.
15 FILLER PIC XXXX.
INITIALIZE RECORD-OUT-AREA.
MOVE RECORD-OUT-AREA TO RECORD-OUT-AREA-INIT-SAVE.
Code: Select all
MOVE RECORD-OUT-AREA-INIT-SAVE TO RECORD-OUT-AREA.
Dave
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page