TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

Easytrieve Define Statement


Define Statement:

The DEFINE statement (with or without the keyword DEFINE) describes data fields within files or within working storage. Optionally, you can omit the DEFINE keyword when the field definitions immediately follow the associated FILE statement.

There are three conditions that apply to data fields either in a file or within working storage, as follows:

  1. Any number of fields can be defined.

  2. Field-names must be unique within a file or within working storage. There can be no duplicates. The same field-name can be defined in multiple files.

  3. A field must be DEFINEd before you can use it in your program.

Syntax:

[DEFINE] field-name {Location} {Attributes} [MASK] [VALUE]

Description:

The description of these fields is provided by the parameters of the DEFINE statement. The field-name, location, and attributes parameters are mandatory; MASK and VALUE are optional.


Field-name Parameter:

This is the name you give to the field you are defining. It must start with a letter; can contain letters, numbers, and special characters; and can be from 1 to 40 characters long.

Syntax:

[DEFINE] field-name

Example:

The field names in the sample program are illustrated below,

      2 *
      3 FILE PERSNL FB(150 1800)
      4   NAME                     17 16 A
      5     LAST-NAME            NAME  8 A
      6   PAY-GROSS                94  4 P 2
      7   DEPT 98 3 N
      8   DATE-OF-HIRE 136 6 N
      9     HIRE-MM DATE-OF-HIRE 2 N
      10    HIRE-DD DATE-OF-HIRE +2 2 N
      11    HIRE-YY DATE-OF-HIRE +4 2 N
      12  SALARY W 4 P 2
      13  BONUS W 4 P 2
      14  RAISE W 4 P 2
      15  SERVICE W 2 N
      16  CURR-DATE S 6 N
      17    CURR-MM CURR-DATE 2 N
      18    CURR-DD CURR-DATE +2 2 N
      19    CURR-YY CURR-DATE +4 2 N
      20 *

Location Parameter:

This parameter identifies the location of the named field within a record or identifies it as a working storage field. The codes to specify location are:

Syntax:

[literal]
[field-name]
{ } [+nn]
[W ]
[S ]
  • literal - Specifies the location of the file field's leftmost byte. It is the starting position of this field relative to the first position of the record (position one (1)).

  • field-name - Specifies the location of the leftmost byte of a file field as the relative displacement from the start of a previously defined field.

  • W or S - Establishes a working storage field. Fields coded as W are spooled to report (work) files; fields coded as S are not.

Example:

In the field definitions sample program (shown above), the first designation to the right of the field-name is the location parameter. Four of the fields,

NAME, PAY-GROSS, DEPT, and DATE-OF-HIRE

are specified with a numeric value that indicates the starting position of each of these fields relative to the beginning of the record.

Below four fields,

LAST-NAME, HIRE-MM, HIRE-DD, and HIRE-YY

are subfields, specified with a relative displacement to their primary fields: NAME and DATE-OF-HIRE.

Below six fields,

VAC-HRS, SALARY, BONUS, RAISE, SERVICE, and CURR-DATE

are located in working storage. CURR-DATE also has three subfields:

CURR-MM, CURR-DD, and CURR-YY.

Attributes Parameter:

This parameter is specified as three components: field length, data format and number of decimal positions, if any. These values are interdependent in many cases.

Syntax:

literal-2 {A/N/P/B/U} [literal]

Description:

  • literal-2 - Field Length (in bytes)

  • A/N/P/B/U - This represent the data format of the field

    1. A - Alphabetic
    2. N - Zoned decimal
    3. P - Packed decimal
    4. B - Binary
    5. U - Unsigned packed decimal
  • literal - Number of Decimal Positions is specified by literal-3.


The following table delineates the relationship between field length, data format, and the valid number of decimal positions for each field.

Field Attribute Relationships:

Data Format CodeMaximum Length (bytes)Number of Decimal Positions
A 254 Not Vaild
N 18 0-18
P 10 0-18
B 4 0-10
U 9 0-18

The field attribute specifications in the Sample Program Library Section, shown earlier, can be read as illustrated in the following table.

Field-nameLengthFormatDecimal Places
NAME 16 bytes A None
PAY-GROSS 4 bytes P 2
DEPT 3 bytes N None
DATE-OF-HIRE 6 bytes N None
VAC-HRS 3 bytes N None
SALARY 4 bytes P 2
BONUS 4 bytes P 2
RAISE 4 bytes P 2
SERVICE 2 bytes N None
CURR-DATE 6 bytes N None

MASK Parameter:

This optional parameter can specify a pattern (edit mask) for printing a numeric field on a report. Alphabetic fields cannot be edited.

Syntax:

MASK ([letter] [BWZ] [literal])

Explanation:

  • [letter] - Letter is an alphabetic identifier for a print mask. This identifier can be any letter A to Y.

  • [BWZ] - BWZ (blank when zero) suppresses printing a numeric field when it contains all zeros.

  • [literal] - Literal-4 is the print edit mask to use. It is an alphabetic literal created with a combination of the following characters:


CharacterDescription
9 Causes any digit to print
Z Causes any digit except leading zeros to print
* Causes an asterisk to replace leading zero digits
- Causes a minus sign to print before the first or after the last digit of a negative number
$ Causes a currency symbol to print before the first nonzero digit
X Permits any character to be printed with the edited data

Example:

  • '(999) 999-9999' - Used for Telephone Number

  • '999-99-9999' - Used for Social Security Number

  • '99/99/99' - Used for Date

  • '$$$$$$$9.99-' - Used for Money (with floating $)

  • '*******999.99-' - Used for Protected check amount


VALUE Parameter:

A field defined with a location of working storage (W or S), and a data format of A (alphabetic), is initialized to blanks. Numeric working storage fields are initialized to zeros. To initialize a working storage field to another value, use the VALUE parameter.

Syntax:

[VALUE literal]

Example 1:

For example, if you are defining an alphabetic field whose name is MONTH, and you want to initialize it to the value JANUARY, your statement might read.

DEFINE MONTH W 10 A VALUE 'JANUARY'

Explanantion:

  • DEFINE—is the keyword that identifies your statement

  • MONTH—is the name of the field being defined

  • W—is the location parameter = working storage

  • 10—is the field length parameter = 10 bytes

  • A—is the data format parameter = alphabetic

  • VALUE—specifies the initial contents of MONTH = JANUARY

Example 2:

Initialization of a numeric field might read

DEFINE YEAR W 4 N VALUE 1999

Explanantion:

  • DEFINE—is the keyword

  • YEAR—is your field-name

  • W—locates your field in working storage

  • 4—indicates a field length of 4 bytes

  • N—specifies a zoned decimal data format

  • VALUE—initializes field YEAR to 1999


If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal