In the COBOL programming language, you define all variables and data fields in a section of your program called the Data Division. Here, you set up records for disk files, printing layouts, counters and working storage for calculations. You define most data fields by giving them unique names, but the FILLER keyword lets you set aside memory space without the need for a name.
FILLER
Video of the Day
FILLER is a reserved word, meaning you cannot use the word for naming fields or records other than to define individual memory elements. You use FILLER immediately following a level number and preceding a PICTURE clause that defines a field's size and data type. COBOL restricts the use of FILLER to the Data Division; it does not apply to the Identification, Environment or Procedure divisions.
Video of the Day
Record Layouts
One of the most common uses for FILLER is for data record definitions. If you use a data file with a 150-character record length and you don't need to label every field in it, you can define the unneeded characters as FILLER, as in the following code:
01 customer-record. 05 FILLER PIC X(10). 05 customer-name PIC X(30). 05 customer-address PIC X(30). 05 customer-city PIC X(30). 05 FILLER PIC X(50).
This lets you read a 150-character record and identify the fields you want -- the customer name, address and city -- while ignoring the rest of the record.
SubString Extraction
You can use the FILLER keyword to assist in the extraction of substrings from a larger string. For example, to extract the first five digits of a ZIP code, you can set up the following statements in the Working-Storage Section:
01 whole-zip-code. 05 primary-zip PIC X(5). 05 FILLER PIC X(5).
In the Procedure Division, you move a ZIP-plus-4 code to whole-zip-code, then move primary-zip to a destination field. In doing so, you drop everything after the first five digits.
FILLER and VALUE
In a record, a FILLER field reserves memory space and accepts any kind of data you move into it. You can also define a FILLER field to have a value. Programmers use this technique frequently for setting up report headings, such as in the following example:
01 print-line. 05 FILLER PIC X(10) VALUE SPACES. 05 FILLER PIC X(15) VALUE "YEAR END REPORT". 05 FILLER PIC X(20) VALUE SPACES. 05 FILLER PIC X(5) VALUE "PAGE ". 05 page-number PIC ZZZ9.
Note that the report page header titles and spacing is all done with FILLER, except one named field that displays a page number.