RAMESH KRISHNA REDDY mainframe discussion forum - cobol, db2,cics,jcl,file-aid,changeman,interview questions
Online Tutorials   | PREV  | TOP  | NEXT



DRONA SERIES
COBOL STUDY MATERIAL


COBOL VERBS - INITIALIZE



   
 

COBOL VERBS - INITIALIZE



INITIALIZE INITIALIZE verb initializes values in a data item to default value. Numeric data items initialized with ZEROS. Alphabetic character codes initilized with spaces. It wont initialize FILLER. Example - Initializing elementary data item. INITIALIZE WS-A. WS-A WS-A WS-A PICTURE BEFORE AFTER 9(4) 6847 0000 X(3) 12E <- SPACES XX99 WE48 <- SPACES A(4) WELS <- SPACES Example - Initializing group data item. 01 CUSTOMER-RECORD. 05 Customer-Name. 10 FirstName PIC X(06). 10 MiddleName PIC X(1). 10 LastName PIC X(05). 05 Customer-DOB. 10 Month PIC 99. 10 FILLER PIC X VALUE '/'. 10 Day PIC 99. 10 FILLER PIC X VALUE '/'. 10 Year PIC 99. After executing following statement, it will initialize all values to its default values. INITIALIZE CUSTOMER-RECORD. FirstName, MiddleName & LastName are initialized with SPACES. Month , Day & Year are initialized with zeros. Since FILLER wont get initialized by INITIALIZE verb, we have used VALUE clause which will initialize FILLER When program execution started. TIP : Using VALUE clause, we can initialize data items. But it works only once when program execution started, it will initialize the data item with whatever value specified with VALUE clause. Example - 01 WS-Month PIC 99 VALUE 11. When program execution started WS-Month data item contains value 11.
    

NEXT CHAPTER TOPIC : COBOL


                                   



Previous chapter in COBOL tutorial Starting of COBOL tutorial Next chapter in COBOL tutorial


Visit COBOL books section in this site for good books




Home | Donations | Online Tutorials | Books | Entertainment | Contactme | privacy |  sql tutorial | jcl interview questions | JCL Tutorial | JCL Tutorial - chapter1 | JCL Tutorial - chapter2 | JCL Tutorial - chapter3 | JCL Tutorial - chapter4 | JCL Tutorial - chapter5 | JCL Tutorial - chapter6 | JCL Tutorial - chapter7 | JCL Tutorial - chapter8 | JCL Tutorial - chapter9 | JCL Tutorial - chapter10 | JCL Tutorial - chapter11