Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 5: Data Division

VALUE clause

  • Before understanding VALUE clause it is important to understand literals, constants and figurative constants. For that, please refer section LITERAL and FIGURATIVE CONSTANT of Module 3 <LINK>
  • VALUE clause is used for initializing data items in working storage section. This can be done during variable declaration
  • While assigning value it is important to ensure that value of data item must not exceed picture size
  • VALUE clause cannot be specified for the data items whose size is variable
  • The VALUE clause defines the initial value of data item. But value in data item can be changed in procedure division using various available clauses
  • Basic syntax:-
    Syntax format 1:-
    VALUE IS literal
    Syntax format 2:-
    VALUES ARE literal-1 THRU | THROUGH literal-2
    Syntax format 3:-
    VALUES ARE literal-1, literal-2
    Note: - Keyword ‘IS’ and ‘ARE’ are optional to specify. In format 2 & 3 ‘VALUES ARE’ can be replaced with ‘VALUE IS’.
  • Literals should be specified in without quotes for numeric data items and with quotes for non-numeric data item
  • VALUE clause optional to specify. The values can be numeric literal, non-numeric literal or figurative constant
  • It can be used for both elementary as well as group data item. If specified for group data item, value must be non-numeric literal or figurative constant and also any elementary item inside that group cannot use VALUE clause.
  • VALUE clause cannot be used in data descriptive entries like REDEFINES. Also it cannot be used with the group/elementary data item specified with JUSTIFIED, SYNCHRONIZED & USAGE (other than DISPLAY)
  • VALUE clause cannot be used inside FILE SECTION except in the case of condition names.
Example 1:-

01 BB-AMOUNT PIC S999V99 VALUE IS -500.12.

Description:- BB-AMOUNT data item will be initialized with value ‘-500.12’.
Example 2:-

01 BB-AMT2 PIC 9999 VALUE 20.

Description:- BB-AMT2 data item will be initialized with value ‘20’.
Example 3:-


Description:- COMP-NAME data item will be initialized with value ‘BIG BROS’.
Example 4:-


Description:- EMP-FUND data item will be initialized with zeroes. Figurative constant ZEROES used for that purpose.
Example 5:-

01 DATE VALUE IS “28012018”. 05 DD PIC X(2). 05 MM PIC X(2). 05 YYYY PIC X(4).

Description:- DATE data item will be initialized with value “28012018’. Here the value is specified at group level. As a result, the data item DD, MM, YYYY will have respectively ‘28’, ‘01’, ‘2018’ as their initial value

© copyright mainframebug.com
Privacy Policy