Cobol- Arrays Variable files

Arrays is such an important concept in Cobol. An array saves a lot of  Developer’s time, also CPU time.

Lot of data fields, we can define with minimal lines of code. We can use these in Variable file description also.

I am giving here two usages. These will give great help in your coding.

USAGE 1:

FD  Varaiable-File.

01 Variable-rec.

   02 ACCT-NUMB  PIC X(8).

   02 PAYMENTS  OCCURS 1 TO 5 TIMES DEPENDING ON

                    NO-OF-PAYMENTS   INDEXED BY INX.

           03 DATE         PIC 9(6).

           03 AMOUNT  PIC 9(5)V99.

USAGE 2:

The other way of coding VB files:

FD  Variable-file-2.

01 rec-1.

  02  General-info   Pic   x(6).

01 Rec-2

     Special-info   Pic   X(8).

Developer noting points:

  • The variable where “depending on” defined, can not be used redfines of other variable.
  • The values “NO-OF-PAYMENTS” and  “INX” must be equal, or, INX value less than NO-OF-PAYMENTS value (this applies to both Index and Subscript).
Advertisements

Author: Srini

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