Monday, 28 July 2014

COBOL Initialize Performance Tuning Tip

Initialize clause is used to initialize the values of variable. 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.

Normally programmer used initialize verb to initialized copybooks or temporary variable's first followed by bussiness logic. Its true that initialized verb is simple to use but ironically has huge impact on program performance If, for example, you carelessly initialize a 50,000-byte table that doesn’t need to be initialized.

Important points that need to be consider while using INITIALIZED verb to eradicate performace a issues pertain to INITIALIZED verb.

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.

To initialize large table and complex copybooks (with multiple REDEFINE Clause) you can INITIALIZE copybook in the begning of program logic and stored copybook data to some working storage variabe of same length and use same working storage variable to re-initialized same complex copybook or variables. Refer below example :

Created with Artisteer

No comments:

Post a Comment