Monday, 28 July 2014

COBOL Initialize Statements | INITIALIZE statement | INITIALIZE Example.

In this tutorial, I'll discuss INITIALIZE Statement in COBOL. Also, try to explain COBOL INITIALIZE Verb with example. So, Let's start with the tutorial. 

INITIALIZE statement is used to set the initial value of the numeric field to ZERO and non numeric fields to SPACES.

The easiest way to use this statement is to code it without the Replacing clause and to refer to a group item. Then, all the numeric fields in the group are set to zeros, and all the alphabetic and alphanumeric fields are set to spaces.

In contrast, if you code the Replacing clause, you can specify which types of fields you want to change, and you can specify the characters that you want those fields to be initialized with.

INITIALIZE Format : 

COBOL INITIALIZED  Example
COBOL INITIALIZE STATEMENT


When you code a Replacing clause for a group item, only the data types that are specified in the clause are initialized. The other data types are ignored.

The Initialize clause always ignores fields that are defined as Filler, fields that are redefined, and index data items.

Example :
COBOL INITIALIZE EXAMPLE.


Coding Recommendations for INITIALIZE Statement.

  • Use Value clauses to initialize fields in working storage whenever that’s possible.
  • Use Move or Initialize statements to re-initialize fields whenever that’s necessary.
  • Don’t use Initialize statements to initialize large tables or record descriptions that don’t need to be initialized.

Created with Artisteer

No comments:

Post a Comment