COBOL: Move, Group Move, Low-values, High-values

COBOL has many keywords. I described here some great insights into COBOL. The key verbs are Low values, High values, Accept, Move, PERFORM, REDEFINES, etc.,

In COBOL, there are only three basic data types:

  • Alphabetic (PIC A)
  • Alphanumeric (PIC X)
  • Numeric (PIC 9)

Zeros in COBOL represents both numeric and Char. High values and Low values are non numeric literals.

  • MOVE copies data from the source identifier (or literal) to one or more destination identifiers. The source and destination identifiers can be group or elementary data items.

Read COBOL interview Questions here.

How MOVE combinations works in COBOL


There are two formats for the ACCEPT verb:

  • The first gets data from the keyboard.
  • The second lets you access the system date and time (that is, the date and time held in the computer’s internal clock) by using certain system variables.

PERFORM‥VARYING is used to implement counting iteration. It is similar to the for construct in languages like Pascal, C, and Java. However, there are some differences:

  • Most languages permit only one counting variable per loop instruction. COBOL allows up to three. Why only three? Before ANS 85 COBOL, tables were allowed only a maximum of three dimensions, and PERFORM‥VARYING was used to process them.
    • Both pre-test and post-test variations of counting iteration are supported.
    • The terminating condition does not have to involve the counting variable.

When the READ attempts to read a record from the file and encounters the end of file marker, the AT END is triggered and Statement Block1 is executed. If the NOT AT END clause is specified then Statement Block2 is executed.

You can use the REDEFINES clause to create a prefilled table by applying the following procedure:

Reserve an area of storage, and use the VALUE clause to fill it with the values required in the table. Use the REDEFINES clause to redefine the area of memory as a table.

 01 BonusTable.
   02 BonusValues PIC X(24) VALUE "050075085120100150135175". 
   02 FILLER REDEFINES BonusValues.  
      03 ServiceCategory OCCURS 4 TIMES.  
          04 MaritalStatus OCCURS 2 TIMES. 
               05 Bonus PIC 9(3).  

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.