Cobol Archive

COBOL RANDOM Function Examples

COBOL RANDOM Function generates the random fractional values ranging from 0 to 1. It generates values like For example if we declared the variable as below 01 WW-RANDOM-NUMBERS PIC 99.999 VALUE ZEROES. PERFORM VARYING WW-SUB1 FROM 1 BY 1 UNTIL WW-SUB1 > 9 COMPUTE WW-RANDOM-NUMBERS = FUNCTION RANDOM DISPLAY ‘–>’WW-RANDOM-NUMBERS END-PERFORM Result: –>00.443 –>00.060


INSPECT verb in COBOL is very useful and it is used to do the following functionalities  Count a particular Character in a string  Convert Lower case to upper case  Replace a particular Character with other character in a string  Replace a set of characters with another set of characters Below are the different examples on

COBOL DB2 Multi Row Fetch

Multi row Fetch Overview in COBOl Db2 program WITH EXAMPLE: Cobol Db2 multi row fetch concept will be used to retrieve multiple rows with a single fetch statement as opposed with a normal cursor which fetches only single record at a time. The multi-row fetch capability was introduced to DB2 z/OS in Version 8. This

COBOL Index & Subscript

COBOL Index and Subscript – Performance considerations Index and Subscript in COBOL are the very important concepts. Both are used to reference an array or table element in COBOL programs. By knowing the basic differences between the two, one can code the programs efficiently in performance point of view. 1. Index –> Represents the displacement

COBOL Perform Types and Usage with examples

Perform Verb in COBOL is used to execute a set of COBOL statements. There exists different types of performs based on the way that is being used. It is vital in keeping a cobol program structured by making it possible to call different paragraphs or sections from another paragraph or section. Following are some of

Cobol DB2 Program execution and Coding requirements

Unlike a normal COBOL program COBOL DB2 program has some special requirements to be considered while coding and execution. For ex: In the coding it is required to include the SQLCA and the program needs to be executed via Terminal monitor Program etc. COBOL DB2 Coding Part: 1. Do the coding as per the requirement,

Cobol-DB2 Cursor Overview

Db2-Cursor: Cursors in the application program are used to retrieve the multiple rows and process them one by one . Generally by using a singleton select statement in the application program, it is possible to retrieve only one row at a time as the host variable structure allows keeping one value at a time. Ex:

COBOL Renames Clause with Examples

COBOL Renames clause is used to regroup the elementary data items and gives them an alternative name. This is a logical grouping of the elementary data items which are defined in a sequential order.It is useful for renaming by overlapping elementary elements.66 Level number is used for defining it. [crayon-5d342b38e1658273085596/] – 01 , 77 levels

COBOL Arrays or Tables

Single dimensional arrays: Arrays are data structures that are used to simplify coding and improve processing efficiency. The primary uses of arrays are to define:  a series of similarly formatted input or output record fields in the FILE SECTION  a group of accumulators in WORKING-STORAGE for different categories of totals  a table in WORKING-STORAGE that


STRING AND UNSTRING with examples: TALLYING and COUNT options String is used to combine two or more strings/variables in to a single string. Examples: [crayon-5d342b38e1d9a468548050/] If you display the ‘name-in’ it shows like ‘ Mahender Reddy G ‘ i.e: it shows the full length of each variable INCLUDING THE SPACES. So this can be avoided